This efinitely uses magic. we're not sure if this will work in future versions of Capistrano, but changing it should be relatively simple.
def serial_task(name, options = {}, &block) servers = self.roles[options[:roles]].collect {|server| server.host} task_syms = [] servers.each do |hostname| role_sym = "_serial_task_#{name.to_s}_#{hostname}".to_sym task_sym = "_do_task_#{name.to_s}_#{hostname}".to_sym task_syms << task_sym role role_sym, hostname task task_sym, :roles => role_sym, &block end task name do task_syms.each do |t| self.send t end end end
Here is an example. Note the syntax is just the same as Capistrano's "task".
serial_task :pwd, :roles => web do run "pwd" end