Installing Vagrant on Ubuntu

A head­less vir­tu­al devel­op­ment envi­ron­ment that can eas­i­ly be shared.

Today I first encoun­tered Vagrant through a yeo­man gen­er­a­tor of all things. I have but touched on it, but what I’ve seen as of yet I like.

Installation

Before I look clos­er at what can be done with it, there’s the quick “gotcha” that, if you are not care­ful, will, erh… Get you.
First, down­load the lat­est ver­sion from their down­loads page. After that, resist try­ing to install it using Ubun­tu Soft­ware Cen­ter, there is a known issue with how sev­er­al things inter­act, with the sum­ma­ry being that installing Vagrant from Ubun­tu Soft­ware Cen­ter will unin­stall virtualbox-4.2 if you have it installed.

How do we solve that?

Easy, actu­al­ly. Rather than using apt-get to install the pack­age and all its’ depen­den­cies, use dpkg -i <vagrant-file> instead to install only the pack­age, to hell with any of its’ depen­den­cies.

Installing VirtualBox

If you didn’t have Vir­tu­al­Box, the best plan is to go to Oracle’s Down­load page and down­load the lat­est ver­sion of Vir­tu­al­Box. After that, you can either dou­ble-click on it to open up Ubun­tu Soft­ware Cen­ter, or run dpkg -i <name-of-package.

Usage

Vagrant’s doc­u­men­ta­tion is quite well writ­ten, with the Quick­start par­tic­u­lar­ly use­ful, but here’s some high­lights:
* vagrant init — Cre­ates a Vagrantfile in the direc­to­ry with basic set­tings. If called with a name and an url to a box, it will install that box, ex: vagrant init precise32 http://files.vagrantup.com/precise32.box, which cre­ates a box called precise32.
* vagrant up — Starts the machine based on the con­fig­u­ra­tions in the Vagrantfile
* vagrant ssh — Logs into the vir­tu­al machine using SSH
* vagrant destroy — Tears down the machine and any changes done to it

Future instal­la­tions in this serie will cov­er the con­fig­u­ra­tion I use, but that requires I start by get­ting the con­fig­u­ra­tion to work!


For the moment comments are not enabled, but feel free to reach out on Twitter.