You've inspired me Jamis. How about the following...
task :group1 do
$group = 1
end
task :group2 do
$group = 2
end
task :group3 do
$group = 3
end
# Note, I have to use a global variable because the tasks can't see
local scope
task :deploy_war_group, :roles => :biz, :only => { :group => $group }
do
...
end
task :deploy_war, :roles => :biz do
end
# then i can control what group through command line
cap prod group1 deploy_war_group
cap prod group2 deploy_war_group
cap prod group3 deploy_war_group
cap prod deploy_war
I can then reuse these groupings for my view tier and cache servers,
etc.
Thanks,
Owen
On Aug 26, 1:01 pm, Jamis Buck <[EMAIL PROTECTED]> wrote:
> That approach certainly works. In fact, I think it's the simplest
> approach. There are others (involving programmatically identifying
> which servers are active in a group, and then restricting subsequent
> run() calls to those servers), but I'd recommend what you have. If
> you're worried about duplicating code inside each subtask, you can
> just define a function and call the function from each:
>
> def deploy_war_guts
> run(...)
> run(...)
> ...
> end
>
> 1.upto(3) do |group|
> task("deploy_war_group#{group}", :roles => :biz, :only =>
> { :group => group }) do
> deploy_war_guts
> end
> end
>
> - Jamis
>
> On Aug 26, 2008, at 12:52 PM, Owen wrote:
>
>
>
> > We've been using capistrano to manage our Java deployments using
> > tomcat and BigIP to control load balancing.
>
> > We need to deploy to groups within a role to avoid taking the whole
> > site out, but want to maintain the the complete list of servers for a
> > particular role. Is there a better way than the following to achieve
> > the desired effect?
>
> > role :biz, "biz1", "biz2", :group => 1
> > role :biz, "biz3", "biz4", :group => 2
> > role :biz, "biz5", "biz6", :group => 3
>
> > task :deploy_war_group1, :roles => :biz, :only => { :group => 1 } do
> > ...
> > end
>
> > task :deploy_war_group2, :roles => :biz, :only => { :group => 2 } do
> > ...
> > end
>
> > task :deploy_war_group3, :roles => :biz, :only => { :group => 3 } do
> > ...
> > end
>
> > task :deploy_war, :roles => :biz do
> > deploy_war_group1
> > deploy_war_group2
> > deploy_war_group2
> > end
>
> > Thanks.
>
> > >
>
>
> smime.p7s
> 3KViewDownload
--~--~---------~--~----~------------~-------~--~----~
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/capistrano
-~----------~----~----~----~------~----~------~--~---