I spent my Sunday afternoon familiarizing myself with a tool who's Getting Started page has been sitting in my Evernote tickle file for a couple weeks. This is one of those many projects that fall under the ever widening category of "Stuff I Wanted To Do, But Am Glad Someone Else Did It So I Can Just Use It And Get On To The Next Thing." If you use virtual machines as part of your development process, or want to, and especially if you already use the excellent VirtualBoxVirtualBox, then Vagrant is certainly worth looking at.
The Setup (for Vagrant 0.2)
sudo apt-get install rubygems libxslt-dev openssl-ruby
sudo gem install vagrantsudo bash -c 'echo "deb http://download.virtualbox.org/virtualbox/debian karmic non-free" >> /etc/apt/sources.list'
Each Vagrant box you build should have its own directory for configuration and should be run from their, so you can create a test project now.
mkdir test-vagrant && cd test-vagrant
vagrant-box add karmic http://files.vagrantup.com/contrib/karmic.boxvagrant initvagrant up
The Point, What Is?Why do this? What is the value in being able to quickly build, run, and clone virtual machines? Here are a few ways I'm already using them and will use them (more) with a tool like Vagrant to make it nicer.
- Keeping a definitive base of my development environment. I always have an image of a machine that I consider my minimum requirements for whatever project I might be working on. This is an Ubuntu image with all the tools I use, my vimrc and my virtualenv/pip shortcuts, etc. When I start a new project, I clone this image and add to it.
- Making my specific environments reproducible. This one I have tried and can now start doing seriously with Vagrant. For any project, I can maintain a script to build a development environment on top of my base. The benefits are two part. First, I can keep a clean record of what is required to work with a project. Second, when a change is made to my base, I can rebuild my development environment for all of my projects instantly. (Well, I can issue the command instantly, but I'll probably each lunch before its done!)
- VirtualBox images can be portable. It might even be possible to move suspended images, but I'm not completely sure about this, yet. If it turns out to be something I can do, I'll be able to suspend a project on my desktop, running the box off a USB key, and then resume it on my laptop in the park. Even if I can't do this, I can still build identical environments on multiple machines, for myself or for other developers.
- Replicating production and building local staging setups, machine the setups I have at Linode and EC2, will become something I can do with a minimal effort. I'm going to save a lot of time deploying to clones of my production machines running right here under my desk.