月曜日, 2月 15, 2010

Keeping capistrano in check: ensuring roles are respected in sub-tasks

Keeping capistrano in check: ensuring roles are respected in sub-tasks

def with_role(role, &block)
original, ENV['HOSTS'] = ENV['HOSTS'], find_servers(:roles =>role).map{|d| d.host}.join(",")
begin
yield
ensure
ENV['HOSTS'] = original
end
end


Capistranoで上位タスクと同じホストを強引に処理対象とする

Re: Identify current host
task :bootstrap, :roles => :master do
servers = find_servers_for_task(current_task)
servers.each do |server|
puts "host: #{server.host}"
end
end



Callbacks and roles
  task :my_custom_task, :roles => :role2 do
servers = find_servers_for_task(current_task) & roles[:role2].servers
run "whatever", :hosts => servers if servers.any?
end



Capistrano で rsync

Capistranoであえて非並列にコマンド実行する


Capistrano

0 件のコメント: