Vagrant

TotT 2014

System Virtual Machines

"a complete system platform which supports the execution of a complete operating system (OS)"
- Wikipedia

Use Cases

  • Multiple OSes
  • Architecture emulation
  • On-demand provisioning
  • Workload migration
  • Disaster recovery
  • Environment consistency

Consistency

  • Working with a team
  • Developing across machines
  • Deploying to production
  • Shipping to a customer

Downsides

  • Guest OS weight
  • Reduced efficiency
  • Resource competition
  • Not entirely portable

VirtualBox

  • Type 2 Hypervisor
    English: It runs VMs on your laptop.
  • Manages VM images
  • Runs VM instances

Vagrant

Developer-centric VM management

  1. Get / create a box (i.e., VM image).
  2. Write a config file.
  3. Script your installs.
  4. Run it.
  5. Share it with your team.

Vagrant CLI

Three commands to master:

$ vagrant up
$ vagrant ssh
$ vagrant destroy

Demo: Vagrant Basics

Demo: Vagrant Basics

Vagrantfile

  1. States the box to use
  2. States how to configure the box (e.g., networking)
  3. States how to provision software on the box

Example: Simple Vagrantfile

Vagrant.configure("2") do |config|
  # fetches a box (i.e., VM image)
  config.vm.box = "tottbox_2013_07_31"
  config.vm.box_url = "http://static.mindtrove.info/tott/#{config.vm.box}.box"
  
  # configures it
  config.vm.network :private_network, ip: "192.168.33.10"
  config.vm.network :forwarded_port, guest: 8080, host: 8080
  
  # runs scripts on it
  config.vm.provision :shell, :inline => "sudo apt-get -y update"
end

tottbox

  • Our Vagrant box
  • Our shared dev environment
  • Pre-configured with many tools

Review

  • Virtual machines
  • VirtualBox
  • Vagrant