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/
?
The Vagrant Puppet provisioner has three variables of interest. You can specify the
manifest_file
to identify the starting manifest, themanifests_path
to identify the manifests directory and themodules_path
to provide a hash of module paths. For your example, the relevant portion of thevagrantfile
might look like this:More details here: https://docs.vagrantup.com/v2/provisioning/puppet_apply.html.
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 installslibrarian-puppet
on the VM, and then callslibrarian-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.