Managing Puppet modules on Vagrant with Librarian-Puppet

When it comes to source code control I’m a purist: I avoid storing any derived files (ex. generated CSS) or third-party code.  So when I started using PuPHPet to generate Vagrant and Puppet configurations, I was dismayed by the gigantic /puphpet/puppet/modules  directory.  3,000 files totaling 5 MB?!  There must be a better way.

Instead of keeping the Puppet dependencies in our repository, librarian-puppet lets us automatically load these modules during setup of the Vagrant box.  In our Vagrantfile  we add a new setup script:

The setup script is based on the bootstrap script from vagrant-puppet-librarian.

librarian-puppet reads from our Puppetfile  — also provided by PuPHPet — for a list of all the Puppet dependencies to download.  It behaves similar to the Windows path limit fix:

  • The modules install to a temporary directory because I had issues running librarian-puppet install  inside the /vagrant  directory, presumably because it’s shared with Windows.  After installation, the modules are copied to /vagrant/puphpet/puppet/modules  so Vagrant’s setup can continue as usual.
  • If the temp directory already exists during setup, the script assumes that the Puppet dependencies are ready and aborts.
  • Temporary files are stored in /var/tmp  to persist during restarts, and the run: 'always'  parameter in the Vagrantfile  ensures that the script will fire during both vagrant reload  and vagrant up .

Finally we add two entries to our .gitignore .

Now we can keep our repository lean while leveraging the power of third-party Puppet modules!

Leave a Reply

Your email address will not be published.