reagan

Trust But Verify - Ruby Jenkins build script that automates the testing of individual items in a monolithic chef-repo. Reagan allows you to test only the cookbooks or roles/environments that have changed in a particular pull request and includes the following tests:

See my blog post for examples: www.therealtimsmith.com/home/2015/11/trust-but-verify-your-chef-infrastructure/

Requirements

Running Locally

While this app is written to be run as a Jenkins job it can also be run locally. This is particularly useful when you want to run the tests prior to commit. To run Reagan locally use the following command line options:

Running in Jenkins

1) Create a Gemfile in your chef-repo and add the reagan gem to the file. Example:

source 'https://rubygems.org'

gem 'chef', '~> 12.3'

group :test do
  gem 'reagan', '~> 0.8'
  gem 'rubocop', '~> 0.30'
  gem 'foodcritic', '~> 4.0'
end

2) Setup a Jenkins job per the instructions in the Github Pull Request Plugin documentation at wiki.jenkins-ci.org/display/JENKINS/GitHub+pull+request+builder+plugin

3) Add the following it:ms to your job configuration:

3) If you don't already have a Jenkins user for your Github account create one now. You can always use your own account's privs, but you really shouldn't do this. Once you have an account with privs on your chef-repo go to github.com/settings/applications and create a oauth token. Make sure the token has repo and public_repo scope. Same off the token for the config creation below

4) Create a Reagan config file (example is in the repo at reagan.yml.EXAMPLE). Unless you specify a custom config location with -c this should be at /etc/reagan.yml, and should be owned by the Jenkins user with 600 privs so to keep your github token private. The config contains the following items:

5) At this point you should be able to open a test pull request