I'd drop Capistrano and use SSHKit, the underlying driver in Capistrano v3
(your example is v2) - see
https://github.com/capistrano/sshkit/blob/master/EXAMPLES.md#upload-a-file-from-disk
and
https://github.com/capistrano/sshkit/blob/master/EXAMPLES.md#using-with-rake

Combine those two to recreate what you have above, and mix in some
https://github.com/capistrano/sshkit#tunneling-and-other-related-ssh-themes
to make sure that you can reach the hosts as you need to, and I think
you'll be fine.

SSH is probably hanging because your process is hanging onto some
resources, that can often be solved by tunneling and/or remotely starting
thigns with `ssh me@thehost 'thecommand'`, for example. Hard to say without
more info.

But, I'd absolutely avoid using Cap v2 if you're starting out, it's more
than two years since EOL, but very widely documented/blogged about in the
net.

Lee Hambley
http://lee.hambley.name/
+49 (0) 170 298 5667

On 1 June 2015 at 21:07, Steve Wechsler <swechs...@gmail.com> wrote:

> Versions:
>
>    - Ruby 1.8.7
>    - Capistrano v2.5.5
>    - Rake / Rails / etc
>
> Platform:
>
>    - CentOS/Red Hat
>
>
> 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.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Capistrano" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to capistrano+unsubscr...@googlegroups.com.
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/capistrano/5014b7b3-78f4-44ed-9099-6fce08743222%40googlegroups.com
> <https://groups.google.com/d/msgid/capistrano/5014b7b3-78f4-44ed-9099-6fce08743222%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Capistrano" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to capistrano+unsubscr...@googlegroups.com.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/capistrano/CAN_%2BVLVYF40sCNDpeaSFzj%2BiHuf833h95CMG4_3PhYLZaPkmXQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to