Friday, January 22, 2016

Vagrant for the beginners ... Tutorial.



Vagrant is a higher level wrapper around different virtualization and configuration management software.

Virtualization Software:
  1. VirtualBox, 
  2. VMware, 
  3. KVM and 
  4. Linux Containers (LXC)
Configuration Management Software:
  1. Ansible, 
  2. Chef, 
  3. Salt, and 
  4. Puppet.

Deploy your uniform environment on any virtual platform. For example, you may deploy with vagrant on Amazon Cloud or Virtual Box  with same environment without any hassle. As a best practice, push vagrant file in the version control repository so that others can benefit without any upfront work.

vagrant init

vagrant box add hashicorp/precise64
 
 

The box add command creates a box from the image "hashicorp/precise64". The box name consists of 2 parts;  is username and  is box name.


Vagrant.configure("2") do |config|
  config.vm.box = "hashicorp/precise64"
end 
 
 
vagrant up
 
 


We see there is an error in mounting and syncing the directories. The issue is fixed by upgrading to virtual box 5.0.14

We will not be able to see anything since Vagrant runs VM without any user-interface. To check if its running, we can SSH it.

vagrant ssh




SSH failed since SSH client is not installed. We will use Putty to SSH the virtual machine. Import the private key to puttygen and save .ppk file.

Now we can connect to box using putty.

vagrant reload --provision

I hope it helped. Feel free to comment...