SlideShare a Scribd company logo
1 of 34
Using Vagrant
    Andy Gale
Who are you?



 Andy Gale
 andy-gale.com
 @andygale
What is 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.
What is Vagrant?
A way of managing virtual machines




 •   Run different operating systems

 •   Define virtual machines in code

 •   Save your own ass
Why Vagrant?
     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 a day

•   Produces unpredictable results
Why Vagrant?
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?
•   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?

• 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
Vagrant sounds
    good!
Getting Started


• Install Oracle’s VirtualBox
  www.virtualbox.org/wiki/Downloads

• Install Vagrant (packages for
  Windows, Mac, Linux)
  downloads.vagrantup.com
Getting Started

               Create a
$ vagrant box add precise32
http://files.vagrantup.com/
precise32.box
       Intialise a workspace
$ cd workspace
$ vagrant init precise32
Configuration
• Simple to configure using the Vagrantfile -
  A Ruby DSL - 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
Configuration

             Define shared folder
config.vm.share_folder "v-data", "/data", "../data"

                    Static IP
       config.vm.network '192.168.0.100'

                 Set hostname
         config.vm.host_name = "steve"

                  Boot with GUI
           config.vm.boot_mode :gui
Vagrant Defaults



• /vagrant - shares your workspace
• Default username "vagrant"
• Default password "vagrant"
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
It’s alive!
  Bring box up!
  $ vagrant up
Connection to box
  $ vagrant ssh
 Close down box
  $ vagrant halt
   Delete box
$ vagrant destroy
So what else?

• Install all the packages you need
  once

• Make it the same as your product
  environment

• Make a base box and distribute
  amongst developers

• What time has this actually saved
Package


$ vagrant package --vagrantfile
Provisioners
You can provision with:

• Shell
• Chef Solo
• Chef Server
• Puppet
• Puppet Server
• Build your own
Provisioners
                 Shell


Vagrant::Config.run do |config|
  config.vm.provision :shell, :path =>
"test.sh"
end
Provisioners
            Chef Solo:

Vagrant::Config.run do |config|
  config.vm.provision :chef_solo do |
chef|
    chef.roles_path = "roles"
    chef.add_role("vm")
  end
end
Provisioners
             Chef Server:
Vagrant::Config.run do |config|
  config.vm.provision :chef_server do |
chef|
     chef.chef_server_url = "http://
chef.inter.net"
     chef.add_role("vm")
  end
end
Provisioners
               Puppet:
Vagrant::Config.run do |config|
  config.vm.provision :puppet do |
puppet|
     puppet.mainfests_path =
"puppetmanifests"
     puppet.mainfest_file = "newbox.pp"
  end
end
Provisioners
           Puppet Server:
Vagrant::Config.run do |config|
  config.vm.provision :puppet_server do |
puppet|
     puppet.puppet_server =
"puppet.inter.net"
     puppet.puppet_node =
"vm.internet.net"
  end
end
Provision with Chef




• A tool for automating the provisioning
  and management of your servers
• Open source
• Lots of examples and code to get you
  started
Chef
           Very brief overview

               Cookbooks
Collections of recipes, templates and other
configuration attributes to get stuff done.

                 Recipes
Chunks of Ruby code that describe what stuff
   we need to do to get that stuff done.
Chef
                         My First Recipe
                                                    Install package
package "ntp" do
  action :install
end                                                Create config file
                                                    from template
template "/etc/ntp.conf" do
  source "ntp.conf.erb"
  owner "root"                                         Restart service
  group "root"                                         when config file
  mode 0644                                               changes
  notifies :restart, resources(:service => "ntp")
end

service "ntp" do
  action :start                               Define service and
end                                              start NTP
Chef
        Scary but you’re not alone


• Community cookbooks
  http://community.opscode.com/

• IRC #chef on freenode
• Foodfight show podcast
  http://foodfightshow.org/index.html

• Ask me andygale@andy-gale.com
Example
    Get started with a CakePHP application environment
                   with Vagrant and Chef


    • Install Oracle’s VirtualBox
    • Install Vagrant
$   git clone git@github.com:salgo/cakefest-vagrant-chef.git
$   cd cakefest-vagrant-chef
$   ./git-fetch-submodules.sh
$   vagrant up
Vagrant and onwards

   Will soon support new virtualisers


• OpenStack
• VMWare?
• Linux containers?
• Write your own?
Vagrant Tips

