Thursday, 27 February 2014

Vagrant - simple environment provisioning

Vagrant is a tool that I'm using more and more these days.
Vagrant provides easy to configure, reproducible, and portable work environments built on top of industry-standard technology and controlled by a single consistent workflow to help maximize the productivity and flexibility of you and your team. 
To achieve its magic, Vagrant stands on the shoulders of giants. Machines are provisioned on top of VirtualBox, VMware, AWS, or any other provider. Then, industry-standard provisioning tools such as shell scripts, Chef, or Puppet, can be used to automatically install and configure software on the machine.
I use it with VirtualBox to quickly install and launch different virtual machines for both development and testing tasks. Some of the teams that I work with have used vagrant within their build process to facilitate test automation or to provide environment consistency in a delivery pipeline.

Its very easy to set up, and is similar for most operating systems
  1. Install VirtualBox
  2. Install Vagrant 
  3. Navigate to where you want to install a vm
  4. Goto a site like http://www.vagrantbox.es/ and choose a prebuilt box 
  5. Then do:
     $ vagrant box add {title} {url}
     $ vagrant init {title}
     $ vagrant up
This will create, initialise and launch the box of your choice in VirtualBox. At point 4, you can just as easily point to your own custom built boxes.

Once you have the box built you can use the following commands to bring up, shut down, or rebuild the box
# to start the box
 $ vagrant up
# to stop the box
 $ vagrant halt
# to rebuild the box
 $ vagrant destroy --force && vagrant up
You can then bring tools like puppet into the equation to manage installations and configurations on the box.

No comments: