Vagrant for classroom inspired by
https://twitter.com/ctrabold at the 2011 Hamburg Railscamp http://railscamp-hamburg.de/ which I saw from the twittersteam of the event.
The goal of the project is to setup Vagrant to launch a linux VM that will run Ruby 1.9.2 and Rails 3 for use by students without the attendant issues that accompany them when setting everything up on a Windows machine.
Ryan Bates has much of the details for the process used in his RailsCast on http://railscasts.com/episodes/292-virtual-machines-with-vagrant?view=asciicast but I used a packaged version of Ruby1.9.2 instead of his solution.
http://vagrantup.com/ and then ‘get started’ and ‘documentation’ as needed plus guides on specifics at
http://stackoverflow.com/questions/7859698/installing-ruby-1-9-2-on-ubuntu-using-chef-and-vagrant with details about different options for putting 1.9.2 on the vagrant box
http://www.capsunlock.net/2011/12/vagrant-productivity-developer-sysadmin.html on installing ruby package on box and notions of cookbook recipies
http://linux.about.com/od/ubuntu_doc/a/ubudg21t2.htm for installing .deb packages
https://gist.github.com/1349431 on setting up own box from scratch and packaging
Solution for now for us is this:
Build base box, add ruby 1.9.2, and then put on requisite gems and other software as needed for the term an then package this as a wad.box for use by the students. This could be just the tool to make the process easier for them (software works as expected) and us (less time spent configuring individual machines) so that everyone’s happier.
Vagrant Talk Notes from TechMeetup
This is a talk of three stories to show you how Vagrant can meet your needs in varying situations.
The first story: teach the ruby class twice a year with 70-100 students each term and they all need to install ruby, rails etc in order to do the class. 97% of them if not more use windows, which can be a pain for ruby and getting some gems to work correctly. As we have them using git on windows they pick up bits of unix commands along the way too, which is fine. As we can’t force them all to buy MBPs we can have them all use linux VMs though.. just need a way to make that install and running as easy as possible … enter Vagrant ‘da da da’ so now we ‘only’ need to set up JRuby and away we go.
a) there are only few basic commands to install, start/stop VM
b) shares a folder with your project so can develop in your own environment and just issue commands on headless vm and see your work in browser as normal after a bit of port forwarding from the VM.
c) makes set up (I hope) easier for all concerned and students can get up and running easier
d) students can then install onto windows full stack at their leisure when understand more of what they’re doing
The second story: you’re a developer working on windows but deploy to linux but many flavours and lots of ways to configure the box – wouldn’t it be nice to have local version of box with same software versioins that you could build your app on and know how it’s going to run on the production server?
a) tool for building apps in production environment instead of using your workstation and hoping for best
b) tool for building same vm that lots of people can locally install
c) tool written in ruby, (needs jruby on windows) but usable by all – don’t let the ruby stop you (similar to use of cucumber for BDD), which means you can build your Java, Haskell, Erlang or even PHP/Wordpress app on the VM with as much ease as you please.
d) makes use of vm easier as smoothes over continuity of command line
The third story: setting up a box for distribution is either hard, or not depending upon what your goal. If you want a script to build the perfect distro as an automated process, say to provision an EC2 instance, then that might be a bit trickier, but if you just want to build a single VM, and then package it for others to use, then that’s easy.
a) vagrant uses chef for setting up VMs when they start and installing software as determined by the config script.
You can make this as simple, or complicated as you like depending upon assumptions about what the person will do after the box has been started.
b) if you assume the person will want it automated, then things can be trickier and you may need to get your head around chef or puppet, which are provisioning tools that will take much of the pain out of this.
c) The easier route, if you just need a box for others to copy and use, is to start with a base box and put what you need in it, and then package it up for others to use and then put it where they can grab it to use.