Download - Vagrant and Configuration Management

Transcript
Page 1: Vagrant and Configuration Management

http://www.flickr.com/photos/mundoo/313716925gareth rushgrove | morethanseven.net

Vagrantand Configuration Management

The Guardian 1st April 2011

Page 2: Vagrant and Configuration Management

Gareth Rushgrove

gareth rushgrove | morethanseven.net

morethanseven.net

Page 3: Vagrant and Configuration Management

Work at FreeAgent

gareth rushgrove | morethanseven.net

freeagentcentral.com

Page 4: Vagrant and Configuration Management

Blog at morethanseven.net

gareth rushgrove | morethanseven.net

Page 5: Vagrant and Configuration Management

Currate devopsweekly.com

gareth rushgrove | morethanseven.net

Page 6: Vagrant and Configuration Management

http://www.flickr.com/photos/arttravel_nz/4178520218gareth rushgrove | morethanseven.net

Problems

- Not all developers want to be sysadmins- New employees or contractors starting

- Works on my machine syndrome- Advantage to running a full stack locally- local service based architectures

Page 7: Vagrant and Configuration Management

gareth rushgrove | morethanseven.net http://www.flickr.com/photos/exalthim/3597210568

Solutions

- Virtualisation

- Configuration management- Vagrant

Page 8: Vagrant and Configuration Management

Virtualisation needs powerful hardware

gareth rushgrove | morethanseven.net http://www.flickr.com/photos/martinoc/477335951

Page 9: Vagrant and Configuration Management

VirtualBox

gareth rushgrove | morethanseven.net

Page 10: Vagrant and Configuration Management

VMware

gareth rushgrove | morethanseven.net

Page 11: Vagrant and Configuration Management

Vagrant

gareth rushgrove | morethanseven.net

vagrantup.com

Page 12: Vagrant and Configuration Management

What is Vagrant?

gareth rushgrove | morethanseven.net

- Automated virtual machine creation using Oracle’s VirtualBox

- Automated provisioning of virtual environments using Chef or Puppet

- Full SSH access to created environments

- Assign a static IP to your VM, accessible from your machine

- Forward ports to the host machine

- Shared folders allows you to continue using your own editor

- Package environments into distributable boxes

- Completely tear down environment when you’re done

- Easily rebuild a complete environment with a single command

Page 13: Vagrant and Configuration Management

$ gem install vagrant$ vagrant box add lucid32 http://.../lucid32.box$ vagrant init$ vagrant up

Vagrant up

gareth rushgrove | morethanseven.net

Page 14: Vagrant and Configuration Management

Vagrant::Config.run do |config| config.vm.box = "lucid32"end

Vagrantfile

gareth rushgrove | morethanseven.net

Page 15: Vagrant and Configuration Management

Vagrant::Config.run do |config| config.vm.forward_port("web", 80, 8080) config.vm.forward_port("ftp", 21, 4567) config.vm.forward_port("ssh", 22, 2222, :auto => true)end

Port forwarding

gareth rushgrove | morethanseven.net

Page 16: Vagrant and Configuration Management

Vagrant::Config.run do |config| config.vm.share_folder("folder", "/guest", "../host")end

Shared folders

gareth rushgrove | morethanseven.net

Page 17: Vagrant and Configuration Management

Vagrant::Config.run do |config| config.vm.define :web do |web_config| web_config.vm.box = "web" web_config.vm.forward_port("http", 80, 8080) end

config.vm.define :db do |db_config| db_config.vm.box = "db" db_config.vm.forward_port("db", 3306, 3306) endend

Multiple VMs

gareth rushgrove | morethanseven.net

Page 18: Vagrant and Configuration Management

gareth rushgrove | morethanseven.net

Base boxes

Page 19: Vagrant and Configuration Management

VeeWee

gareth rushgrove | morethanseven.net

Page 20: Vagrant and Configuration Management

Chef

gareth rushgrove | morethanseven.net

Page 21: Vagrant and Configuration Management

Vagrant provisioning with Chef

gareth rushgrove | morethanseven.net

Vagrant::Config.run do |config| config.vm.provision :chef_solo do |chef| chef.roles_path = "roles" chef.add_role("vm") endend

Page 22: Vagrant and Configuration Management

Vagrant provisioning with Chef Server

gareth rushgrove | morethanseven.net

Vagrant::Config.run do |config| config.vm.provision :chef_server do |chef| chef.chef_server_url = "http://chefserver" chef.add_role("vm") endend

Page 23: Vagrant and Configuration Management

Vagrant::Config.run do |config| config.vm.provision :chef_solo do |chef| chef.recipe_url = "http://github.com/cookbooks.tar.gz" chef.add_recipe "garethr" chef.cookbooks_path = [:vm, "cookbooks"] chef.json.merge!({ :garethr => { :ohmyzsh => "https://github.com/.../oh-my-zsh.git", :dotvim => "https://github.com/garethr/dotvim.git" }}) endend

gareth rushgrove | morethanseven.net

Remote Tar File

Page 24: Vagrant and Configuration Management

Puppet

gareth rushgrove | morethanseven.net

Page 25: Vagrant and Configuration Management

Vagrant provisioning with Puppet

gareth rushgrove | morethanseven.net

Vagrant::Config.run do |config| config.vm.provision :puppet do |puppet| puppet.manifests_path = "puppetmanifests" puppet.manifest_file = "newbox.pp" endend

Page 26: Vagrant and Configuration Management

Vagrant provisioning with Puppet Server

gareth rushgrove | morethanseven.net

Vagrant::Config.run do |config| config.vm.provision :puppet_server do |puppet| puppet.puppet_server = "puppet.example.com" puppet.puppet_node = "vm.example.com" endend

Page 27: Vagrant and Configuration Management

gareth rushgrove | morethanseven.net ttp://www.flickr.com/photos/moonboots/40371626

Advantages

gareth rushgrove | morethanseven.net http://www.flickr.com/photos/exalthim/1783760822

- Executable documentation- Early and often testing of configuration

- Shared language between dev and ops

Page 28: Vagrant and Configuration Management

Questions?

gareth rushgrove | morethanseven.net http://flickr.com/photos/psd/102332391/