Over a million developers have joined DZone.

How to Test a Puppet Module

DZone's Guide to

How to Test a Puppet Module

· DevOps Zone
Free Resource

Download “The DevOps Journey - From Waterfall to Continuous Delivery” to learn learn about the importance of integrating automated testing into the DevOps workflow, brought to you in partnership with Sauce Labs.

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).

Discover how to optimize your DevOps workflows with our cloud-based automated testing infrastructure, brought to you in partnership with Sauce Labs


Published at DZone with permission of Scott Leberknight, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.


Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}