5. Hardware Approach
Set up test
environment
Make change
Did change work?
Yes
Commit
No
‣ Walk to server room
‣ Plug in keyboard/monitor
‣ Reboot Server (~2m)
‣ Wait for Kickstart install (~30m)
‣ Upload automation bash scripts
‣ Run them (~15m)
‣ Assess success
6. Virtualisation
Set up test
environment
Make change
Did change work?
Yes
Commit
No
‣ Use Kickstart to create base image
(~30m)
‣ Roll back to VM snapshot
‣ Upload automation bash scripts
‣ Run them (~15m)
‣ Assess success
7. What is Vagrant?
‣ Command line tool
‣ Supports Linux, Mac, Windows
‣ Supports multiple hypervisors
‣ Folder sharing
‣ As portable as your laptop
8. What is Vagrant?
‣ Import pre-defined “base boxes” from remote servers
‣ Describe box configuration in Vagrantfile
‣ Share both with other people
‣ “vagrant up” starts a clean, new environment
‣ “vagrant destroy” throws it away.
9. What is Vagrant?
Webserver
Messenger Database
Text editor Browser
Operating System
Music
Twitter
Photoshop
Filesystem
10. What is Vagrant?
Browser Photoshop
Database
Operating System
Webserver
Text editor
Messenger
Music
Twitter
Guest O/S
Filesystem
14. Vagrantfile
Vagrant.configure("2") do |config|
# Set up some box defaults. We're going to use the Puppet Labs
# CentOS 6.5 x86_64 base box, and give it 1GB RAM
config.vm.box = 'puppetlabs/centos-6.5-64-puppet'
# …
# Set up some Puppet "facts". These will be available to the
# puppet manifests when they run.
puppet_facts = {
"vagrant" => “1”,
"roles" => [ 'webserver', 'database' ]
}
# Provision the Vagrant box using Puppet.
config.vm.provision "puppet" do |puppet|
puppet.manifests_path = "puppet/manifests"
puppet.manifest_file = "site.pp"
puppet.module_path = "puppet/modules"
puppet.facter = puppet_facts
end
end
15. Nodeless Configuration
# On every node...
node default {
# ...apply some default settings
class { demo_defaults: }
# Then apply classes for each role we've found via facts:
if( 'webserver' in $roles ) {
notice("Found 'webserver' role via Facts")
class { demo_role_webserver: }
}
if( 'database' in $roles ) {
notice("Found 'database' role via Facts")
class { demo_role_database: }
}
}
16. Nodeless Configuration
class demo_defaults {
# ...
# If this is a vagrant box, let's just stop iptables because we don't need
# any firewalling.
if( $vagrant ) {
service { "iptables":
ensure => stopped,
enable => false,
}
}
}
18. Benefits
‣ Short cycle time
‣ No copying files around
‣ Share box & manifests with development teams
‣ Easy to try existing config on new operating systems
19. Advanced Usage
‣ Multiple box environments with private networking
‣ “vagrant share” features of Vagrant Cloud
‣ Build production images with the same tools
‣ Build fully automated test suites
20. Try it yourself
‣ https://github.com/jtopper/vagrant-demo
‣ Follow the instructions in the README
‣ Open a new GitHub issue if you get stuck!