Blog Logo
  • Home
  • About

Deploying with Fabric and Subversion

by Drew Engelson — 03 Feb 2009

Here's a sample fabfile for deploying to production and staging systems directly from Subversion.

def production():
    config.fab_hosts = ['server1.example.com', 'server2.example.com']
    config.app_path = '/path/to/app/'

 def staging():
    config.fab_hosts = ['staging.example.com']
    config.app_path = '/path/to/app/'

 def svn_update():
    "Updates the repository."
    sudo("cd $(app_path); svn up")

 def reboot():
    "Reboot Apache2 server."
    sudo("/usr/sbin/apachectl restart")

 def update():
    require('fab_hosts', provided_by=[production])
    invoke(svn_update)

 def deploy():
    require('fab_hosts', provided_by=[production])
    invoke(svn_update)
    invoke(reboot)

Now, deploying is easy. After committing my changes to Subversion, I simply instantiate:

$ fab production deploy

This is equivalent to:

$ fab production update reboot
Drew Engelson
Author

Drew Engelson

https://tomatohater.com

I currently lead the Cloud Foundation Services team at Starbucks. We are building the Starbucks PaaS to allow digital platforms to be deployed globally with a focus on automation, scalability, performance, security, and developer experience.

Prior to Starbucks, I led Celerity's Technology Innovation and Architecture practice and founded Zoombit and served in technology leadership at Huge and PBS.

Yes. I seriously hate tomatoes.

All content copyright Tomatohater © 2006-2021 • All rights reserved.
No ResultWebsite Carbon