• If you’re running OS X make sure OS
  updates are compatible with VirtualBox
  - Oracle are quick to release fixes but
  best to check

• Keep guest additions up to date with
  https://github.com/dotless-de/vagrant-vbguest

• You can play with Chef in Vagrant so
  there’s no excuse not to try
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
Other Boxes

    Example boxes here
Questions?

More Related Content

What's hot

Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20Michael Lihs
 
Codecoon - A technical Case Study
Codecoon - A technical Case StudyCodecoon - A technical Case Study
Codecoon - A technical Case StudyMichael Lihs
 
Docker Docker Docker Chef
Docker Docker Docker ChefDocker Docker Docker Chef
Docker Docker Docker ChefSean OMeara
 
Steamlining your puppet development workflow
Steamlining your puppet development workflowSteamlining your puppet development workflow
Steamlining your puppet development workflowTomas Doran
 
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...Puppet
 
Superb Supervision of Short-lived Servers with Sensu
Superb Supervision of Short-lived Servers with SensuSuperb Supervision of Short-lived Servers with Sensu
Superb Supervision of Short-lived Servers with SensuPaul O'Connor
 
Lessons from Etsy: Avoiding Kitchen Nightmares - #ChefConf 2012
Lessons from Etsy: Avoiding Kitchen Nightmares - #ChefConf 2012Lessons from Etsy: Avoiding Kitchen Nightmares - #ChefConf 2012
Lessons from Etsy: Avoiding Kitchen Nightmares - #ChefConf 2012Patrick McDonnell
 
Drone your Ansible
Drone your AnsibleDrone your Ansible
Drone your AnsibleDennis Rowe
 
Deploying PHP Applications with Ansible
Deploying PHP Applications with AnsibleDeploying PHP Applications with Ansible
Deploying PHP Applications with AnsibleOrestes Carracedo
 
Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...
Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...
Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...Puppet
 
OSCamp 2019 | #3 Ansible: Automated Tests of Ansible code with GitLab, Vagran...
OSCamp 2019 | #3 Ansible: Automated Tests of Ansible code with GitLab, Vagran...OSCamp 2019 | #3 Ansible: Automated Tests of Ansible code with GitLab, Vagran...
OSCamp 2019 | #3 Ansible: Automated Tests of Ansible code with GitLab, Vagran...NETWAYS
 
TYPO3 Camp Stuttgart 2015 - Continuous Delivery with Open Source Tools
TYPO3 Camp Stuttgart 2015 - Continuous Delivery with Open Source ToolsTYPO3 Camp Stuttgart 2015 - Continuous Delivery with Open Source Tools
TYPO3 Camp Stuttgart 2015 - Continuous Delivery with Open Source ToolsMichael Lihs
 
Investigation of testing with ansible
Investigation of testing with ansibleInvestigation of testing with ansible
Investigation of testing with ansibleDennis Rowe
 
Powering Development and Testing Environments with Vagrant
Powering Development and Testing Environments with VagrantPowering Development and Testing Environments with Vagrant
Powering Development and Testing Environments with VagrantCoen Jacobs
 
How to Write Chef Cookbook
How to Write Chef CookbookHow to Write Chef Cookbook
How to Write Chef Cookbookdevopsjourney
 
Hand Crafted Artisanal Chef Resources
Hand Crafted Artisanal Chef ResourcesHand Crafted Artisanal Chef Resources
Hand Crafted Artisanal Chef ResourcesSean OMeara
 
Michelin Starred Cooking with Chef
Michelin Starred Cooking with ChefMichelin Starred Cooking with Chef
Michelin Starred Cooking with ChefJon Cowie
 
Docker puppetcamp london 2013
Docker puppetcamp london 2013Docker puppetcamp london 2013
Docker puppetcamp london 2013Tomas Doran
 
CI/CD Using Ansible and Jenkins for Infrastructure
CI/CD Using Ansible and Jenkins for InfrastructureCI/CD Using Ansible and Jenkins for Infrastructure
CI/CD Using Ansible and Jenkins for InfrastructureFaisal Shaikh
 
How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...
How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...
How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...Puppet
 

What's hot (20)

Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
 
Codecoon - A technical Case Study
Codecoon - A technical Case StudyCodecoon - A technical Case Study
Codecoon - A technical Case Study
 
Docker Docker Docker Chef
Docker Docker Docker ChefDocker Docker Docker Chef
Docker Docker Docker Chef
 
