Setup vagrant on ubuntu:
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.
More details can be found at vagrantup
1) Install dependency :
VirtualBox is a general-purpose full virtualizer for x86 hardware, targeted at server, desktop and embedded use. (VirtualBox)
Add one of the following lines according to your distribution to your /etc/apt/sources.list:
deb http://download.virtualbox.org/virtualbox/debian precise contrib
#wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add -
#sudo apt-get install virtualbox-4.3
2) Download and install vagrantup.
#sudo dpkg -i /home/hemant/Downloads/vagrant_1.6.5_x86_64.deb
3) Setup vagrant.
Create a root directory for your project and navigate in it:
Next, run the initialization command:
a) Pass box as parameter:
#vagrant init [box-name] [box-url]
If a first argument is given, it will prepopulate the config.vm.box setting in the created Vagrantfile. [ex. hashicorp/precise64]
If a second argument is given, it will prepopulate the config.vm.box_url setting in the created Vagrantfile. [ex. https://vagrantcloud.com/hashicorp/boxes/precise64]
b) Create a Vagrantfile and update default configuraion.
#config.vm.box = “precise64″
More Vagrantfile oprions,
#Install dependencies using provision,
config.vm.provision :shell, :path => "install.sh"
#Create a private network, which allows host-only access to the machine using a specific IP.
config.vm.network :private_network, ip: "192.168.1.1"
#Share an additional folder to the guest VM.
config.vm.synced_folder "/h_data", "/v_data", owner: "root", group: "root", :mount_options => ['dmode=777,fmode=777']
This will tell it to use this new box. More boxes can be discover here Vagrantcloud.
Save the file and exit. Now you can deploy the guest machine with the following command:
This will bring up a VPS running Ubuntu 12.04 LTS 64Bit. To make use of it, you can easily SSH into it:
Vagrant will share the project root folder from the host machine (the one containing the Vagrantfile) with a folder on the guest machine, /vagrant.
You can exit and go back to the host with the following command:
To stop and remove the guest machine and all traces of it,
Use reload command is usually required for changes made in the Vagrantfile to take effect. After making any modifications to the Vagrantfile
The configured provisioners will not run again, by default. You can force the provisioners to re-run by specifying the –provision flag.
To add more boxes for other projects use following command adds ‘hashicorp/precise64′ box to Vagrant.
#vagrant box add hashicorp/precise64