Reputation: 1138
Is it possible to access the hostname
and user
of a role without using on
, so I don't have to nest the task below so ugly?
task :foo do
on roles(:web) do |host|
run_locally do
execute :rsync, '-avzr', "/foobar", "#{host.user}@#{host.hostname}:/foobar"
end
end
end
Upvotes: 2
Views: 2282
Reputation: 1138
Solved using Uri Agassi suggestion to use each
:
task :foo do
run_locally do
roles(:web).each do |host|
execute :rsync, '-avzr', "/foobar", "#{host.user}@#{host.hostname}:/foobar"
end
end
end
Upvotes: 5