Testing Puppet R10k with Jenkins

This post covers testing an r10k puppetfile with Jenkins to prevent code with issues from reaching production. The Jenkins slave must have r10k installed to perform the tests listed below.

R10k (https://github.com/puppetlabs/r10k) is a utility for deploying Puppet environments and modules.

Puppetfile Check

The puppetfile check command is used to validate the syntax of the puppetfile.

r10k puppetfile check -v

Puppetfile Install

The puppetfile install command is used to download the actual puppet modules. This ensures that any errors such as non-existant repos or invalid names are caught before the code is merged to production. The -v or verbose option is used to view the modules as they are being downloaded.

r10k puppetfile install -v

Jenkins Job

The following section covers the code that can be used in the “Execute Shell” to handle the testing and installation of the puppet modules.

echo "Testing puppetfile syntax..."
r10k puppetfile check -v
echo "Testing puppetfile module installation..."
r10k puppetfile install -v

Jenkins Results

The following section covers the results of the jenkins job. The “Syntax OK” line is the result of the “r10k puppetfile check” command and the updating module portions are the module installation process.

[r10k.ci_poc_r10k.test] $ /bin/bash /tmp/hudson3146664036726728336.sh
Syntax OK
INFO     -> Updating module /home/jenkins/workspace/r10k.ci_poc_r10k.test/modules/ci_poc_puppet
INFO     -> Updating module /home/jenkins/workspace/r10k.ci_poc_r10k.test/modules/module_version
Finished: SUCCESS