1
votes

I'm in the process of ditching MAMP in favor of a Vagrant Ubuntu VM + Puppet for my Wordpress development workflow. Ultimately, I would like to reuse the puppet provisionning on the staging and production machines.

Vagrant defaults to running the Puppet files (modules, manifests, hiera.yaml) under /tmp/vagrant-puppet-3. However, my understanding is that on a real server one would put these files under the default Puppet directory which is /etc/puppet/.

I understand that Puppet will work fine under /tmp/vagrant-puppet-3, however I would like my developement machine to be as close as possible to the future staging / production machines.

So ... my queston is : How can you get Vagrant to create and run the puppet files from /etc/puppet/ ?

2

2 Answers

0
votes

The Vagrant Puppet provisioner has three variables of interest. You can specify the manifest_file to identify the starting manifest, the manifests_path to identify the manifests directory and the modules_path to provide a hash of module paths. For your example, the relevant portion of the vagrantfile might look like this:

local.vm.provision :puppet do |puppet|
   puppet.manifests_path = "/etc/puppet/manifests"
   puppet.module_path = "/etc/puppet/modules"
   puppet.manifest_file = "/etc/puppet/manifests/site.pp"
   puppet.options = [
      '--verbose',
      '--debug',
   ]
end

More details here: https://docs.vagrantup.com/v2/provisioning/puppet_apply.html.

0
votes

One option here is to use a tool like librarian-puppet to auto-install your Modules into /etc/puppet/modules/ on the Vagrant VM. Librarian-puppet is able to download specific versions of any Puppet modules from GitHub or PuppetForge.

Here's a wonderful example of how you could implement this in practice (including a sample VagrantFile, etc.): https://github.com/purple52/librarian-puppet-vagrant

In the above example, pay close attention to the main.sh shell provisioning script for Vagrant. It is what actually installs librarian-puppet on the VM, and then calls librarian-puppet install (to install the configured modules).

After librarian-puppet has initialized the VM, you can simply use the normal Puppet provisioning in Vagrant to actually load/run the modules, e.g.

# This assumes you have a "puppet/manifests/main.pp" script 
# under your vagrant folder
config.vm.provision :puppet do |puppet|
  puppet.manifests_path = "puppet/manifests"
  puppet.manifest_file  = "main.pp"
end