Steamlining your puppet development workflow
Steamlining your puppet development workflowSteamlining your puppet development workflow
Steamlining your puppet development workflow
 
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
 
Superb Supervision of Short-lived Servers with Sensu
Superb Supervision of Short-lived Servers with SensuSuperb Supervision of Short-lived Servers with Sensu
Superb Supervision of Short-lived Servers with Sensu
 
Lessons from Etsy: Avoiding Kitchen Nightmares - #ChefConf 2012
Lessons from Etsy: Avoiding Kitchen Nightmares - #ChefConf 2012Lessons from Etsy: Avoiding Kitchen Nightmares - #ChefConf 2012
Lessons from Etsy: Avoiding Kitchen Nightmares - #ChefConf 2012
 
Drone your Ansible
Drone your AnsibleDrone your Ansible
Drone your Ansible
 
Deploying PHP Applications with Ansible
Deploying PHP Applications with AnsibleDeploying PHP Applications with Ansible
Deploying PHP Applications with Ansible
 
Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...
Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...
Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...
 
OSCamp 2019 | #3 Ansible: Automated Tests of Ansible code with GitLab, Vagran...
OSCamp 2019 | #3 Ansible: Automated Tests of Ansible code with GitLab, Vagran...OSCamp 2019 | #3 Ansible: Automated Tests of Ansible code with GitLab, Vagran...
OSCamp 2019 | #3 Ansible: Automated Tests of Ansible code with GitLab, Vagran...
 
TYPO3 Camp Stuttgart 2015 - Continuous Delivery with Open Source Tools
TYPO3 Camp Stuttgart 2015 - Continuous Delivery with Open Source ToolsTYPO3 Camp Stuttgart 2015 - Continuous Delivery with Open Source Tools
TYPO3 Camp Stuttgart 2015 - Continuous Delivery with Open Source Tools
 
Investigation of testing with ansible
Investigation of testing with ansibleInvestigation of testing with ansible
Investigation of testing with ansible
 
Powering Development and Testing Environments with Vagrant
Powering Development and Testing Environments with VagrantPowering Development and Testing Environments with Vagrant
Powering Development and Testing Environments with Vagrant
 
How to Write Chef Cookbook
How to Write Chef CookbookHow to Write Chef Cookbook
How to Write Chef Cookbook
 
Hand Crafted Artisanal Chef Resources
Hand Crafted Artisanal Chef ResourcesHand Crafted Artisanal Chef Resources
Hand Crafted Artisanal Chef Resources
 
Michelin Starred Cooking with Chef
Michelin Starred Cooking with ChefMichelin Starred Cooking with Chef
Michelin Starred Cooking with Chef
 
Docker puppetcamp london 2013
Docker puppetcamp london 2013Docker puppetcamp london 2013
Docker puppetcamp london 2013
 
CI/CD Using Ansible and Jenkins for Infrastructure
CI/CD Using Ansible and Jenkins for InfrastructureCI/CD Using Ansible and Jenkins for Infrastructure
CI/CD Using Ansible and Jenkins for Infrastructure
 
How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...
How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...
How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...
 

Viewers also liked

Vagrant - RuPy Tuesday
Vagrant - RuPy TuesdayVagrant - RuPy Tuesday
Vagrant - RuPy TuesdayGaldoMedia
 
Compliance Automation with Inspec Part 1
Compliance Automation with Inspec Part 1Compliance Automation with Inspec Part 1
Compliance Automation with Inspec Part 1Chef
 
Introduction to Chef - Techsuperwomen Summit
Introduction to Chef - Techsuperwomen SummitIntroduction to Chef - Techsuperwomen Summit
Introduction to Chef - Techsuperwomen SummitJennifer Davis
 
Wprowadzenie do technologii Puppet
Wprowadzenie do technologii PuppetWprowadzenie do technologii Puppet
Wprowadzenie do technologii PuppetSages
 
Introducing Chef | An IT automation for speed and awesomeness
Introducing Chef | An IT automation for speed and awesomenessIntroducing Chef | An IT automation for speed and awesomeness
Introducing Chef | An IT automation for speed and awesomenessRamit Surana
 
Infrastructure Automation with Chef & Ansible
Infrastructure Automation with Chef & AnsibleInfrastructure Automation with Chef & Ansible
Infrastructure Automation with Chef & Ansiblewajrcs
 
