fabric: a good assistant for the development of WaterOnMars

wom-logo-128Despite spending currently more time using my WaterOnMars feed reader than developing it, I'm still making small improvements to it. And to make my life easier I could count on a solid little project: fabric ! fabric is a Python based command-line utility designed to help running commands remotely: typically to deploy a web app on a remote server. So I'm using it to deploy WaterOnMars on my personal server and also to deploy the demo version on heroku. But more recently I added fabric's configuration file (the "fabfile") to the sources of the project as an officially maintained helper for development tasks ((well I didn't think of it in such a formal way obviously)). It's now usable to run the test suite, to launch the web app locally, to set-up the db and to deploy it on custom servers. What I really like with fabric:fabric_logo
  • it's easily installable with pip, in a virtualenv if needed and bam! fabric's command line "fab" is immediately available on console
  • it's easily configurable with a single Python file
  • I had absolutely no problem in using it for remote actions ((credential prompts, log collection and console interaction are perfectly well handled))
  • it can also easily be used to define local commands
With all that, fabric makes a pretty good assistant for various development/deployment tasks related to WaterOnMars. So, to also provide some help to developers that may be interested in WaterOnMars, I did a little addition to the fabfile. It now looks up another configuration file called "fabhosts.cfg" where the servers to deploy to are defined along with the corresponding credentials. This way the fabfile and all its implemented actions can be committed to the sources while the fahosts.cfg and the credentials it contains are explicitly ignored by .gitignore. Here is an illustration of the fabhosts.cfg's format:
[{userA}@{hostX}]
site_dir = ~/path/to/wateronmars_site
virtual_env_dir = ../venv
final_deploy_action = touch /path/to/passenger/tmp/restart.txt
And more details are available in  WaterOnMars's fabfile.py of course.