nohobo

Vagrant in 1 Minute

Here’s a fast one for you. Vagrant is a clever app that allows you to build out development instances in 5 minutes from the command line. No ISO installation, no remoting into the hypervisor, no configuring the wrong network adapter 4 times, none of that madness.

Everything you need to know in 1 minute:

GO!

Install VirtualBox from here!

Install Vagrant from here!

Bring up a command prompt, cd to your desktop, mkdir a directory called ‘vagrant’, and cd into it.

Quick info, in Vagrant a ‘box’ is basically a prebuilt OS. You can find prebuilt boxes here and here. We’re just going to use a test Ubuntu image. Run these commands:

prompt> vagrant box add hashicorp/precise32 <- This will download our box.
prompt> vagrant init hashicorp/precise32 <- This creates a 'Vagrantfile' in our 'vagrant' directory and tells it to use our box.
prompt> vagrant up <- This starts our instance in VirtualBox (you can use other providers like VMWare or EC2 with the --provider option, VB is just the default). You'll see a lot of text.
prompt> vagrant ssh <- This connects to our Ubuntu instance!
ubuntu> ls /vagrant <- By default the 'vagrant' folder is shared under /vagrant. You could put puppet manifests or source packages in here!
ubuntu> exit <- Back to our regular prompt.
prompt> vagrant halt <- This stops our Ubuntu instance. You can rerun 'vagrant up' to start it back up or you can run 'vagrant destroy' to delete it.

Boom! Done.

Literally that simple. Provisioning to VMWare or OpenStack, building boxes, doing post-install tie ints to your infrastructure, and setting up more complicated networking are great next steps. One really useful line to add into your Vagrantfile is this one...

config.vm.provision :shell, :path => "bootstrap.sh"

...which will cause your VM to run the contents of 'bootstrap.sh' from your 'vagrant' directory on creation. Put it underneath the other 'config.vm' option. Here you could install puppet and then have it run some manifests out of your parent directory, run software updates, install development tools, anything you can think of.

In short, Vagrant is awesome. I'm definitely going to tie this into OpenStack at some point to do automatic provisioning. Once I get that worked out I'll make sure to add some more posts on how to do it here. For further reading you can find some excellent documentation here. Trips out!