Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Net::OpenSSH::Parallel Options

by rgren925 (Beadle)
on Mar 25, 2022 at 21:45 UTC ( [id://11142424]=perlquestion: print w/replies, xml ) Need Help??

rgren925 has asked for the wisdom of the Perl Monks concerning the following question:

Hi

I have written some code using Net::OpenSSH and am now trying to use Net::OpenSSH::Parallel to more easily set up ssh sessions (for issuing commands and sending files) to many servers concurrently. I started down the path of using Parallel::ForkManager to do the Net::OpenSSH sessions but that was pretty cumbersome. Net::OpenSSH::Parallel is working perfectly but for one thing:

Net::OpenSSH has some options to eliminate stuff like login banners--using master_stderr_discard and master_stdout_discard--and I want to use them with the parallel version. They don't work directly (i.e., they generate an error when I try to use them with Net::OpenSSH::Parallel). I'm hoping that, since it is based on Net::OpenSSH, there may be a way to set them in Net::OpenSSH::Parallel.

Is that do-able and, if not, any recommendations?

Thanks very much. Rick.

Replies are listed 'Best First'.
Re: Net::OpenSSH::Parallel Options
by atcroft (Abbot) on Mar 25, 2022 at 22:08 UTC

    Are you trying to add them in the Net::OpenSSH::Parallel constructor (my $pssh = Net::OpenSSH::Parallel->new()) call? If so, take a look at the section on the 'add_host' method--specifically, it says, "[A]ny additional option will be passed verbatim to the Net::OpenSSH constructor later." So I suspect the following *MIGHT* work (*UNTESTED*):

    my $pssh = Net::OpenSSH::Parallel->new(); $pssh->add_host($_, master_stderr_discard => 1, master_stdout_discard => 1, ) for @hosts;

    Hope that helps.

      Wow! Thank you SO much! Don't know how I missed that. I guess that, since the options are passed on the constructor to Net::OpenSSH, I *assumed* (always a bad idea) that it would be the same here.

      It works great!
Re: Net::OpenSSH::Parallel Options
by etj (Deacon) on Apr 04, 2022 at 14:06 UTC
    In the spirit of using the best tool for the job, have you considered using Ansible for this task?

      I'm not convinced that Ansible is ready for production use yet. The best tool for the job might be Rex, however.


      🦛

        I think they're referring to ansible which is a rather widely used configuration management product (supported by RedHat), not a random CPAN module that happens to have the same name . . .

        Edit: community version docs.

        The cake is a lie.
        The cake is a lie.
        The cake is a lie.

        Is that the FUD it looks like?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11142424]
Approved by atcroft
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2024-03-29 10:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found