Vagrant & Reusable Code

Preview:

DESCRIPTION

Gianluca Arbezzano discuss about Vagrant and Saltstack in order to speedup your development operations

Citation preview

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 is Vagrant?•Provider•Provisioning•Networking•Share Folder

Why Vagrant?

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

I use one of this systems in production

•Updating•Maintainability•Scalibility

RISKSBug 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 ProvioningVagrant.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: localhostfile_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.slsbase: '*': - basedev: '*-dev*': - webserver - webserver.dev - webapp - mysqlprod: '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

THANK YOUhttp://www.corley.it