2. * Vagrant is a tool for creating,
managing and distributing
portable development
environments.
3. * Wrapper around a variety of virtual machine
providers.
* Single command that uniformly creates,
provisions, destroys, and connects to machines
* Replicate and rebuild whole VM instantly
4.
5. * Open source tool.
* Works on Mac OS X, Windows
and Linux
19. Providers
A provider manages compute resources for virtual machines
Allows to use the right provider for the different environment
20. Providers
VAGRANTFILE_API_VERSION
=
"2"
Vagrant.configure(VAGRANTFILE_API_VERSION)
do
|config|
config.vm.box
=
"MantasK/centos-‐6.5-‐x86_64-‐puppet"
config.vm.host_name
=
'test77v1.dev1.adform.com'
config.vm.provider
"virtualbox"
do
|vm|
vm.customize
[
"modifyvm",
:id,
"-‐-‐memory",
"2048",
"-‐-‐cpus",
"2"
]
end
end
21. Providers
$
vagrant
box
list
$
vagrant
box
add
<name>
<url>
$
vagrant
up
-‐-‐provider=<name>
22. Synced Folders
Automaticaly syncs folders from host to guest
Types: VirtualBox, Rsync, SMB, NFS, Etc.,
Default: Vagrant will share your project
directory (the directory with the Vagrantfile)
to /vagrant
23. Synced Folders
VAGRANTFILE_API_VERSION
=
"2"
Vagrant.configure(VAGRANTFILE_API_VERSION)
do
|config|
config.vm.box
=
"MantasK/centos-‐6.5-‐x86_64-‐puppet"
config.vm.host_name
=
'test77v1.dev1.adform.com’
config.vm.synced_folder
"data",
"/tutorial"
config.vm.provider
"virtualbox"
do
|vm|
vm.customize
[
"modifyvm",
:id,
"-‐-‐memory",
"2048",
"-‐-‐cpus",
"2"
]
end
end
24. Networking
Forwarded Ports - basically NAT
Private Network - Host-only networking
Public Network - Bridged Networking
You can use mix and match – couple of those together or
couple of one
29. Multi machine
Manage multi-machine cluster with a single Vagrantfile
Vagrant.configure(VAGRANTFILE_API_VERSION)
do
|config|
config.vm.define
"node1"
do
|node1|
node1.vm.box
=
"MantasK/centos-‐6.5-‐x86_64-‐puppet"
node1.vm.host_name
=
'node1.test.com'
node1.vm.provider
"virtualbox"
do
|vb|
vb.customize
["modifyvm",
:id,
"-‐-‐memory",
"2048"]
end
node1.vm.network
"private_network",
ip:
"172.16.0.11"
end
config.vm.define
"node2"
do
|node2|
node2.vm.box
=
"MantasK/centos-‐6.5-‐x86_64-‐puppet"
node2.vm.host_name
=
'node2.test.com'
node2.vm.provider
"virtualbox"
do
|vb|
vb.gui
=
true
vb.customize
["modifyvm",
:id,
"-‐-‐memory",
"1048"]
end
node2.vm.network
"private_network",
ip:
"172.16.0.21"
end
end
30. Plugins
Extensions. Lots of them!
https://github.com/mitchellh/vagrant/wiki/Available-Vagrant-Plugins
$
vagrant
plugin
install
vagrant-‐aws
$ vagrant up --provider=aws
36. Docker vs VMs
Full Issolation
Resources guaranteed
Size: 1GB VM x # VMs
Performance: overhead
Minutes to start
Need conversion
Less Issolation
No guaranteed resources
Size: 1GB ( little over J)
Performance: no overhead
Seconds to start
Portable