31
VAGRANT & CODE REUSABLE Gianluca Arbezzano www.gianarb.it - @gianarb Corley srl - www.corley.it Cloud Party 21/05/2014

Vagrant & Reusable Code

Embed Size (px)

DESCRIPTION

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

Citation preview

Page 1: Vagrant & Reusable Code

VAGRANT &CODE REUSABLE

Gianluca Arbezzano

www.gianarb.it - @gianarb

Corley srl - www.corley.it

Cloud Party 21/05/2014

Page 2: Vagrant & Reusable Code

Don’t sleep developer!

Page 3: Vagrant & Reusable Code

Decrease the complexity

•Start up project•Flexibility

Page 4: Vagrant & Reusable Code

What is Vagrant?•Provider•Provisioning•Networking•Share Folder

Page 5: Vagrant & Reusable Code

Why Vagrant?

Vagrant allow to:•Configure•Reproduce•Share

it’s very easy!

Page 6: Vagrant & Reusable Code

Command line•$. vagrant box•$. vagrant init•$. vagrant up•$. vagrant ssh•$. vagrant destroy•$. vagrant reload•$. vagrant provision

Page 7: Vagrant & Reusable Code

Plugin$. vagrant plugin install <name>

$. vagrant plugin remove <name>

$. vagrant plugin list

Page 8: Vagrant & Reusable Code

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"

Page 9: Vagrant & Reusable Code

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"

Page 10: Vagrant & Reusable Code

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

Page 11: Vagrant & Reusable Code

Vagrantfile - Configuration

web.vm.provider :virtualbox do |v|v.customize ["modifyvm", :id, "--memory", 512,

"--name", "cwitter-dev.local"]end

Page 12: Vagrant & Reusable Code

PROVISIONING

Page 14: Vagrant & Reusable Code

I use one of this systems in production

•Updating•Maintainability•Scalibility

Page 15: Vagrant & Reusable Code

RISKSBug in your configurations

Price of good cookbook (Chef), formula (salt)…

Page 16: Vagrant & Reusable Code

Answer to this problem is…

Page 17: Vagrant & Reusable Code

REUSABILITY

Page 18: Vagrant & Reusable Code

Environments•Production•Develop•Certification•…

Page 19: Vagrant & Reusable Code

Vagrant configuration is shareable

Page 20: Vagrant & Reusable Code

VAGRANT AND SALT

Page 21: Vagrant & Reusable Code

Repository

Page 22: Vagrant & Reusable Code

Repository/prod/salt

Page 23: Vagrant & Reusable Code

Repository/dev/salt

Page 24: Vagrant & Reusable Code

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

Page 25: Vagrant & Reusable Code

Minion – Conf(1)

master: localhostfile_client: local

Page 26: Vagrant & Reusable Code

Minion – Conf(2)

file_roots: base: - /srv/base/salt prod: - /srv/prod/salt dev: - /srv/prod/salt - /srv/dev/salt

Page 27: Vagrant & Reusable Code

Minion – Conf(3)

pillar_roots: base: - /srv/base/pillar prod: - /srv/prod/pillar dev: - /srv/dev/pillar

Page 28: Vagrant & Reusable Code

top.slsbase: '*': - basedev: '*-dev*': - webserver - webserver.dev - webapp - mysqlprod: 'proxy.milan.enter.*': - nginx

'web.milan.enter.*': - webserver - webapp

……

•Inheritance

•Customization of environmentes

Page 29: Vagrant & Reusable Code

Think your

system

Write it

Configure develop

env

Configure prod …

Page 30: Vagrant & Reusable Code

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

Page 31: Vagrant & Reusable Code

THANK YOUhttp://www.corley.it