Tuesday, March 15, 2016

Replacing Boxen with Vanilla Puppet (for setting up a new mac)

I recently got a new MacBook at work and decided to overhaul my personal setup routine. Last time I tried an early version of Boxen, and although I was pretty happy with it there were a few things that bothered me. It is very opinionated, and I had a hard time stopping it from overwriting my .gitconfig and things like that. It also dragged in a series of dependencies I didn't feel the need for, and made Homebrew a bit weird by installing it in the non-standard location /opt/boxen/homebrew.

Since Boxen is based on Puppet, and I've used plenty of Puppet on Linux, I wanted to simplify things a bit and see how far standard Puppet on OS X would get me.

Warning! Make sure you don't install puppet using brew! It'll install an old version which is not trivial to uninstall.

It's fairly straight forward to install Puppet on a Mac, but since there is no standard package manager, like there's yum or apt on Linux, you have to set it up with a provider, in our case: Homebrew. I installed Homebrew manually at this point, but I think you could actually have Puppet do it for you.

Next, we have to install a puppet module for Homebrew. I found found a good one here by Kevin James (I tried the gildas and halyard ones first, but kept running into problems with them).

As Puppet goes, it has to be executed as superuser:

    sudo puppet module install thekevjames-homebrew

and it depends on the Puppet standard library:

    sudo puppet module install puppetlabs-stdlib

Now we're ready to fire away and apply a puppet file defining our packages:

    sudo puppet apply puppet-mac.pp

As an example, consider my own puppet-mac.pp - note how I've got various kinds of packages:

  • normal packages, these are built from source by Homebrew
  • casks, which are Homebrew's notion of pre-built binaries
  • gems, for those weird pieces of software that are not available via Homebrew
People who enjoy Boxen will probably not see the big point of going this way, but I think it feels easier and more elegant. It also reduces the discrepancies between my Linux and Mac setup.