Introduction to Chef: Automate Your Infrastructure by Modeling It In Code
Introduction to Chef: Automate Your Infrastructure by Modeling It In CodeIntroduction to Chef: Automate Your Infrastructure by Modeling It In Code
Introduction to Chef: Automate Your Infrastructure by Modeling It In CodeJosh Padnick
 

Viewers also liked (9)

Vagrant - RuPy Tuesday
Vagrant - RuPy TuesdayVagrant - RuPy Tuesday
Vagrant - RuPy Tuesday
 
Compliance Automation with Inspec Part 1
Compliance Automation with Inspec Part 1Compliance Automation with Inspec Part 1
Compliance Automation with Inspec Part 1
 
Introduction to Chef - Techsuperwomen Summit
Introduction to Chef - Techsuperwomen SummitIntroduction to Chef - Techsuperwomen Summit
Introduction to Chef - Techsuperwomen Summit
 
Wprowadzenie do technologii Puppet
Wprowadzenie do technologii PuppetWprowadzenie do technologii Puppet
Wprowadzenie do technologii Puppet
 
Introducing Chef | An IT automation for speed and awesomeness
Introducing Chef | An IT automation for speed and awesomenessIntroducing Chef | An IT automation for speed and awesomeness
Introducing Chef | An IT automation for speed and awesomeness
 
Introduction to chef
Introduction to chefIntroduction to chef
Introduction to chef
 
Infrastructure Automation with Chef & Ansible
Infrastructure Automation with Chef & AnsibleInfrastructure Automation with Chef & Ansible
Infrastructure Automation with Chef & Ansible
 
Chef introduction
Chef introductionChef introduction
Chef introduction
 
Introduction to Chef: Automate Your Infrastructure by Modeling It In Code
Introduction to Chef: Automate Your Infrastructure by Modeling It In CodeIntroduction to Chef: Automate Your Infrastructure by Modeling It In Code
Introduction to Chef: Automate Your Infrastructure by Modeling It In Code
 

Similar to Using Vagrant

PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & Hadoop
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & HadoopPuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & Hadoop
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & HadoopWalter Heck
 
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & Hadoop
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & HadoopPuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & Hadoop
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & HadoopOlinData
 
Using Vagrant, Puppet, Testing & Hadoop
Using Vagrant, Puppet, Testing & HadoopUsing Vagrant, Puppet, Testing & Hadoop
Using Vagrant, Puppet, Testing & HadoopPuppet
 
Vagrant Binding JayDay 2013
Vagrant Binding JayDay 2013Vagrant Binding JayDay 2013
Vagrant Binding JayDay 2013Hendrik Ebbers
 
Devoxx UK 2013: Sandboxing with the Vagrant-Binding API
Devoxx UK 2013: Sandboxing with the Vagrant-Binding APIDevoxx UK 2013: Sandboxing with the Vagrant-Binding API
Devoxx UK 2013: Sandboxing with the Vagrant-Binding APIHendrik Ebbers
 
Getting started with puppet and vagrant (1)
Getting started with puppet and vagrant (1)Getting started with puppet and vagrant (1)
Getting started with puppet and vagrant (1)Puppet
 
Vagrant introduction for Developers
Vagrant introduction for DevelopersVagrant introduction for Developers
Vagrant introduction for DevelopersAntons Kranga
 
Vagrant-Binding JUG Dortmund
Vagrant-Binding JUG DortmundVagrant-Binding JUG Dortmund
Vagrant-Binding JUG DortmundHendrik Ebbers
 
Automated Infrastructure and Application Management
Automated Infrastructure and Application ManagementAutomated Infrastructure and Application Management
Automated Infrastructure and Application ManagementClark Everetts
 
Vagrant-Overview
Vagrant-OverviewVagrant-Overview
Vagrant-OverviewCrifkin
 
Create Development and Production Environments with Vagrant
Create Development and Production Environments with VagrantCreate Development and Production Environments with Vagrant
Create Development and Production Environments with VagrantBrian Hogan
 
Lightweight and reproducible environments with vagrant and Puppet
Lightweight and reproducible environments with vagrant and PuppetLightweight and reproducible environments with vagrant and Puppet
Lightweight and reproducible environments with vagrant and PuppetHendrik Ebbers
 
Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...
Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...
Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...Chef Software, Inc.
 
Laravel Forge: Hello World to Hello Production
Laravel Forge: Hello World to Hello ProductionLaravel Forge: Hello World to Hello Production
Laravel Forge: Hello World to Hello ProductionJoe Ferguson
 
