Example Puppet config that can be reused between Vagrant and "real" systems
Ruby Puppet Shell
Switch branches/tags
Nothing to show
Latest commit 0852b9d Jan 29, 2013 @blalor add references
Failed to load latest commit information.
puppet initial commit Jan 29, 2013
.gitignore initial commit Jan 29, 2013
README.md add references Jan 29, 2013
Vagrantfile initial commit Jan 29, 2013


Reusable Puppet config for Vagrant

This provides a very simple example that shows how you can reuse Puppet configuration between Vagrant and your non-Vagrant systems, including data lookup via Hiera.

Tested with Puppet 3.0.2.


The Vagrant-specific configuration is captured in the Vagrantfile. The resulting Puppet invocation is

cd /tmp/vagrant-puppet/manifests \
&& FACTER_is_vagrant='true' puppet apply \
    --hiera_config hiera.yaml \
    --modulepath '/tmp/vagrant-puppet/modules-0' \

When provisioned (via vagrant up or vagrant provision) you will see the following on the console:

Notice: role::ui configured for vagrant; hostname:

Other environments

A sample puppet_apply.sh script is included in the puppet directory. All that is required is to clone this repository (or otherwise make the files available on the target system).


is_vagrant fact

This could be replaced with the direct definition of a data_center fact.

Vagrant shell provisioner

Vagrant takes care of providing mounts for the manifests and modules, so the configuration would only get shuffled around a bit, but it's possible to directly invoke puppet_apply.sh from Vagrant.

hieradata path messiness

There's no way to provide variables to Hiera for path expansion other than via Puppet itself. It's a bit chicken-and-eggy. The provided hiera.yaml uses a relative path to the hieradata directory that is compatible with the Vagrant invocation of Puppet, and the example puppet_apply.sh similarly takes care of the path munging, but it doesn't feel all that clean to me.