Automating virtualization with veewee and vagrant

In order to consolidate my development environment a friend (thank you @bascht) mentioned veewee to me. Veewee automates and simplifys vagrant basebox creation. It comes with a plethora of templates for operating systems and versions. I use it to quickly build Ubuntu server on VirtualBox.

I started with a standard template (vagrant basebox define ‘appbox’ ‘ubuntu-12.10-server-amd64’) and customized the Including replacing the ruby install with rvm. This leads to problems when using chef which I don’t necessarily use so I can live with the inconvenience rather than with having to ruby setups.

I keep my own definitions for veewee in a separate directory to be able to version control it. Basebox creation itself is done by a little script. This setup requires git, and VirtualBox to be installed. I clone veewee parallel to the directory holding my definitions.

cd ..

echo “nnBuilding dbesbox and exportingnn”
if [ ! -d $BASE/veewee/definitions ]; then
mkdir $BASE/veewee/definitions/
cp -r $BASE/my-devenv/appbox/ $BASE/veewee/definitions/appbox/
cp -r $BASE/my-devenv/databasebox/ $BASE/veewee/definitions/databasebox/
cd $BASE/veewee/
veewee vbox build ‘appbox’ —force
veewee vbox export ‘appbox’ —force
echo “nnDone building and exporting appboxnn”
mv $BASE/veewee/ $BASE/my-devenv/

veewee vbox build ‘databasebox’ —force
veewee vbox export ‘databasebox’ —force
echo “nnDone building and exporting databaseboxnn”
mv $BASE/veewee/ $BASE/my-devenv/

cd $BASE/my-devenv/
veewee alias delete vagrant #Eradicate the “Gemfile could not be found” error
source ~/.zshrc

After building the two boxes I add them with

vagrant box add 'appbox' ''

and databasebox accordingly.

My Vagrantfile looks like this: do |config|

config.vm.define :app do |app_config| = "appbox" :hostonly, "" # is the host
app_config.vm.provision :shell, :path => "provisions/"
app_config.vm.provision :shell, :path => "provisions/"

config.vm.define :db do |db_config| = “databasebox” :hostonly, “”
db_config.vm.provision :shell, :path => “provisions/”
db_config.vm.provision :shell, :path => “provisions/”


My provisioner is shell, but a »gem install chef« would enable you to use chef subsequently to provision. (Since rvm installation requires a closing and restarting of the shell or login/logout I found this to be more reliable.)

Now a simple ‘vagrant up’ starts both boxes and pointing the browser at is answered by the nginx in appbox. My application is configured to use the db server at