Cooking Perl with Chef: Hello World Tutorial
Cooking Perl with Chef: Hello World TutorialCooking Perl with Chef: Hello World Tutorial
Cooking Perl with Chef: Hello World TutorialDavid Golden
 
Node object and roles - Fundamentals Webinar Series Part 3
Node object and roles - Fundamentals Webinar Series Part 3Node object and roles - Fundamentals Webinar Series Part 3
Node object and roles - Fundamentals Webinar Series Part 3Chef
 
Cooking Perl with Chef: Real World Tutorial with Jitterbug
Cooking Perl with Chef: Real World Tutorial with JitterbugCooking Perl with Chef: Real World Tutorial with Jitterbug
Cooking Perl with Chef: Real World Tutorial with JitterbugDavid Golden
 
How I hack on puppet modules
How I hack on puppet modulesHow I hack on puppet modules
How I hack on puppet modulesKris Buytaert
 

Similar to Using Vagrant (20)

PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & Hadoop
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & HadoopPuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & Hadoop
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & Hadoop
 
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & Hadoop
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & HadoopPuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & Hadoop
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & Hadoop
 
Using Vagrant, Puppet, Testing & Hadoop
Using Vagrant, Puppet, Testing & HadoopUsing Vagrant, Puppet, Testing & Hadoop
Using Vagrant, Puppet, Testing & Hadoop
 
Vagrant Binding JayDay 2013
Vagrant Binding JayDay 2013Vagrant Binding JayDay 2013
Vagrant Binding JayDay 2013
 
Vagrant For DevOps
Vagrant For DevOpsVagrant For DevOps
Vagrant For DevOps
 
Devoxx UK 2013: Sandboxing with the Vagrant-Binding API
Devoxx UK 2013: Sandboxing with the Vagrant-Binding APIDevoxx UK 2013: Sandboxing with the Vagrant-Binding API
Devoxx UK 2013: Sandboxing with the Vagrant-Binding API
 
Getting started with puppet and vagrant (1)
Getting started with puppet and vagrant (1)Getting started with puppet and vagrant (1)
Getting started with puppet and vagrant (1)
 
Vagrant introduction for Developers
Vagrant introduction for DevelopersVagrant introduction for Developers
Vagrant introduction for Developers
 
Vagrant-Binding JUG Dortmund
Vagrant-Binding JUG DortmundVagrant-Binding JUG Dortmund
Vagrant-Binding JUG Dortmund
 
Automated Infrastructure and Application Management
Automated Infrastructure and Application ManagementAutomated Infrastructure and Application Management
Automated Infrastructure and Application Management
 
Vagrant-Overview
Vagrant-OverviewVagrant-Overview
Vagrant-Overview
 
Create Development and Production Environments with Vagrant
Create Development and Production Environments with VagrantCreate Development and Production Environments with Vagrant
Create Development and Production Environments with Vagrant
 
Lightweight and reproducible environments with vagrant and Puppet
Lightweight and reproducible environments with vagrant and PuppetLightweight and reproducible environments with vagrant and Puppet
Lightweight and reproducible environments with vagrant and Puppet
 
Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...
Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...
Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...
 
Laravel Forge: Hello World to Hello Production
Laravel Forge: Hello World to Hello ProductionLaravel Forge: Hello World to Hello Production
Laravel Forge: Hello World to Hello Production
 
Cooking Perl with Chef: Hello World Tutorial
Cooking Perl with Chef: Hello World TutorialCooking Perl with Chef: Hello World Tutorial
Cooking Perl with Chef: Hello World Tutorial
 
Node object and roles - Fundamentals Webinar Series Part 3
Node object and roles - Fundamentals Webinar Series Part 3Node object and roles - Fundamentals Webinar Series Part 3
Node object and roles - Fundamentals Webinar Series Part 3
 
Cooking Perl with Chef: Real World Tutorial with Jitterbug
Cooking Perl with Chef: Real World Tutorial with JitterbugCooking Perl with Chef: Real World Tutorial with Jitterbug
Cooking Perl with Chef: Real World Tutorial with Jitterbug
 
Vagrant
Vagrant Vagrant
Vagrant
 
How I hack on puppet modules
How I hack on puppet modulesHow I hack on puppet modules
How I hack on puppet modules
 

