Veewee, for Creating VMs

Published 2013-06-12

If you want to play around with virtualization software like Vagrant, Virtualbox, or VMWare Fusion, you'll need to create a virtual machine image (henceforth referred to as a "VM"). The most common way to do this is to download an Ubuntu or CentOS ISO and install it through the virtualization GUI. However this is a time-consuming process, and if you discover that you made a mistake or you want to tweak the way you installed the operating system, you have to start the process over.

Veewee to the rescue! Veewee is a tool for automatically building VMs from ISOs, in a variety of formats. Veewee describes the exact process used to create the VM, so it's easy to share with other people (team members or contributors for example). Also, you can check the procedure into version control and easily reproduce the original VM later, so you don't need to keep different versions of a 700 megabyte VM sitting around on your hard drive.

Questions Before We Begin



In order to run Veewee, you'll need ruby and bundler installed on your system. If you don't have ruby these, refer to Installing Ruby the Correct Way and you'll be on your way in no time. The Veewee docs ask for ruby 1.9.2 but I had great success with ruby 1.9.3-p392. YMMV.

Also, you'll need some virtualization software. I tested things out with Virtual Box and VMWare Fusion. If you don't have one of these already you can download Virtual Box for free.

Installing Veewee

$ git clone
$ cd veewee
$ bundle install

At this point you should be able to run bundle exec veewee and see the following output:

  veewee fusion          # Subcommand for Vmware fusion
  veewee help [COMMAND]  # Describe available commands or one specific command
  veewee kvm             # Subcommand for KVM
  veewee parallels       # Subcommand for Parallels
  veewee vbox            # Subcommand for VirtualBox
  veewee version         # Prints the Veewee version information

Aliasing veewee

Since typing bundle exec veewee is a bit tedious, I'm going to create an alias for it via:

$ alias veewee="bundle exec veewee"

This enables us to simply type veewee as long as we're in the veewee folder. You can make this alias persistant by adding it to ~/.bash_profile or its equivalent on your system (~/.profile on Ubuntu or ~/.zshrc for z-shell).

Creating a VM

When you ran veewee earlier you should have seen a list of commands. Most of these (aside from the obvious help and version commands) actually correspond to the virtualization software you're using. You'll need to invoke one to see the other commands. For example:

$ veewee vbox
  veewee vbox build [BOX_NAME]                     # Build box
  veewee vbox define [BOX_NAME] [TEMPLATE]         # Define a new basebox starting from a template

Building a VM involves two steps. First, we need to create the definition (called a "box") used to describe the installation procedure. Then we need to build it. We do this using the define and build commands.

Defining a VM

Veewee includes a selection of templates to create your first box. I selected an Ubuntu template, but you can choose from anything in the templates/ directory.

$ veewee vbox define awesome-ubuntu-server ubuntu-12.04.2-server-amd64
                            ^                     ^
                            |                     |
                        Box name     Which template to use to create the box definition

Somewhere in the console spew you should have noticed that your definition has been created under definitions/. You can see it like so:

$ ls definitions

Veewee also mentions that you can customize the definition, so let's take a moment to tweak it. Since I'm using VirtualBox for this one, with Chef, I'm going to make changes to definitions/awesome-ubuntu-server/definition.rb:

:postinstall_files => [
  #"", # I commented these three lines

Feel free to make whatever changes are most relevant for you before continuing on to the next section. The line barfed on my first run-through, so comment that one out unless you're planning to use it.

Building the VM

Now that we have a definition for our box, the next step is to build it. Since this is our first box, veewee will download a handful of dependencies, including VirtualBox guest additions and the ISO for the operating system we selected.

Since I already had the Ubuntu server ISO downloaded, I moved it into iso/ and saved some time, but if you don't have your chosen OS ISO, veewee will download it for you when you run:

$ veewee vbox build awesome-ubuntu-server -n

From here, Veewee runs through the installation process (downloading files as necessary). You can watch Veewee's progress in the terminal, or (and this is the whole point, really) you can put it in the background and go do other things while Veewee takes care of everything for you.

Note: If you want to watch Veewee work, you can omit the -n flag from the build command. -n suppresses the GUI.

This is by far the easiest part of the entire process, but it takes some time. So go watch an episode of your favorite TV show or play a game or pretend to work for awhile, and come back later. On my computer this process took about 15 minutes.

If everything works, you'll eventually see:

The box awesome-ubuntu-server was built successfully!

If you go looking, you'll find the new VM conveniently located inside the ~/VirtualBox VMs/ folder on your computer.

Export the VM for Vagrant Use

Since I plan to use this box with Vagrant, the final step for me is to export it into the Vagrant box format.

$ veewee vbox export awesome-ubuntu-server

Veewee is nice enough to export the box into the location where Vagrant is going to look for it, and spews a message indicating this:

To import it into vagrant type:
vagrant box add 'awesome-ubuntu-server' '/Users/cbednarski/code/veewee/'

To use it:
vagrant init 'awesome-ubuntu-server'
vagrant up
vagrant ssh

That's it! If you want to get fancy, you can upload the image to a server and share it with your team, or show them how to run through the Veewee process themselves.


vagrant linux devops veewee