Slide 1

Slide 1 text

Getting Started with Vagrant Andy Gale Tuesday, 19 March 13

Slide 2

Slide 2 text

Who are you? Andy Gale Head of Technology Content Hub Ltd @andygale Tuesday, 19 March 13

Slide 3

Slide 3 text

A way of managing virtual machines • Run different operating systems • Define virtual machines in code • Save your own ass What is Vagrant? Tuesday, 19 March 13

Slide 4

Slide 4 text

Vagrant Who has tried Vagrant before? Tuesday, 19 March 13

Slide 5

Slide 5 text

Setting up a development environment • Often considered a right of passage • Takes hours, often requires support • Requires documentation that’s always frequently out of date • Breaking your development environment can kill productivity for days • Produces unpredictable results Why Vagrant? Tuesday, 19 March 13

Slide 6

Slide 6 text

Your development and production environment are not the same! • Different OS? • Different version of PHP/Python/Ruby? • Diverged package versions? • Different default configuration files? Why Vagrant? Tuesday, 19 March 13

Slide 7

Slide 7 text

• Update a website with a new feature. • The feature relies on a PHP module that is required by your web app • Module already installed on your laptop because another project that is hosted elsewhere needed it • It’s not a the server you deploy to, so the entire website stops working • You have no idea why, the same code worked on your machine • It worked on my machine! Why Vagrant? Tuesday, 19 March 13

Slide 8

Slide 8 text

• Vagrant configuration should be stored in version control • New developers can start developing quicker • Switch between projects, versions of PHP, languages with a few commands Why Vagrant? Tuesday, 19 March 13

Slide 9

Slide 9 text

• Vagrant lowers development environment setup time • Maximizes dev/prod parity • Makes the “works on my machine” excuse a relic of the past. from vagrantup.com Why Vagrant? Tuesday, 19 March 13

Slide 10

Slide 10 text

Vagrant sounds good! Tuesday, 19 March 13

Slide 11

Slide 11 text

• Install Oracle’s VirtualBox www.virtualbox.org/wiki/Downloads • Install Vagrant (packages for Windows, Mac, Linux) downloads.vagrantup.com Getting Started Tuesday, 19 March 13

Slide 12

Slide 12 text

Box • A box is a saved image of virtual machine that contains all the necessary packages to use Vagrant • You can make your own from an existing VirtualBox VM or use one of the official Vagrant boxes Tuesday, 19 March 13

Slide 13

Slide 13 text

Official Boxes Ubuntu Lucid 32 Bit http://files.vagrantup.com/lucid32.box Ubuntu Lucid 64 Bit http://files.vagrantup.com/lucid64.box Ubuntu Precise 32 Bit http://files.vagrantup.com/precise32.box Ubuntu Precise 64 Bit http://files.vagrantup.com/precise64.box Tuesday, 19 March 13

Slide 14

Slide 14 text

More Boxes Example boxes here Tuesday, 19 March 13

Slide 15

Slide 15 text

Getting Started $ vagrant box add precise32 http://files.vagrantup.com/precise32.box Create a box Intialise a workspace $ cd workspace $ vagrant init precise32 Tuesday, 19 March 13

Slide 16

Slide 16 text

Configuration • Simple to configure using the Vagrantfile a text file which can be kept in version control • Easy to forward ports: Vagrant::Config.run do |config| # Forward guest port 80 to # host port 4567 config.vm.forward_port 80, 4567 end Tuesday, 19 March 13

Slide 17

Slide 17 text

Configuration config.vm.share_folder "v-data", "/data", "../data" Define shared folder Static IP config.vm.network '192.168.0.100' Set hostname config.vm.host_name = "steve" Boot with GUI config.vm.boot_mode :gui Tuesday, 19 March 13

Slide 18

Slide 18 text

Multiple VMs 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 end end Tuesday, 19 March 13

Slide 19

Slide 19 text

Vagrant Commands Create and start box $ vagrant up Connect to box $ vagrant ssh Close down box $ vagrant halt Delete box $ vagrant destroy Tuesday, 19 March 13

Slide 20

Slide 20 text

Vagrant Defaults • /vagrant - shares your workspace • Default username "vagrant" • Default password "vagrant" Tuesday, 19 March 13

Slide 21

Slide 21 text

• VirtualBox • Amazon EC2 • Rackspace • VMware Fusion (costs $79 per seat) • (more to come from the community) Providers Not just VirtualBox!!! Tuesday, 19 March 13

Slide 22

Slide 22 text

• Shell • Chef Solo • Chef Server • Puppet • Puppet Server • Build your own Provisioners You can provision with: Tuesday, 19 March 13