Using Vagrant

  • 1. Using Vagrant Andy Gale
  • 2. Who are you? Andy Gale andy-gale.com @andygale
  • 3. What is 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.
  • 4. What is Vagrant? A way of managing virtual machines • Run different operating systems • Define virtual machines in code • Save your own ass
  • 5. Why Vagrant? 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 a day • Produces unpredictable results
  • 6. Why Vagrant? Your development and production environment are not the same! • Different OS? • Different version of PHP/Python/Ruby? • Diverged package versions? • Different default configuration files?
  • 7. Why Vagrant? • 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!
  • 8. Why Vagrant? • 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
  • 10. Getting Started • Install Oracle’s VirtualBox www.virtualbox.org/wiki/Downloads • Install Vagrant (packages for Windows, Mac, Linux) downloads.vagrantup.com
  • 11. Getting Started Create a $ vagrant box add precise32 http://files.vagrantup.com/ precise32.box Intialise a workspace $ cd workspace $ vagrant init precise32
  • 12. Configuration • Simple to configure using the Vagrantfile - A Ruby DSL - 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
  • 13. Configuration Define shared folder config.vm.share_folder "v-data", "/data", "../data" Static IP config.vm.network '192.168.0.100' Set hostname config.vm.host_name = "steve" Boot with GUI config.vm.boot_mode :gui
  • 14. Vagrant Defaults • /vagrant - shares your workspace • Default username "vagrant" • Default password "vagrant"
  • 15. 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
  • 16. It’s alive! Bring box up! $ vagrant up Connection to box $ vagrant ssh Close down box $ vagrant halt Delete box $ vagrant destroy
  • 17. So what else? • Install all the packages you need once • Make it the same as your product environment • Make a base box and distribute amongst developers • What time has this actually saved
  • 18. Package $ vagrant package --vagrantfile
  • 19. Provisioners You can provision with: • Shell • Chef Solo • Chef Server • Puppet • Puppet Server • Build your own
  • 20. Provisioners Shell Vagrant::Config.run do |config|   config.vm.provision :shell, :path => "test.sh" end
  • 21. Provisioners Chef Solo: Vagrant::Config.run do |config|   config.vm.provision :chef_solo do | chef|     chef.roles_path = "roles"     chef.add_role("vm")   end end
  • 22. Provisioners Chef Server: Vagrant::Config.run do |config|   config.vm.provision :chef_server do | chef|      chef.chef_server_url = "http:// chef.inter.net"      chef.add_role("vm")   end end
  • 23. Provisioners Puppet: Vagrant::Config.run do |config|   config.vm.provision :puppet do | puppet|      puppet.mainfests_path = "puppetmanifests"      puppet.mainfest_file = "newbox.pp"   end end
  • 24. Provisioners Puppet Server: Vagrant::Config.run do |config|   config.vm.provision :puppet_server do | puppet|      puppet.puppet_server = "puppet.inter.net"      puppet.puppet_node = "vm.internet.net"   end end
  • 25. Provision with Chef • A tool for automating the provisioning and management of your servers • Open source • Lots of examples and code to get you started
  • 26. Chef Very brief overview Cookbooks Collections of recipes, templates and other configuration attributes to get stuff done. Recipes Chunks of Ruby code that describe what stuff we need to do to get that stuff done.
  • 27. Chef My First Recipe Install package package "ntp" do   action :install end Create config file from template template "/etc/ntp.conf" do   source "ntp.conf.erb"   owner "root" Restart service   group "root" when config file   mode 0644 changes   notifies :restart, resources(:service => "ntp") end service "ntp" do   action :start Define service and end start NTP
  • 28. Chef Scary but you’re not alone • Community cookbooks http://community.opscode.com/ • IRC #chef on freenode • Foodfight show podcast http://foodfightshow.org/index.html • Ask me andygale@andy-gale.com
  • 29. Example Get started with a CakePHP application environment with Vagrant and Chef • Install Oracle’s VirtualBox • Install Vagrant $ git clone git@github.com:salgo/cakefest-vagrant-chef.git $ cd cakefest-vagrant-chef $ ./git-fetch-submodules.sh $ vagrant up
  • 30. Vagrant and onwards Will soon support new virtualisers • OpenStack • VMWare? • Linux containers? • Write your own?
  • 31. Vagrant Tips • If you’re running OS X make sure OS updates are compatible with VirtualBox - Oracle are quick to release fixes but best to check • Keep guest additions up to date with https://github.com/dotless-de/vagrant-vbguest • You can play with Chef in Vagrant so there’s no excuse not to try
  • 32. 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
  • 33. Other Boxes Example boxes here

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n