Rapid Prototyping with Vagrant and Chef

Rapid Prototyping with Vagrant and Chef

0 0


LTC2013 lightning talk on Vagrant and Chef

On Github jbfink / ltc2013-vagrant

Rapid Prototyping with Vagrant and Chef

John Fink

Digital Scholarship Librarian

McMaster University

e: john.fink@gmail.com

t: @adr

g: jbfink


Is this, uh, appropriate for a lightning talk? it's okay. mention bathroom breaks. Stretch legs. Come see me after!

Why develop with virtual machines?

This is my messy desk. Wouldn't it be great if each time you started a new project you could stow your messy desk away and have a new clean desk?
by making clones! Sort of like this!
This is supposed to be my "fast" slide, but while I was out in beautiful Hamilton, Ontario last week at a swap meet I saw this parked in the parking lot, and every time I see a Chevette I get really excited because, geez, how is it still running?

What is Vagrant?

vagrantup.com Ask if anybody in the room uses Virtualbox. Ask if anyone is *completely* mystified as to what virtual machining is. Basically it's making a new machine -- not necessarily of the same operating system or even processor type -- in your existing machine.
Vagrant is used most often with the Virtualbox VM engine, but recent versions have been abstracted to use pretty much any VM. Virtualbox is very popular though because it runs on Windows, OSX and Linux, is open source, and doesn't need special hardware to run. I run it on my 6 year old desktop at work and it runs ok.
Basically all this is is Virtualbox in a headless mode -- so it can be worked with programmatically -- plus a Ruby layer on top to define things like open ports, what sort of "base box" to use, and etc.


I know this is not really about Ruby, but if you're thinking about starting to learn programming it's really the only language that I've ever gelled to, and I'm an English major, so.

What is Chef?

opscode.com Usually when you make a new Vagrant machine, it comes pretty bare -- you can log into it but it doesn't have apache or gcc or php or ruby or whatever sort of dev environment you want. Chef is a way to define "recipes" or groups of recipes to make machines have different tasks. You could, say, have one recipe for apache, one for mysql, and one for php, and then after bringing up a Vagrant virtual machine, tell it install those three recipes and have a fully functioning php development machine.
package "apache2" do
  package_name node['apache']['package']

service "apache2" do
  case node['platform_family']
  when "rhel", "fedora", "suse"
    service_name "httpd"
    # If restarted/reloaded too quickly httpd has a habit of failing.
    # This may happen with multiple recipes notifying apache to restart - like
    # during the initial bootstrap.
    restart_command "/sbin/service httpd restart && sleep 1"
    reload_command "/sbin/service httpd reload && sleep 1"

Any questions?