Ask Your Question

How to test puppet changes without committing?

asked 2016-04-05 22:12:41 -0500

UnitedMarsupials gravatar image

We use Puppet with Foreman here, and it is the Foreman (with the Puppet add-on), that controls, which classes are applicable to each host.

Foreman can be told to apply a particular git-branch to a particular host, and that's how our development is currently ongoing. Trouble is, you still have to commit your changes (even if only to a branch), before you can test them, which increases noise.

Is there a way puppet apply or puppet agent (or some other incarnation) can run simulating the regular agent-daemon precisely except getting the modules from a specified local directory instead of from puppet-master?

We use Puppet-3.7.5 at the moment. Thanks!

edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted

answered 2016-04-09 03:23:38 -0500

updated 2016-04-09 03:26:23 -0500

Have a look at some Puppet Forge modules, e.g. one I wrote recently here.

  • Ensure you have Vagrant installed
  • Ensure you have Rubygems installed
  • Ensure you have bundler installed (gem install bundler)


$ git clone
$ bundle install
$ export BEAKER_destroy=no
$ bundle exec rake beaker

Now you have a working development environment in Vagrant.

Moreover if you make changes to the code, you can test those changes without committing.

You can also do a lot of development and testing just using Rspec-puppet.

$ bundle exec rake spec

You can also do

$ bundle exec rake validate   
$ bundle exec rake lint

This checks all your files for syntax and style issues.

It's a bit of a learning curve to set all this up for your own modules, but it's the best way to do Puppet development. I never need to log onto a long-lived test environment, and I never log on to a Puppet master.

edit flag offensive delete link more

answered 2016-04-13 19:07:42 -0500

Gary Steven gravatar image

Copy your modules to another host you want to test them on, in this example I will use a directory named modules in my home directory. You can then use puppet apply to simulate what the class will do. This gets a little more complicated if you are using exported resources and you have to make some additional changes or pass parameters to puppet apply but this will let you test your modules on a host that is not a puppetmaster or foreman.

puppet apply --modulepath=~/modules/ -e "include class"
puppet apply --modulepath=~/modules/ -e "class { 'foo': param1 => value1, param2 => value2 }"
edit flag offensive delete link more


Yes, this is, pretty much, what I did, while waiting for answers :) Except I construct the `artificial-site.pp` with an `include` for every module defined for the host in Foreman and an `artificial-hiera.yaml` pointing at my hiera subdir. What's missing are the exported resources -- any ideas there?

UnitedMarsupials gravatar imageUnitedMarsupials ( 2016-04-13 21:33:24 -0500 )edit

You can hand edit your puppet.conf on the host your testing on to set all your values for puppetdb such as report = true reports = puppetdb You might need to adjust your routes.yaml as well - You can take values from your current puppet master

Gary Steven gravatar imageGary Steven ( 2016-04-19 10:52:10 -0500 )edit

answered 2016-04-13 21:07:32 -0500

DarylW gravatar image

We have a large monorepo with all of our modules in them, and a collection of modules from the forge. We install all our forge modules into /etc/puppet/modules, and we have scripted a command to rsync our modules, manifests, and hieradata into the /etc/puppet/environment/ENVNAME/

This allows us to easily update our changes, then re-run the puppet agent one any of the nodes in our cluster to see the effect of our code updates.

It isn't as optimal for the automated deployments off of our CI/CD pipeline, but it helps during the development process.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2016-04-05 22:12:41 -0500

Seen: 215 times

Last updated: Apr 13 '16