Automagically remove/readd servers from EC2 load balancers as you cap deploy
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib use EC2 tags for what servers should be in ELB Jan 16, 2012
.gitignore Much nicer Apr 11, 2011
Gemfile Much nicer Apr 11, 2011 updated README Jan 16, 2012
Rakefile Much nicer Apr 11, 2011
capistrano-elb.gemspec restore link to latest fog Nov 11, 2011


A simple library to control Amazon Elastic Load Balancers for use within Capistrano

As of version 0.4.0 it looks for an 'elb' tag with value of the name of a loadbalancer to decide when to remove/readd servers.


gem install capistrano-elb


You should have ec2credentials.yaml in the same directory as your cap files

:aws_access_key_id: YOUR_KEY_ID_
:aws_secret_access_key: YOUR_KEY

then just

require "capistrano-elb/tasks"

This will instantiate an instance of the CapELB class and add hooks to remove/readd before/after deploys

(Equivalent to having the following in your deploy.rb)

require "capistrano-elb"

namespace :elb do
  capELB =

  task :remove do 
    servers = roles[:web] {|server|}
    puts "Removing #{servers} from ELB"
    capELB.remove servers

  task :add do 
    servers = roles[:web] {|server|}
    puts "Adding #{servers} to ELB"
    capELB.add servers

  task :check do 
    puts capELB.check_config

before "deploy", "elb:remove"
after "deploy", "elb:add"

You can just require capistrano-elb and do whatever you want inside your deploy scripts of course

If you want to hook after deploy but before the elb:add you can target after deploy:restart :your_task