This site is an archive; learn more about 8 years of OpenHatch.

[Devel] New way of building an OpenHatch development environment: please try it!

Asheesh Laroia asheesh at asheesh.org
Tue Jul 5 22:38:29 UTC 2011


I've been working on creating a virtual machine that sets up OpenHatch, so 
that it's easier for new contributors to get going. I'm succeeding, and 
I've gotten to the point where it's worthwhile for other people to look at 
it! I just pushed it to Gitorious.

First, a quick glossary:

puppet: a text-based language for describing the resources available on a 
machine

vagrant: a program that manages virtual machines, with a particular eye to 
web app development. http://vagrantup.com/

VirtualBox: A program that manages (and runs) virtual machines. Vagrant 
actually is a wrapper around VirtualBox.

VM, aka "Virtual machine": A computer and operating system emulated within 
another computer.

How to use Vagrant (and what it gives you)
------------------------------------------

If you have the latest version of the OpenHatch code, please do this:

0. Use git-clean to remove all unversioned files, or start with a fresh 
clone

This is necessary because the the the VM and your main machine will have 
conflicting ideas about what to store in the eggs/ etc. directories.

Run

   git status

to make sure there's nothing you want to keep. If that's true, run:

   git clean -x -d -f

BE CAREFUL! If you're unsure about running the above on your OpenHatch 
checkout, just do a fresh clone.

1. Install VirtualBox, if you don't already have it

(On a Debian/Ubuntu system, just do: "sudo apt-get install 
virtualbox-ose")

2. Install RubyGems

(On a Debian/Ubuntu system, just do: "sudo apt-get install rubygems")

3. Install Vagrant with 'gem':

   sudo gem install vagrant

4. In the OpenHatch directory, run:

   vagrant up

This will (very slowly) create a VM that has OpenHatch installed.

5. To SSH into the VM you created, run:

   vagrant ssh

6. To suspend the VM, for easy picking it up later:

   vagrant suspend

7. To bring the VM back to life:

   vagrant up

8. To destroy the VM, throwing away that operating system (you can always 
rebuild it later)

   vagrant destroy

The *really* neat thing is that you can still use "git" from your main 
machine -- the files are shared between the VM and your main machine. You 
can also use your regular old text editor; it's just the OpenHatch code 
*runs* in a VM.

Why I like this
---------------

Right now, if you run "buildout" and it fails on your system, you go onto 
IRC and see if you can find me, and then we'll both try really hard to 
debug an absurdly large complex stack of dependencies which normally 
operate great but routinely fail in random environments.

Instead of that, you could just have a virtual machine that we know works. 
Assuming you have about 1GB of free disk space, this simplifies things 
dramatically.

If you're familiar with the 'virtualenv' tool for isolating Python, this 
is the virtual environment to end all virtualenvs.

Vagrant has the mindset of disposable virtual machines, which I really 
like. The virtual machine's configuration is laid down in Puppet 
manifests. This means, basically, that if whatever service you need is not 
described in the Puppet manifests, then you will lose it when you 
"destroy" then "up". This provides the necessary incentive to actually 
describe things in the Puppet manifest.

I only added a few files to make this work:

* Vagrantfile
* puppet-provisioning-files/manifests/squeeze.pp
* puppet-provisioning-files/manifests/classes/openhatch_dependencies.pp
* puppet-provisioning-files/manifests/classes/openhatch_code.pp
* puppet-provisioning-files/manifests/classes/apt_get_update.pp

What work remains to be done
----------------------------

The Puppet configuration files should, really, be a bit longer. They are 
missing some crucial pieces:

* Configure MySQL within the VM so that './bin/mysite' can connect to it

* Setting up celery to run background tasks

* Setting up cron to run periodic background tasks

* Setting up Apache (maybe not necessary actually)

* Configuring Django and buildout so that emails that the dev server sends 
out are logged to a directory.

There are some niceties we could put in place:

* Automatically download and import a data snapshot

* Set up the bug tracker and wiki and forum (and any future apps) so that 
you have a very realistic simulation of the main server, and you can test 
out your patches to the services, too.

Why this took me so long
------------------------

(-:

I hit a whole bunch of snags getting this far. For example:

* Buildout would utterly fail on an Ubuntu virtual machine. Eventually I 
had the good idea of trying it on Debian, which works great. I spent a 
while yesterday banging my head against this.

* My computer would periodically turn off with a message like this:

   ERROR CRITICAL CPU TEMPERATURE 128 C SHUTTING DOWN

and then it would turn off.

What's next
-----------

I really want someone to try this and let me know what you think. 
Preferably multiple "someone"s!

You (dear reader) might also find the Vagrant tutorial instructive. I sure 
did. http://vagrantup.com/docs/getting-started/index.html

-- Asheesh.

-- 
Good day for a change of scene.  Repaper the bedroom wall.


More information about the Devel mailing list