Versions:
- Ruby 1.8.7
- Capistrano v2.5.5
- Rake / Rails / etc
Platform:
I'm trying to write a task (to be called from a Perl script) that will work on any Linux host in my environment. However, since there is only one host that can SSH to every other host (it can also receive SSH connections from any host), and I can't guarantee that the task will be running on that host, I need to find a way to run the task on that host.
Here's what I came up with so far:
set :user, usr
cmd = "getpass " + user
set :password, `#{cmd}`
task :distribute, :on_error => :continue do
host_list = hosts.split(',')
servers = []
host_list.each do |n|
servers.push([n])
end
filelist=files.split(',')
filelist.each do |f|
upload f, target_dir, { :via => :scp, :hosts => servers, :on_error => :continue }
end
end
to be invoked like this:
/usr/bin/cap -f distribute_file.rb -S usr=user_to_run_as -s target_dir=/path/to/target -s files=/path/to/source_file -s hosts=(list of hosts) HOST=master_host
but that caused it to only run against master_host
So then I tried executing it with SSH, but that had a tendency to hang, plus it seemed to me like there should be a built-in method for this.
I'm a Perl guy and am new to both Ruby and capistrano, so please be gentle :)
Thanks.