Setting up Riak with Vagrant and Puppet

Setting up Riak is pretty easy and straight forward,
but depending on my needs there is the need to change configuration
depending on the current use case. This means that having one instance of it on
my development machine just doesn’t cut it. Luckily there is
Vagrant which provides a quick way to setup VMs as
needed for a given project, along with Puppet this allows me to bundle all the
configuration for a given project.

Basho provides a nice module to setup Riak with puppet, but is pretty complex
to handle all the different use cases. Since I just need it for development I
decided to make it easier for me and other devs by providing an easy to setup and
a quickly understandable module for my needs. It just installs the most recent
version of Riak from the debian-pkg provided for Ubuntu 12.04 LTS 64Bits. So here we go

Vagrant configuration is short and simple, puppet folder setup as well.

while for riak_precise64 I just add a submodule via git

$ git submodule add

and here we go a simple

$ vagrant up

will give us a nice VM with riak ready to use, and any config nicely contained in app.config.

Vagrant by example: Setting up Phantomjs

Vagrant is an amazing tool, especially switching between projects it comes in
handy to keep the dependencies separated. This works even better with puppet to
provision the machines in a reproducible fashion.

Installing vagrant

First things first, we need to install vagrant,
which has changed some time ago from being a gem to provide
installer packages. Installation now is really
simple, just download and install.

Setting up vagrant

To get of the ground lets setup an example box.

$ mkdir myproject && cd myproject
$ vagrant init precise32

This will download, and setup a basic box with ubuntu precise32.

Configure puppet

Inside the Vagrantfile we now configure vagrant to use
puppet, to provision the box for us. This will make
it easy to spin up a similar box whenever we need a new one.

Personally I prefer to modify the default vagrant behavior a bit and keep
everything puppet under puppet/* inside the project.

Setting up phantomjs

Now to the meat of this example, setting up phantomjs from the tarball download


Luckily the good guys from example42 provide a nice
puppet module to handle just these installs, it comes packaged with
puppi. Right now puppi seems a little much
such we just extract the netinstall code inside a module of its own and set it
inside the repo
Netinstall is a quite simple module, the only dependency we need to worry about
is the uri_parser which is implemented as a ruby extension and located in lib.
I also decided to rename netinstall.pp to init.pp since it is autoloaded
this way, and removed the puppi prefix.

Setting up the init.pp

Under manifests we can now create the custom init.pp in which we install
phantomjs and libfontconfig1 on which it depends.

Vagrant up

Now a simple

$ vagrant up

Will provision the machine with phantomjs installed, which we can test via after
provisioning is done.

$ vagrant ssh
$ phantomjs

Missed something?

Installing new packages is now easy as adding them to the init.pp file and

$ vagrant provision

Bundle all the dependencies!