VAGRANT &
CODE REUSABLE
Gianluca Arbezzano
www.gianarb.it - @gianarb
Corley srl - www.corley.it
Cloud Party 21/05/2014
Don’t sleep developer!
Decrease the complexity
•Start up project
•Flexibility
What isVagrant?
•Provider
•Provisioning
•Networking
•Share Folder
WhyVagrant?
Vagrant allow to:
•Configure
•Reproduce
•Share
it’s very easy!
Command line
•$. vagrant box
•$. vagrant init
•$. vagrant up
•$. vagrant ssh
•$. vagrant destroy
•$. vagrant reload
•$. vagrant provision
Plugin
$. vagrant plugin install <name>
$. vagrant plugin remove <name>
$. vagrant plugin list
Vagrantfile - Configuration
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(“2”) do |config|
config.vm.define :web do |web|
web.vm.box = "precise64"
web.vm.box_url = "http://files.vagrantup.com/precise64.box"
Vagrantfile - Configuration
web.vm.network :private_network, ip: “192.168.33.222”
web.vm.network “port_forwarding”, guest: 80, host: 8080
config.vm.hostname = "cwitter-dev.local”
web.vm.synced_folder "../", "/var/www/cwitter", owner: "www-
data", group: "www-data"
Vagrantfile - Configuration
config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = ["cookbooks"]
chef.add_recipe "apt"
chef.add_recipe "vim"
chef.add_recipe "openssl"
chef.add_recipe "apache2"
chef.add_recipe "postgresql::server”
end
Vagrantfile - Configuration
web.vm.provider :virtualbox do |v|
v.customize ["modifyvm", :id, "--memory", 512, "--name",
"cwitter-dev.local"]
end
PROVISIONING
How is it?
Server provisioning is a set of
actions to prepare a server with
appropriate systems, data and
software, and make it ready for
network operation
http://en.wikipedia.org/wiki/Provisio
ning#Server_provisioning
I use one of this systems in production
•Updating
•Maintainability
•Scalibility
RISKS
Bug in your configurations
Price of good cookbook (Chef), formula (salt)…
Answer to this problem is…
REUSABILITY
Environments
•Production
•Develop
•Certification
•…
Vagrant configuration is shareable
VAGRANT AND SALT
Repository
Repository/prod/salt
Repository/dev/salt
Salt Provioning
Vagrant.configure("2") do |config|
config.vm.box = "precise64”
config.vm.hostname = “cwitter-dev.local”
web.vm.network “port_forwarding”, guest: 80, host: 8080
web.vm.synced_folder “.”, “/srv/”
web.vm.synced_folder “../”, “/var/www/cwitter”
config.vm.provision :salt do |salt|
salt.verbose = true
salt.minion_config = “./minion"
salt.run_highstate = true
salt.install_type = “daily”
end
end
Minion – Conf(1)
master: localhost
file_client: local
Minion – Conf(2)
file_roots:
base:
- /srv/base/salt
prod:
- /srv/prod/salt
dev:
- /srv/prod/salt
- /srv/dev/salt
Minion – Conf(3)
pillar_roots:
base:
- /srv/base/pillar
prod:
- /srv/prod/pillar
dev:
- /srv/dev/pillar
top.sls
base:
'*':
- base
dev:
'*-dev*':
- webserver
- webserver.dev
- webapp
- mysql
prod:
'proxy.milan.enter.*':
- nginx
'web.milan.enter.*':
- webserver
- webapp
……
• Inheritance
• Customization of environmentes
Think your
system
Write it
Configure
develop env
Configure
prod
…
Links
•www.vagrantup.com
•www.vagrantbox.es
•irc.freenode.net #vagrant
•https://github.com/dotless-de/vagrant-vbguest
•https://github.com/schisamo/vagrant-omnibus
•https://vagrantcloud.com
THANKYOU
http://www.corley.it

Vagrant & Reusable Code