I’m currently teaching myself how to do Puppet. Why? Well, at Percona we support a bunch of platforms for our software. This means we have to maintain a bunch of Jenkins slaves to build the software on. We want to add new machines and have (up until now) maintained a magic “apt-get install” command line in the Jenkins EC2 configuration. This isn’t an ideal situation and there’s been talk of getting Puppet to do the heavy lifting for a while.
So I sat down to do it.
Step 1: take the “apt-get install” line and convert it into puppet speak.
This was pretty easy. I started off with Vagrant starting a Ubuntu Lucid 32 VM (just like in the Vagrant getting started guide) and enabled the provision using puppet bit.
Step 2: find out you need to run “apt-get update”
Since the base VM I’m using was made there had been updates, so I needed to make any package installation depend on running “apt-get update” to ensure I was both installing the latest version and that the repositories would have the files I was looking for.
This was pretty easy (once I knew how):
exec {"apt-update": command => "/usr/bin/apt-get update", }
Exec["apt-update"] -> Package <| |>
This simply does two things: specify to run “apt-get update” and then specify that any package install depends on having run “apt-update” first.
I’ve also needed things such as:
case $operatingsystem { debian, ubuntu: { $libaiodev = "libaio-dev" } centos, redhat: { $libaiodev = "aio-devel" } default: { fail("Unrecognised OS for libaio-dev") } } package { "libaio-dev": name => $libaiodev, ensure => latest, }
The idea being that when I go and test all this stuff running on CentOS, it should mostly “just work” there too.
The next step? Setting up and running the Jenkins slave.