- Southampton, England
Building a Vagrant Box with VeeWee
This is a quick follow up to my previous post where I described how I got started using Vagrant and Chef. This time around I want to detail the process of creating a base box from scratch. Why build a box from scratch? Security for one, but mainly just for the hell of it. I'm using another handy RubyGem, this one's called VeeWee. It handles the tedious steps like downloading ISOs and configuring the box. Give it some shell scripts and it runs them post installation, helpful for getting libraries installed.
First up then, install the VeeWee gem.
As well as providing its own binary, VeeWee extends Vagrant by adding the 'basebox' subcommand to it. Run
vagrant basebox to see a list of options.
Create a Box Definition
A good starting point is using a template on which to base the box definition.
This prints out the templates available on GitHub. I'm using the
CentOS-6.3-x86_64-minimal template in this example.
This generates a
definitions folder with the VeeWee config and some post installation shell scripts. I've created a repos on GitHub with my own modifications and additions to the template. I'm installing rbenv and some additional plugins. I then use rbenv to build and install the latest version of Ruby.
Build & Export
Next up, the box is built. This might take a while...
Following the build, the box is exported to the Vagrant .box format.
Add to Vagrant
Now it's possible to add the newly created box to Vagrant (I covered these steps in my previous post).
We're just left to initialise the box, add recipes and boot it. Job done.