running single command on multiple servers
I need the ability to (1) copy a single file to multiple servers. (2) run a single command on multiple servers. I found an application called pssh in the epel repository that works, but I do not have access to this repository on my prod network, but do have access to it on the dev network.
Is there a way to copy this application and install it without the use of a repository, or is there another application that provides the same function in the std rhel repoistories?
thank you
Responses
Hi Andy,
At the basic level this could be done by using a script or in simple terms using a for loop in shell. I presume that you know about this and your query is in a different context. What is your requirement for running commands on multiple servers?
If your prod and dev environments are similar then you could run 'yumdownloader' to download required packages and then move then wherever it is required where there is no network access. Install 'yum-utils' to get this command if not installed.
Consider the use of Ansible (does not have to be Ansible Tower, but flat regular Ansible) see http://docs.ansible.com. Ansible is included in Red Hat you do not have to pay for Ansible Tower which is just a "wrapper" around regular Ansible (a nice wrapper, but a wrapper).
You can deal with multiple servers using Ansible using ssh keys and sudo (if set up on all systems you use).
Regards, RJ
Another use the enhanced terminal program named "terminator" which has nothing to do with the obvious science fiction movie, but instead is a useful ... enhanced terminal program that allows you to open one enhanced "terminator" terminal, and separate into panes multiple terminals. You can then make groups to "broadcast" commands to some or all of the groups you've established using these instructions in this link. And here is the man page for terminator at https://linux.die.net/man/1/terminator
Measure twice, cut once, use caution when using broadcast, really.
Regards,
RJ
Hi RJ,
Although it doesn't exactly fit into this discussion, but as you mentioned Terminator, I'd like to show you a great alternative : Tilix is my terminal of choice. You may want to give it a try. Oh, and Ansible is a good suggestion. :)
Regards,
Christian
An option that I use often for this purpose is 'multixterm'. e.g. multixterm -xc "ssh %n" server1 server2 server3 server4
This command comes with 'expectk' (Expect Tk), and is part of the standard RHEL repos.
All of these are good options.
Andy, You could download your own copy of EPEL (it would take a while) and present it locally... I bring that up in case your 100 or so systems are behind some network that can't normally see the public internet. Or... perhaps if you have one system that can be an intermediary and host it there... or be a proxy.
Can your 100 or so systems see any of the mirrors for EPEL? https://admin.fedoraproject.org/mirrormanager/mirrors/EPEL
Any of these have advantages and disadvantages. Now the idea behind Ansible (again, not Ansible Tower) is that it is gaining lots of traction and is being widely adopted. We patch entire networks with literally hundreds of systems using Ansible. We push configurations, scripts and more with one command traversing some all or even one system using Ansible (not tower). Ansible can be set up with sane group names where you identify rational groupings of your systems.
However, the other options I and others produced above are good options as well
Regards,
RJ
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
