I'm currently doing some development work with Red Hat OpenShift Origin, which is primarily (currently) developed for Fedora 19.  As part of my efforts to fix up the Puppet module used for deployment, I wanted the ability to quickly spin up new clean Fedora 19 virtual machines.

Enter Vagrant.  Vagrant is a tool for building complete development environments on your local computer using VirtualBox (other hypervisors are available).  At the time of writing, there wasn't a pre-canned Fedora 19 Vagrant box readily available, so I set out to make my own.

Enter Veewee!  Veewee is a tool for easily (and repeatedly) building custom Vagrant base boxes, KVMs, and virtual machine images.  Veewee is written in Ruby and uses Bundle to manage its Ruby Gem dependencies.  The problem with Ruby is that it reminds me of the good(?) old days of Perl and CPAN.  In other words, dependencies often fail for one reason or another, you install various different versions to suit particular applications and your environment can become rather filthy rather quickly.

Enter RVM!  RVM is a tool which allows you to easily install, manage, and work with multiple ruby environments from interpreters to sets of gems.

Welcome to Ruby, I recommend you don't wear your nice clothes - this could get messy!

1.  Install VirtualBox

VirtualBox is very easy to install, head on over to the download page and follow the instructions.

2.  Install Vagrant

Vagrant is also easy to install.  Again, head on over to their downloads page and you'll find .dmg package for OS X and just follow the instructions.  You might want to try the getting started guide to get a feel for what we're trying acheive.

3.  Install RVM

Installing RVM is reality straight forward.  The source is available on Github, so just follow these commands.

mkdir -p ~/.rvm/src
cd ~/.rvm/src
rm -rf ./rvm
git clone --depth 1 git://github.com/wayneeseguin/rvm.git
cd rvm

4.  Install Ruby 1.9.2

Now we want to install a nice fresh copy of Ruby 1.9.2 using RVM.  This will likely take quite a while, so why not go get yourself a beer.

rvm install 1.9.2
rvm use [email protected] --create
which ruby
ruby -v

5.  Install Veewee

mkdir -p ~/.veewee/src
cd ~/.veewee/src
git clone https://github.com/jedi4ever/veewee.git
cd veewee
gem install bundler
gem install ruby-ajp  # Bundler borked this, so we install manually
bundle install        # Ruby talk for install Veewee's dependencies
gem build veewee.spec
gem install veewee-0.3.8.dev.gem
veewee version

6.  Define a Fedora 19 template

Got this far?  Wow.  Okay, well, the bad news is that after all that, at the time of writing the standard Veewee Fedora 19 template is broken.  Sorry about that.  However, this is Open Source, so naturally some nice person has submitted a pull request on Github with the fix!

# Check the default template is present
veewee vbox templates | grep Fedora-19-x86_64

# Define our template based on the default
mkdir -p ~/veewee
cd ~/veewee
veewee vbox define 'fedora-19-x86_64' 'Fedora-19-x86_64' --workdir=~/veewee/definitions/fedora-19-x86_64

# At this point, you can edit the definition if you like.
# If the default template is still broken, here's where you would apply the
# changes provided in the Pull Request above.

# Build a VM from our new template
veewee vbox build 'fedora-19-x86_64'

# Perform some checks to ensure Vagrant will like it
veewee vbox validate 'fedora-19-x86_64'

# Export the VM to a disk image
veewee vbox export 'fedora-19-x86_64'

7.  Start Her Up Steve!

Now all we need to do is import our newly created image and bask in our glory...

# Import the disk image to Vagrant
vagrant box add 'fedora-19-x86_64' ~/veewee/fedora-19-x86_64.box

# Start a new Vagrant box
mkdir -p ~/vagrant
cd ~/vagrant
vagrant init fedora-19-x86_64

# Boot the box up
vagrant up

# Login
vagrant ssh