DevOps Zone is brought to you in partnership with:

Scott is a Senior Software Architect at Altamira Corporation. He has been developing enterprise and web applications for over 15 years professionally, and has developed applications using Java, Ruby/Rails, Groovy/Grails and Python. His main areas of interest include object-oriented design, system architecture, testing, and frameworks of all types including Spring, Hibernate, Ruby on Rails, Grails, and Django. In addition, Scott enjoys learning new languages to make himself a better and more well-rounded developer a la The Pragmatic Programmers' advice to "learn one language per year." Scott is a DZone MVB and is not an employee of DZone and has posted 43 posts at DZone. You can read more from them at their website. View Full User Profile

How to Test a Puppet Module

10.27.2012
| 4358 views |
  • submit to reddit

Originally authored by Brandon Marc Aurele

We recently acquired some new (and old) hardware for a few of our internal big data projects. This encouraged us to research and implement an automated provisioning system. We decided to use Razor because of its relative ease of use, but more importantly its native integration with Puppet. As a part of setting up our environment worked with a few different Puppet Modules and I also needed to write my own Module that would install Blur. I am writing this blog to discuss how I went about iteratively testing my module.

Testing Modules

I needed to test that the module was being properly installed on any “new” machine that my Puppet Master was provisioning. I wanted to test the module locally (to the master) without having to load my module to the Puppet Forge; as this would likely be very slow and increase my development time. Unfortunately Puppet really wants to install modules from the Forge.

To get around this issue I cloned my Module repository to the Puppet Master box, built the module, and then forcably installed the module. This will cause Puppet to install the module even if it receives an error or a warning. You should now be able to add your Module to the sites.pp and it will be installed on the specified endpoints. You can edit the module in /etc/puppet/modules/YOUR_MODULE to see small changes immediately, but be careful as this will require you to also uninstall the module forcably.

  # Clone the repo
  git clone REPO
  cd REPO

  # Build the module
  puppet module build

  # Forcably Install
  puppet module install /pkg/YOUR_MODULE-VERSION.tar.gz --force

  # Forcably Uninstall (if you edit the module manually)
  puppet module install AUTHOR-YOUR_MODULE --force

These few commands, paired with a well configured Vagrant environment, allowed me to rapidly deploy module changes to fresh machines and dramatically reduce my write, test, and repeat loop. It may also be possible to achieve this workflow using symlinks from your repo to the Modules folder, allowing for an even more rapid code to deploy loop, but I was not able to get it working properly (possibly a versioning/installation issue).

Published at DZone with permission of Scott Leberknight, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)