Vagrant

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.

Vagrant stands on the shoulders of giants. Machines are provisioned on top of VirtualBox, VMware, AWS, etc.

I am using virtualbox as an example, you can fire up a ubuntu box with a few lines of code.


# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|

config.vm.box = "ubuntu/trusty64"

config.vm.synced_folder "./data", "/home/vagrant/data"
config.vm.provision "shell", path: "./scripts/vagrant/install-glance.sh"

config.vm.network "forwarded_port", guest: 8983, host: 8984, auto_correct: true

config.vm.network "private_network", ip: "192.168.33.10"

config.vm.provider "virtualbox" do |vb|

# Customize the amount of memory on the VM:
vb.memory = "8024"
end

end

You can forward the port from virtual box to your host, if the port is used with other programs, it can auto fix the port and assign a new one.


config.vm.network "forwarded_port", guest: 8983, host: 8984, auto_correct: true

You can set up a virtual ip for the box.


config.vm.network "private_network", ip: "192.168.33.10"

Setup a sync folder that can be access both in ssh and your host machine.


config.vm.synced_folder "./data", "/home/vagrant/data"

After you have created the VagrantFile, you can call

Vagrant Up

to fire up the box.

Once configuration VagrantFile has been changed, need to call

Vagrant Reload

to refresh the virtual box.

To destroy a virtual box, call

Vagrant Destroy

To access public built vagrant boxes,

https://atlas.hashicorp.com/boxes/search

http://www.vagrantbox.es/