Fully functional Puppet testing environment using Vagrant
a.k.a. Awesomeness in a box
This repo allows testing of your Puppet manifests and modules in a fully isolated local environment managed by Vagrant. The setup covers general Puppet best practices such as externalizing your environment data into Hiera. A sample fileserver is also setup if you need it.
The configuration bundled in this sample setup will install and configure a base MySQL server on your Vagrant virtual machine. This is here for demonstration purposes only; you will obviously change this to whatever your needs are.
As with any great things in life, please enjoy responsibly!
How to use?
- Install Vagrant
- Optionally, install VirtualBox (to manage Vagrant boxes or otherwise just see them)
- Install Puppet 3.x
- Install librarian-puppet
I strongly suggest installing the
maestrodevfork of librarian-puppet because it seems to fix a few module versions issues compared to the original.
- On the command line, navigate to the "puppet" directory (
librarian-puppet installto install all Puppet module dependencies
Starting your first VM
Please note that this sample environment uses CentOS 6.4 as a base Vagrant box. You can use whichever you need by changing
vagrant upto startup your VM. On the first run, it'll download the box image file so prepare to wait a bit.
- Once a box is started, you may just run
vagrant provisionto re-run Puppet on the host
- To re-create your VM from scratch, run
vagrant destroyfollowed by
Version control your Puppet manifests
/puppet directory that's included in this repository is included for simplicity of kickstarting the project on your
computer. What you'd generally do is have everything under the
/puppet directory be its own Git repo, and clone that
repository into the
/puppet directory here.
Then on your production Puppetmaster, you would use this repository's
master branch as your production Puppet manifests
By making all your changes in specific Git branches, you can safely test those changes using Vagrant, then
promote them to production by merging to
master when ready. Then on your Puppetmaster,
git pull to get the latest
(and, more importantly, tested!) code.
Testing multiple servers
In this project, Hiera is configured to use the box's host name as a way of selecting the right YAML files to use. This is
a good practice to follow as it allows for much easier node configuration. Setting it up this way also allows you to select
the box you want to test by simply changing Vagrant's
config.vm.hostname configuration in