Hi,

Is there anyway to reset a role?

What I want to do is read a list of IPs dynamically from a temporary
file, then run a task on a portion of the list at a time, not have the
task run on all the IP's directly in parallel. What I am trying to do
so far is to get the list, run the task on the first IP in the list,
sleep for 5 seconds and then run the task again on the next IP in the
list. Ideally, this would take 5 IPs at a time until all IPs are
executed, but I need to learn to crawl before I can walk ;)


task :test_cycle do
        transaction do
                set :j, 4
                set :k, 0
                $servers = IO.readlines(server_list)    # Get the list of 
servers from
temp file.
                while k < j
                                # This is a method to increment by one. 
Capistrano
                                # complains that "+" is an unknown method 
without this.
                    def add(value)
                        value = value + 1
                        return value
                    end

                    $ip = $servers[k].chomp

                            role :servers_each, $ip             # Set the
server_each role to the new IP

                            test_each                   # Run the task
                        set :k, add(k)                  # Increment k by 1.
                            role :servers_each, servers_each.clear
                       end
            end
end



desc "Test cycling through servers"
task :test_each, :roles => :servers_each do
        run "uptime"
        puts "Sleeping for 5 seconds"
        sleep 5
end


This works except for each time the loop is run, the next IP gets
added to the server_each role. This has the effect of re-running the
command on each server each time. So the first time it runs from 1
server. The next time, it runs on 2 servers, and so on.

How can I set server_each back to empty after running test_each and is
this even the a good way to do this?


Thanks in advance for you help!


--~--~---------~--~----~------------~-------~--~----~
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/capistrano
-~----------~----~----~----~------~----~------~--~---

Reply via email to