Not too long ago I started setting up some EC2 AMIs and startup scripts for our engineers to use for development and with the addition of Buildout by one of those engineers it became what we referred to as dev-on-demand or “dod”. For various reasons we have now since retired the dev-on-demand and just have a number of servers that the engineers can use.
Ideally you should be limited only by the performance of your machine or other resources to quickly fire up one or more virtual servers to work, test or learn with.
Vagrant is a tool for doing just that – to build and deploy virtualized dev environments. By using Oracle’s VirtualBox along with Chef from Opscode, Vagrant is able to build out something from a simple dev setup to a complex dev environment that you can save, reproduce and then tear it all down when you are done. The reproducible part is something that I would point out if you are part of a team, because you can save standard setups that your team can use as a starting point or share entirely new configuration ideas with them.
And if you find yourself teaching a class or just needing to learn something new on your own Vagrant should be a good pick to use as your classroom.
Two little gotchas that I encountered after installing it on Mac OS 10.6:
$ sudo gem install vagrant $ vagrant box add base http://files.vagrantup.com/base.box
When trying to add a new box after installing the Ruby gem I got the following error:
/usr/local/lib/ruby/gems/1.8/gems/nokogiri-1.4.1/ lib/nokogiri/nokogiri.bundle: dlopen(/usr/local/lib/ruby/gems/1.8/gems/ nokogiri-1.4.1/lib/nokogiri/nokogiri.bundle, 9): no suitable image found. Did find: (LoadError)
I had to reinstall Ruby, because of some issue when I upgraded to Snow Leopard. After the reinstall I was able to get past this step and onto setting up Vagrant and starting the server.
$ vagrant init $ vagrant up
Until I had this second error:
/usr/local/lib/ruby/gems/1.8/gems/ virtualbox-0.5.4/lib/virtualbox/global.rb:122:in `config': The path to the global VirtualBox config must be set. See Global.vboxconfig= (VirtualBox::Exceptions::ConfigurationException)
I had just installed VirtualBox (we use VMware Fusion at work) and I hadn’t used it yet and just needed to run VirtualBox at least once to get vagrant up to work. After that the new box was downloaded, added and started right up.
If you’re reading this and thinking thats nice, but we use X instead of Ruby, unless you are on a OS that Vagrant doesn’t support it really shouldn’t be an issue. At work we are a Python / Django shop and I was able to add a recipe for mod_wsgi and get a simple Django app up and running with no issues. And I’m sure if I had time a recipe could be expanded to fit our needs to use buildout getting our app onto one or more boxes.
Read more about Vagrant here and if you are managing any number of Unix/Linux servers and haven’t yet heard of Puppet of Chef I’d encourage you to spend some time with at least one of them. For those on a Mac who might have always wondered why there isn’t a default package management system on Mac OS X and have been looking for one check out Homebrew.