Wow, thanks for the quick response Jamis! I think i'll use option 1
but keep the masochistic method in my back pocket if need be.
--alp
On May 2, 1:16 pm, Jamis Buck <[EMAIL PROTECTED]> wrote:
> If it were me, I'd define each server in two roles, :server, and then
> either :even or :odd.
>
> %w(test01 test02 test03 test04).each_with_index do |host, index|
> which = (index+1) % 2 == 0 ? :even : :odd
> server(host, :server, which)
> end
>
> task :stop_odd, :roles => :odd do
> # ...
> end
>
> Alternatively, if you're masochistic ;) you can specify a proc as the
> value of the :hosts key, and return the servers you want that way.
> Something like this:
>
> %w(test01 test02 test03 test04).each_with_index do |host, index|
> role :server, host, :machine => index+1
> end
>
> select_odd_hosts = Proc.new do
> find_servers(:roles => :server).select { |s| s.options[:machine]
> % 2 == 1 }
> end
>
> task :stop_odd, :hosts => select_odd_hosts do
> # ...
> end
>
> - Jamis
>
> On May 2, 2008, at 2:00 PM, alpduhuez wrote:
>
>
>
> > Hello...
> > I'm new to Capistrano, love it so far, great tool. I am trying to
> > have more than one condition to select a task. I have lots of servers
> > and would like to deploy to them in groups of odd/even. Here is what
> > I am trying to do, is this possible with some syntax?
>
> > I have a server defined as:
> > role :server, "test01", :machine => 1
> > role :server, "test02", :machine => 2
> > role :server, "test03", :machine => 3
>
> > task :stop_odd, :roles => :server, :only => { :machine =>
> > 1, :machine => 3 , :machine => 5 } do
> > run "echo Hello, $HOSTNAME"
> > end
>
> > This way only the last entry is used. I also tried:
>
> > task :stop_odd, :roles => :server, :only => { :machine => 1
> > || :machine => 3 || :machine => 5 } do
> > run "echo Hello, $HOSTNAME"
> > end
>
> > I also tried expressions but that didn't work either. Is there some
> > way to do this?
>
> > Thanks!
--~--~---------~--~----~------------~-------~--~----~
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/capistrano
-~----------~----~----~----~------~----~------~--~---