# Multiple after\_deploys in deploy.rb

**URL:** <https://www.ruby-forum.com/t/multiple-after-deploys-in-deploy-rb/91610>\
**Category:** Rails\
**Created:** [April 10, 2007, 8:45pm UTC](https://www.ruby-forum.com/t/multiple-after-deploys-in-deploy-rb/91610 "2007-04-10T20:45:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Curtis\_Spencer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e495f1/32.png) [@Curtis\_Spencer](https://www.ruby-forum.com/u/Curtis_Spencer)\
**Post date:** [April 10, 2007, 8:45pm UTC](https://www.ruby-forum.com/t/multiple-after-deploys-in-deploy-rb/91610/1 "2007-04-10T20:45:01Z")

</div>

Hi,

I am using Capistrano to do a deploy to servers with different roles.  
I want call after\_deploy in the following manner.

task :after\_deploy, :roles =\> [:rolea] do  
run “task a”  
end

task :after\_deploy, :roles =\> [:roleb] do  
run “task b”  
end

The problem seems that the second after\_deploy clobbers the first even  
though they are meant for different roles. I do a workaround now by  
making role a use after\_symlink, but now I am adding a few more roles  
and I am running out of after\_\* to workaround. Is there a way to do the  
following

task :after\_deploy do  
if current\_server.role == :rolea  
run “task a”  
elsif current\_server.role == :roleb  
run “task b”  
end  
end

Thanks in advance for the help.

-Curtis
