Vagrant Up in 5 Easy
Steps
Trevor Roberts Jr
@VMTrooper
Cody Bunch
@cody_bunch
Introduction
 What is Vagrant?
 Created by Mitchell Hashimoto
 Provisioning Tool for Dev & Test Environments
 Why use Vagrant?
 Quick
 Easily replicate production on a Dev box
 How do I get started?
Step 1: Select your Provider
 What is a provider?
 Oracle VirtualBox (Free)
 VMware Fusion or Workstation ($)
 Build your own (AWS, Rackspace, etc.)
Step 2: Install Vagrant
 http://downloads.vagrantup.com
Step 3: Download a box
 VirtualBox: http://files.vagrantup.com/precise64.box
 VMware Fusion:
http://files.vagrantup.com/precise64_vmware.box
 Build your own or use others:
http://www.vagrantbox.es/
Step 4: Vagrant Init & Up
Open a Terminal Window in the directory for your test lab:
 vagrant init
 Edit the resulting Vagrantfile
 vagrant up
Step 5: Vagrant SSH
Login to the VM using vagrant CLI:
 vagrant ssh
Success!
But wait, there’s more…
 Version Control
 Customize Your VM
 Multi-VM Configuration (Static & Dynamic)
 VM Provisioners
 Squid Proxy
Version Control
 Source Code Control for your Vagrantfile
 Git, SVN, etc.
 Online collaboration
 GitHub, BitBucket, etc.
 This presentation and example code can be found at:
https://github.com/VMTrooper/VagrantBrownBag
Customize Your VM
 Hostname
 config.vm.hostname = "controller"
 IP Address
 config.vm.network :private_network, ip: 178.16.172.200
NOTE: for NAT addresses (i.e. :public_network), you will
need to do some extra work involving DHCP
Customize Your VM
 Memory
# If using Fusion
config.vm.provider :vmware_fusion do |v|
v.vmx["memsize"] = 1024
end
# If using VirtualBox
config.vm.provider :virtualbox do |vbox|
vbox.customize ["modifyvm", :id, "--memory", 1024]
end
Multi-VM Configuration
 Share files between VMs.
 The Vagrantfile’s folder is mounted to /vagrant on each
VM
 See sample code
Provisioners
 Configuration Management
 Shell Scripts
 Puppet (Standalone & Agent)
 Chef (Solo & Client)
 Ansible
Additional Info
 Vagrant Site: http://docs.vagrantup.com/v2/
 Google Groups: https://groups.google.com/forum/#!forum/vagrant-up
 IRC: #vagrant on Freenode
 GitHub (Check out bunchc, bodepd, ody, etc)
 For Fusion-related tips, I post them as I find them:
 http://vmtrooper.com/category/automation/vagrant/
 Mitchell’s Book

Vagrant Up in 5 Easy Steps

  • 1.
    Vagrant Up in5 Easy Steps Trevor Roberts Jr @VMTrooper Cody Bunch @cody_bunch
  • 2.
    Introduction  What isVagrant?  Created by Mitchell Hashimoto  Provisioning Tool for Dev & Test Environments  Why use Vagrant?  Quick  Easily replicate production on a Dev box  How do I get started?
  • 3.
    Step 1: Selectyour Provider  What is a provider?  Oracle VirtualBox (Free)  VMware Fusion or Workstation ($)  Build your own (AWS, Rackspace, etc.)
  • 4.
    Step 2: InstallVagrant  http://downloads.vagrantup.com
  • 5.
    Step 3: Downloada box  VirtualBox: http://files.vagrantup.com/precise64.box  VMware Fusion: http://files.vagrantup.com/precise64_vmware.box  Build your own or use others: http://www.vagrantbox.es/
  • 6.
    Step 4: VagrantInit & Up Open a Terminal Window in the directory for your test lab:  vagrant init  Edit the resulting Vagrantfile  vagrant up
  • 7.
    Step 5: VagrantSSH Login to the VM using vagrant CLI:  vagrant ssh
  • 8.
  • 9.
    But wait, there’smore…  Version Control  Customize Your VM  Multi-VM Configuration (Static & Dynamic)  VM Provisioners  Squid Proxy
  • 10.
    Version Control  SourceCode Control for your Vagrantfile  Git, SVN, etc.  Online collaboration  GitHub, BitBucket, etc.  This presentation and example code can be found at: https://github.com/VMTrooper/VagrantBrownBag
  • 11.
    Customize Your VM Hostname  config.vm.hostname = "controller"  IP Address  config.vm.network :private_network, ip: 178.16.172.200 NOTE: for NAT addresses (i.e. :public_network), you will need to do some extra work involving DHCP
  • 12.
    Customize Your VM Memory # If using Fusion config.vm.provider :vmware_fusion do |v| v.vmx["memsize"] = 1024 end # If using VirtualBox config.vm.provider :virtualbox do |vbox| vbox.customize ["modifyvm", :id, "--memory", 1024] end
  • 13.
    Multi-VM Configuration  Sharefiles between VMs.  The Vagrantfile’s folder is mounted to /vagrant on each VM  See sample code
  • 14.
    Provisioners  Configuration Management Shell Scripts  Puppet (Standalone & Agent)  Chef (Solo & Client)  Ansible
  • 15.
    Additional Info  VagrantSite: http://docs.vagrantup.com/v2/  Google Groups: https://groups.google.com/forum/#!forum/vagrant-up  IRC: #vagrant on Freenode  GitHub (Check out bunchc, bodepd, ody, etc)  For Fusion-related tips, I post them as I find them:  http://vmtrooper.com/category/automation/vagrant/  Mitchell’s Book

Editor's Notes

  • #7 Alternatively first line could be…For Fusion: vagrant init precise64 http://files.vagrantup.com/precise64_vmware.boxFor VirtualBox:vagrant init precise64 http://files.vagrantup.com/precise64.boxIt will automatically configure the name of the Vagrant box that you are using and
  • #12 For NAT, see http://vmtrooper.com/vagrant-static-external-ip-addresses-with-the-vmware-fusion-provider/