2. .
wwhhooaammii
JJuulliieenn PPiivvoottttoo
• System administrator at inuits.eu
• CentOS user since CentOS 5.5
• DevOps believer
• Open-source defender since 2004
• roidelapluie on twitter/github
3. .
• Tool to build development environments
• Easy to use, easy to configure
• Extensible via plugins
• Supports config management utilities
▶ Chef
▶ Puppet
▶ Cfengine
▶ Docker
▶ …
4. .
AA bbiitt ooff ccoonntteexxtt
• Born in 2010 as a ruby gem
• Written by Mitchell Hashimoto (@mitchellh)
• Used to be a wrapper around VirtualBox
6. .
WWoorrkkiinngg wwiitthhoouutt VVaaggrraanntt
• Hard to rebuild, reproduce
• No isolation
• Not the same OS as in production
• What if multiple versions of mysqld/java/…?
8. .
FFiixxeedd pprroobblleemmss
• Easy to rebuild, reproduce
• No more "Works on my machine"
• Use the same OS as the production OS
• Use multiple VM's if needed
• Desktop OS is not full of useless config
9. .
DDeevveellooppmmeenntt eennvviirroonnmmeenntt
• One or multiple virtual machine, container, …
• Provisionned (puppet, chef, ansible, script…)
• Any operating system
• A lot of providers supported
▶ Virtualbox
▶ Docker
▶ AWS (plugin)
▶ KVM/Qemu (plugin)
▶ LXC (plugin)
▶ Also closed source VMWare, Hyper-V
10. .
AA VVaaggrraanntt bbaassee bbooxx
• A VM or an image or a Dockerfile
• SSH access if virtual machine
• SSH user for Vagrant
• Optional provisioning systems
17. .
vvaaggrraanntt bbooxx aadddd <<bbooxx uurrll>>
• Fetches a base box
• Takes an URL, a json file or a tarball as
parameter
• Adds it to the available base boxes
• Now we can use the box at will!
20. .
vvaaggrraanntt iinniitt <<bbooxx nnaammee>>
CCrreeaatteess aa ssiimmppllee VVaaggrraannttffiillee
• The Vagrantfile is the configuration file
• It contains the definition of the environment
• It is written in ruby
21. .
SSiimmppllee VVaaggrraannttffiillee
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure( VAGRANTFILE_API_VERSION ) do |config|
config.vm.box = "vStone/centos7.xpuppet .3.x
end
26. .
vvaaggrraanntt uupp
• Creates a VM in Virtualbox
• Prepares it: setting name, network, port
forwarding
• Once booted: sets the hostname
• On the first run, provisions the VM if needed
56. .
MMuullttiippllee VVMM''ss
• Multiple VM's defined in one file
• Vagrant commands can take the name of
the vm as argument
• Remember: a vagrant file is a ruby file (think
loops, hashes, …)
57. .
NNeettwwoorrkkiinngg
• Multiple networking possibilites
• Port forwarding
• Internal network
• Public network (bridge)
• Depending on provider
58. .
NNeettwwoorrkkiinngg aanndd CCeennttOOSS 77
• Not yet supported OOTB
• But plugins are there!
• vagrant plugin install vagrant-centos7_fix
59. .
VVaaggrraanntt ccoommmmaannddss
• vagrant box add box url: fetches a box
• vagrant init box name: creates Vagrantfile
• vagrant up: starts/creates the vm
• vagrant provision: run cfgmgmt, scripts
• vagrant destroy: deletes the vm
• vagrant halt: stops the vm
• vagrant ssh: ssh the virtual machine
• vagrant reload: vagrant halt vagrant up
• vagrant status: gets the status of the vm
60. .
FFiillee sshhaarriinngg
• Vagrant allows you to share files between
host and guest
• Protocol depends on privider: NFS, rsync,
vbox-addons,…
• By default, the Vagrantfile directory is
mounted on /vagrant
62. .
CCoonncclluussiioonn
VVaaggrraanntt
• Vagrant is a tool for everyone
• Have a clean environment in minutes
• Safely experience change
• Test on multiple platforms
63. .
CCoonncclluussiioonn
VVaaggrraanntt ppllaayyss nniicceellyy wwiitthh::
• Jenkins (plugins available)
• Puppet (project beaker)
• Any OS
• A lot of cloud providers