• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Fabric:  A Capistrano Alternative

Fabric: A Capistrano Alternative



Fabric: A lightweight deployment tool for Rubyists and Pythonists alike

Fabric: A lightweight deployment tool for Rubyists and Pythonists alike



Total Views
Views on SlideShare
Embed Views



14 Embeds 11,629

http://leone.panopticdev.com 11164
http://rirug.com 334
http://note.harajuku-tech.org 49
http://translate.googleusercontent.com 29
http://harajuku-tech.posterous.com 22
http://7781964911499645745_73fcfa2288a103bf59aad4aec7f7296adcc6dc5a.blogspot.com 6
http://feeds.feedburner.com 6 5
https://twitter.com 4
http://webcache.googleusercontent.com 3
http://blog.mikeleone.com 3
http://paper.li 2
http://twitter.com 1
http://www.howtogeek.com 1



Upload Details

Uploaded via as OpenOffice

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

    Fabric:  A Capistrano Alternative Fabric: A Capistrano Alternative Presentation Transcript

    • Fabric - A Lightweight Deployment Tool for Rubyists and Pythonists Alike
      • Mike Leone - Panoptic Development, Inc
    • Why Fabric?
      • Capistrano is elegant, powerful, extensible
      • but...
      • Too many features for small, simple projects
      • If you're using a DSL, the implementation language isn't so important
      • If you know Ruby, you already know enough Python for a simple fabric script!
      • Can you teach a Rubyist how Capistrano works in 3 minutes?
      • Probably not!
      • Makes assumptions about your version control system
      • Release directory structure
      • The way your server restarts
      • In typical Ruby fashion, there's lots of ”magic”
    • Fabric is two things
      • API for streamlining the use of SSH for app deployment or sys admin tasks
      • Command-line interface for calling Python methods
    • Example $ fab free_space
    • Write a deploy script in 3 minutes
      • We want a script that will:
      • test our code
      • deploy it to our server in the /mnt directory
      • restart the web server
    • Install Fabric
        $ sudo apt-get install python-setuptools $ sudo easy_install fabric
    • Add Fabric to your Ruby App
        $ cd my/awsome/rails_app $ touch fabfile.py
    • Three Lines of Boilerplate
        from fabric.api import * env.hosts = ['myserver.com'] env.user = ”mike”
    • Run the tests
        def test(): local('rake spec')
      • If tests fail, deployment will stop
    • Send your App Code Over
        def pack_code(): local('tar czf /tmp/latest.tgz') def upload_code(): put('/tmp/latest.tgz', '/tmp/') with cd('/mnt/rails_app'): run('tar xzf /tmp/latest.tgz')
    • Restart the Web Server
        def restart(): sudo('/etc/init.d/apache2 restart')
    • Put it all Together
        def deploy(): test() pack_code() upload_code() restart()
    • Your new Deploy Script
    • Deploy!
        $ fab deploy
    • Deploy your Release Branch
        $ git checkout my-release-branch $ fab deploy
    • Advantages
      • Don't have to include branch, repository info
      • Use any release directory structure you want
      • Someone knowing nothing about deployment tools can look at your script and understand exactly what's going on
    • Further Reading
      • Fabric documentation:
      • http://docs.fabfile.org/0.9.1/
      • My Company Website and Blog:
        • http://panopticdev.com