I already talked a bit of the handy Vagrant tool and about the DevOps philosophy. In the Vagrant post I showed how to use an available public Ubuntu box and how easy is to use the shell provisioner to setup a basic LAMP box.

Then I said that there are publicly available boxes out there but omitted the Vagrant Boxes site. Why the omission? Simply, I really don’t find them so useful and I think the drawbacks overweights the benefits. Grabbing a box that you don’t know how it was set up can lead to serious security problems. And if the box is just a basic installation, it is almost helpless since you’ll need to make the provisioning of your desired setup everytime you init a VM based in the box.

Why not just create a base box? Here comes Veewee.


Veewee is a tool to easily build Vagrant boxes or KVM, VirtualBox and Fusion images. Hands-on, let’s open a terminal. You’ll need to have the RubyGems installed on your machine to install Veewee. Read the Vagrant post to see how to install it. Let’s install the latest available alpha release (note: the following commands were tested on an ol’ but good MacOS X Leopard.)

$ sudo gem install veewee --pre

Veewee comes with a lot of OS templates that you can use to build your Vagrant base box or VM image (and that’s why we used the alpha release since it contains updated templates for the major OS versions.) You can list the available templates using the following command:

$ vagrant basebox templates | sort

There are templates for popular Linux distros (Debian, Ubuntu, CentOS, Scientific Linux), some Unix flavors (Solaris, FreeBSD) and even for the Windows 8 preview release. Let’s build a Debian box. First, let’s define our base box with the name ‘squeeze64-lamp’ using Debian 6.0.4 AMD64.

$ mkdir -p ~/Dev/veewee/squeeze/amd64
$ cd ~/Dev/veewee/squeeze/amd64
$ vagrant basebox define squeeze64-lamp Debian-6.0.4-amd64-netboot
[vagrant] The basebox 'squeeze64-lamp' has been succesfully created from the template 'Debian-6.0.4-amd64-netboot'
[vagrant] You can now edit the definition files stored in definitions/squeeze64-lamp or build the box with:
[vagrant] vagrant basebox build 'squeeze64-lamp'

Looking at the definitions/squeeze64-lamp directory, we can see a bunch of files that are used to install the enough software needed for a Vagrant base box:

$ ls definitions/squeeze64-lamp/
base.sh       cleanup-virtualbox.sh definition.rb      puppet.sh       vagrant.sh        zerodisk.sh
chef.sh       cleanup.sh            preseed.cfg        ruby.sh         virtualbox.sh

The main file here is the definition.rb. It have a hash with some of the VirtualBox VM definitions (like the number of CPUs, the memory and disk sizes), boot and Kickstart definitions that are used to automatize the OS installation and the post-install files. Let’s setup the same LAMP box from the Vagrant post. Download or clone the vagrant-shell-scripts Git repository and change the post install files in definitions.rb using the following snippet:

:postinstall_files => [

Hint: put your post-install files anywhere after the base.sh file and before the cleanup.sh file.

With everything in place, build your box! This can take some time since it will download the Virtual Box Guest Additions and the OS ISO image (but just for the first time.)

$ vagrant basebox build squeeze64-lamp

After creating the box, validate it:

$ vagrant basebox validate squeeze64-lamp

With the tests’ ok, export your box:

$ vagrant basebox export squeeze64-lamp

Now you have a custom Vagrant base box that you can distribute for your IT team. Just add it to Vagrant and start using it!

$ vagrant box add squeeze64-lamp squeeze64-lamp.box
$ vagrant init squeeze64-lamp
$ vagrant up
$ vagrant ssh