Vagrant & Puppet Best Practices

During my usage of Vagrant I've discovered some best practices that will help you develop puppet projects more efficiently.

1) Use librarian-puppet to manage your puppet modules

librarian-puppet is an excellent tool for managing your puppet module dependencies.

It is only supported on Linux at the current moment as far as I can tell so if you are running on windows there are two solutions:

  1. Attempt to use it with MSYS which is something I haven't tried yet. YMMV.
  2. Install it on the target machine you are currently testing and ssh to it in order to use librarian-puppet. It's not optimal but it works.

I have tested and used the second option mainly to save time and to allow me to develop my puppet projects more easily on windows.

You have to share the modules library in order to manage the puppet modules using librarian-puppet on the target machine and develop your project on windows which brings me to my next point.

2) Share the modules directory

In order to use the puppet modules globally share the /modules/ directory using:

config.vm.share_folder('modules', '/etc/puppet/modules', 'modules')

This way you can ensure that the dependencies are both on the development machine and on the target machine.

Make sure your module path in the provisioning configuration is set to 'modules' like this:

puppet.module_path = "modules"

3) Share the templates directory

In order to use templates with vagrant you have to share the project's template directory using:

config.vm.share_folder('templates', '/tmp/vagrant-puppet/templates', 'templates')

Make sure your templates path in the provisioning configuration is set to '/tmp/vagrant-puppet/templates' like this:

puppet.options = ["--templatedir","/tmp/vagrant-puppet/templates"]

4) When provisioning a puppet master share the required manifests

In order for the puppet master to provision the rest of the nodes share the project's manifests that are not related to the puppet master itself using:

 

master_config.vm.share_folder("puppet-master", "/etc/puppet/manifests", "puppet-master")

 

I selected puppet-master as the folder name where all the manifests reside but you can select any folder name you'd like.

Happy provisioning everyone.