Friday, March 21, 2014

Automating Computer Setup with Boxen

I just finished setting up a new laptop at work, and in doing so I revamped my personal computer automation quite a bit. I set up Boxen for installing software, and I improved my handling of dot-files using vcsh, which I'll cover in the next blog-post after this one.

Since it's a Mac, it doesn't come with any reasonable package manager built in. A lot of people get along with a combination of homebrew or MacPorts plus manual installs, but this time I took it a step further and decided to install all the "desktop" tools like VLC and Spotify using GitHub's Boxen:

  include vlc
  include cyberduck
  include pgadmin3
  include spotify
  include jumpcut
  include googledrive
  include virtualbox

If the above excerpt looks like Puppet to you, it's because it is. The nice thing about this is that I can apply the same puppet scripts on my Ubuntu machines as well. Boxen is Mac-specific, Puppet is not.

It was a little weird to get started with Boxen, as you're offered a download, but you are supposed to fork their our-boxen repo and take it from there. Here's a short recap:

  1. Create /opt/boxen/ and give yourself permissions to write in it
  2. Clone your our-boxen fork into /opt/boxen/repo
  3. cd into repo and run ./script/boxen
  4. Add further modules (recipes) in repo/Puppetfile and include them in repo/manifests/site.pp
  5. Run boxen again (should be automatically added to your global PATH by now).
  6. Commit and push your changes so you can apply the same to other machines, or share with colleagues.

I found lots of good modules by just scrolling through all the repos in the Boxen organization. You can lock versions for the modules, and do some special configuration in some cases, just look in each module repo's README if you need something special.

Note that you're bound to run into a bunch of hiccups along the way. Most of these have known solutions, so just search through the module's issues. In a few cases I ended up doing brew install <module> directly to get one working, which is OK since Boxen uses Homebrew as package provider.

Expect to fiddle with this a couple of hours the first time you add all your favorite modules. When downloading a lot of large packages, Boxen will break down with long stack traces because of network timeouts. Just keep restarting it and keep it up until it's done.

Here's my boxen repo. The interesting files there are Puppetfile and manifests/site.pp. You can also put some personal stuff (a Boxen repo is supposed to be used across a whole team) in a personal config, but I didn't really get into this yet.