Getting started with vagrant on Mac OS X

Vagrant wants an up-to-date RubyGems. From experience changing the ruby install bundled with Mac OS X can be a bad idea. I considered using rvm but I don’t think I need all that power here. So I’ll be my usual old-fashioned self, and install my own ruby in /usr/local.

  • Download latest ruby source code (1.9.2-p180 at time of writing), ./configure && make && make install (this results in a 64-bit only build)
  • create a new terminal, check gem environment gives the new ruby, run gem update --system && gem update
  • if you now get a lot of deprecation warnings, follow this advice to get rid of them: gem pristine --all --no-extensions (there are no native extension installed yet so no need to worry about those)
  • if you get any instructions about running rdoc-data, ignore the instructions, according to this bug report it’s not needed for ruby 1.9.2.

So now we have up-to-date ruby and up-to-date RubyGems. Good. Let’s get virtualbox and vagrant:

Get started:

vagrant box add lucid32
mkdir test1
cd test1
vagrant init
vi Vagrantfile
# change to "lucid32"
# set config.ssh.max_tries to something high, say 50000
# set config.ssh.timeout to something high, say 3000000
vagrant up
vagrant ssh
echo test

Works for me.

My preferred hypervisor on the mac is VMWare Fusion though. I already have a bunch of custom scripts set up to create and manage VMs and puppet them up. I could migrate those over to VirtualBox I guess and then change all my scripts to use vagrant, but I don’t really see that it offers me any benefit right now. Definitely a useful tool though and it’ll be interesting to follow its development.