Vagrant

32
Vagrant http://www.flickr.com/photos/ themacinator/

description

 

Transcript of Vagrant

Page 1: Vagrant

Vagrant

http://www.flickr.com/photos/themacinator/

Page 2: Vagrant

Credits

Creators of Vagrant Mitchell Hashimotor

• http://mitchellhashimoto.com/

John Bender• http://nickelcode.com/

Patrick Debois http://jedi.be/blog/Much of this presentation is based off his

http://www.slideshare.net/jedi4ever/vagrant-devopsdays-mountain-view-2011

Page 3: Vagrant

va·grant/ˈvāgrənt/Noun:A person without a settled home or regular work who wanders from place to place and lives by begging.

Page 4: Vagrant

Vagrant  http://www.vagrantup.com/a tool for creating and distributing virtualized development environments.

Page 5: Vagrant

How ?

http://www.flickr.com/photos/51029297@N00/

Page 6: Vagrant

Requirements

•Ruby (use RVM)•Virtualbox

Page 7: Vagrant

Install Stuff

$ gem install vagrant

Page 8: Vagrant

Your First Box

$ vagrant box add base http://files.vagrantup.com/lucid32.box$ vagrant init$ vagrant up

Page 9: Vagrant

Coffee

http://www.flickr.com/photos/rwp-roger/

Page 10: Vagrant

Connect

$ vagrant ssh 

Page 11: Vagrant

Had Enough

$ vagrant destroy

Page 12: Vagrant

Features

http://www.flickr.com/photos/sidereal/

Page 13: Vagrant

Port Forwarding

VM Workstation

80

3306

1080

13306

config.vm.forward_port "http", 80, 1080config.vm.forward_port "mysql", 3306, 13306

Page 14: Vagrant

Shared Filesystem

VM

Workstation

/home/bob/project

/project

config.vm.share_folder "project", "/project", "/home/bob/project"

Page 15: Vagrant

Provisioners

• Puppet• Chef• Shell Scripts

Page 16: Vagrant

Using Puppet

  config.vm.provision :puppet do |puppet|    puppet.manifests_path = "manifests"    puppet.manifest_file  = "node.pp"    puppet.module_path    = "modules"  end 

Page 17: Vagrant

Using Puppet

  config.vm.provision :puppet do |puppet|    puppet.manifests_path = "manifests"    puppet.manifest_file  = "node.pp"    puppet.module_path    = "modules"  end 

Page 18: Vagrant

include myserver

class myserver {    package {

        "apache2"     => "present",        "mysql-server => "present",        "vim"         => "present",    }}

node.pp

Page 19: Vagrant

Why Vagrant ?

• Easier than using Virtualbox• Rebuild at will• Dedicated environment for project• Reproducible environments• Distribute environments• Automated setup using Puppet, Chef or

Shell Scripts• Tear down when done

Page 20: Vagrant

For Developers

•Servers like live•Servers you control•Stop polluting your workstation•Still use the tools you love

Page 21: Vagrant

For Operations

•Testing Puppet Manifests•Trying out new software

Page 22: Vagrant

For Test

•Testing client applications•UI testing

Page 23: Vagrant

Demonstration

http://www.flickr.com/photos/strassenstriche/

Page 24: Vagrant

Cool Stuff

http://www.flickr.com/photos/wza/

Page 25: Vagrant

Version Control

Vagrantfile

Puppet

VCS

Page 26: Vagrant

StacksVagrant::Config.run do |config| config.vm.define :tomcat do |tomcat_config| web_config.vm.box = "tomcat" web_config.vm.forward_port("tc", 8080, 8080) end config.vm.define :web do |web_config| web_config.vm.box = "web" web_config.vm.forward_port("http", 80, 1080) end

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

Tomcat

MySQL

Apache

Page 27: Vagrant

Distribute Box

$ vagrant package --base my_base_box

Base Box Base BoxVMProvision Package

Page 28: Vagrant

Obtaining Base Boxeshttp://vagrantbox.es/

Page 29: Vagrant

Creating Base Boxes

•VeeWee• https://github.com/jedi4ever/veewee

Page 30: Vagrant

Referenceshttp://www.flickr.com/photos/brokenthoughts/

Page 31: Vagrant

References

• Vagrant http://vagrantup.com/• Vagrant https://github.com/mitchellh/vagrant• Virtual Box https://www.virtualbox.org/ • RVM http://beginrescueend.com/• Base Boxes http://vagrantbox.es/• VeeWee https://github.com/jedi4ever/veewee

Page 32: Vagrant

Questions ?http://www.flickr.com/photos/dullhunk/