Managing Jenkins with Puppet, part 1: Basic installation

January 31, 2020 – Petri Lammi

It seems every other organization is using Jenkins these days. Jenkins is a continuous integration and continuous delivery server that can be used to automate building, testing, and delivering or deploying software. 

Many organizations also use Puppet for their configuration management needs. Puppet is, if not the de facto configuration management solution, at least one of the most mature and field tested ones. It consists of several server components, agents, a declarative programming language, amongst others. Puppet can be used to install, set up and manage large number of all kinds of resources.

While setting up a single Jenkins master server manually is not particularly challenging, setting up several, and managing changes on them over time, can become quite a burden to manage. With Puppet a lot of that burden can be taken care of with a set of tools that are designed for just for that.

We assume here that you already have a server instance with puppet agent installed. We will first install a minimal, working Jenkins master server and continue from there later.

First we need to have the puppet jenkins module in place. If you are using r10k or Code Manager (you should), add a line to your Puppetfile:

mod 'puppet-jenkins', '2.0.0'

or if you want to pin to a specific commit:

mod 'puppet-jenkins',  
  :git => '',  
  :commit => '3bd0774fddec9a78d86304d018db89a57130b9e3'

If you don’t use r10k or Code Manager, install the module on your puppetserver manually:

puppet module install puppet-jenkins --version 2.0.0

After you have the module in place, create a minimal manifest to install and set up a basic jenkins master. Here we will use LTS version 2.204.2:

class profile::jenkins_master { 

# Ensure needed java jdk is present
package { 'openjdk-8-jdk-headless':
  ensure => 'present',  

# Install and set up basic jenkins master 
class { '::jenkins':

version            => '2.204.2',    
lts                => true,
repo               => true,
configure_firewall => false,    
install_java       => false,    
port               => '8080',    
purge_plugins      => false,    
require            => Package['openjdk-8-jdk-headless'],  

After putting this manifest in place, preferably with the help of your version control system and r10k, run

$ puppet agent --test --verbose 

on your server and you should end up with a working basic Jenkins master. You can then proceed by navigating to your server url and finish the installation by following the install wizard.

Want to talk to an expert?

If you want to reach us, just send us a message or book a free call!