Closed mperry2 closed 9 years ago
The code to do this is already in the latest version. Have a look in the man page for the external cluster command
Duncs
The man page says that external_cluster_command is for specifying a command that's run. Could you explain how it would be used in this instance? All I want to do is have cssh connect to hosts listed in any arbitrary text file.
Matt
You can have a Perl or shell script that looks at each @ARGV then looks for the file in the appropriate dir. If it exists, read the file and output the contents to stdout. If it doesn't exist just return the @ARGV entry
Something like:
foreach my $b (@ARGV){ if(-f "$HOME/etc/$b"){ my $hosts=slurp "$HOME/etc/$b"; print $hosts; } else { print $b } }
So the cluster name you provide would be the file containing the hosts
I have used this for looking up hosts from a CMDB instead of a static host file. The logic in the command can be whatever you need it to be, even looking up some cluster names in a DB, others from a generated file or wherever you have the data. You have the flexibility to look up clusters as you need
Let me know if that doesn't answer your question.
Not easy typing code on an iPhone :D
Duncs
Sent from my iPhone
On 3 Mar 2015, at 23:10, Matt Perry notifications@github.com wrote:
The man page says that external_cluster_command is for specifying a command that's run. Could you explain how it would be used in this instance? All I want to do is have cssh connect to hosts listed in any arbitrary text file.
— Reply to this email directly or view it on GitHub.
I often connect to groups of hosts whose membership is created from scripts and reports. Because the groups of hosts are dynamic, it doesn't make sense to put them into the .clusterssh/clusters file. I've gotten tired of typing
cssh $(cat hosts.txt)
and want something that's less work to type and will work with my bash completion.I'm going to add a feature to my local copy of ClusterSSH that will have it connect to a list of hosts in a text file (one host name per line). I'd be happy to submit a pull request if you're interested. If so, do you have a recommendation for the command line switches to use? I was planning on using
--hosts
and-H
(taking it away from the--man
option).