Puppet Beaker

Puppet Beaker

Introduction:

Beaker is a test framework created by Puppetlabs to run tests against puppet modules on real servers (VM, containers whatever) and test that they do what they say they should do.

Installing beaker is usually done by adding a few lines to the Gemfile:

# Beaker

group :acceptance do

gem 'beaker'

gem 'beaker-rspec'

gem 'beaker-hiera'

gem 'beaker-puppet_install_helper'

end


Beaker nodesets:

Next, we need to add node descriptions providing information on the operating system and releases to run tests on. These are placed into the spec/acceptance/nodesets/ folder.

You must have at least a default.yml in the nodesets folder inside your acceptance folder. You can have different yaml files for different platforms you wish to test against.


Role of spec helper in spec/acceptance/nodesets/ folder:

The spec helper do the tasks needed in order to prepare your SUT (system under test).

This might include installing puppets, installing your puppet module dependencies, etc..


The filename is important, it must end in _spec.rb in order for the test harness to detect it. You can see that there are many matches you can use to run pretty much any kind of test you can think of.


Running Test:

bundle exec rake acceptance


This command will spin up your described servers in nodesets, install your puppet modules and dependencies, and test your assertions.


Conclusion:

They will maybe slow, but they can be very helpful, and potentially the only way to really test the functionality of a puppet module in an end-to-end way.

Puppet is a system configuration management tool. Unit tests can only go so far as to make sure the compiled catalog is “correct”. Puppet acceptance tests can help you go 100% and ensure that your module literally does what it says it does by running tests against actual systems, files, packages, and services. 




Relavant Blogs:

Puppet condition 

Puppet Beaker 

Chef data bags 

AWS CodeBuild: A Fully Managed Build Tool

Recent Comments

No comments

Leave a Comment