At some point you will find it very handy to be able to run the same command on multiple servers. Sure, you could just put a list of IPs in a file and run something against it using a for loop, but gsh is going to make your life much easier.
First off, i've used the old 'list of ips' way in the past - especially if I have an easy list of servers that are all the same and know that I want to group them all together. gsh, on the other hand, will allow you to run the same command on various servers sorted by category, similar to ansible.
You still need to maintain a list of your servers, but it's worth it. Also, you'll want to have ssh keys set up on each of the servers from your 'gsh-server'.
Some examples
Want to check the openssh version on each of your cent6 and cent7 machines?
How about uptime on all of your VPS?
How about uptime on all of just the cent6 vps machines?
An example /etc/ghosts file
Each installation of gsh requires a valid /etc/ghosts file (yes.. you can pronounce it "gee hosts"). Here's an example one which ties in our examples from above:
Download / Install it
You can download gsh from here:
http://outflux.net/unix/software/gsh/
Once you unpack it and cd into its directory, you can install it with:
Then, Start your /etc/ghosts file. You can have as many categories as you like. Some popular ones can be location / dc, os, hardware, etc..
Have fun with it - and let us know how it goes!
First off, i've used the old 'list of ips' way in the past - especially if I have an easy list of servers that are all the same and know that I want to group them all together. gsh, on the other hand, will allow you to run the same command on various servers sorted by category, similar to ansible.
You still need to maintain a list of your servers, but it's worth it. Also, you'll want to have ssh keys set up on each of the servers from your 'gsh-server'.
Some examples
Want to check the openssh version on each of your cent6 and cent7 machines?
Code:
gsh cent6+cent7 "rpm -q openssh"
How about uptime on all of your VPS?
Code:
gsh vps "uptime"
How about uptime on all of just the cent6 vps machines?
Code:
gsh vps^cent7 "uptime"
An example /etc/ghosts file
Each installation of gsh requires a valid /etc/ghosts file (yes.. you can pronounce it "gee hosts"). Here's an example one which ties in our examples from above:
Code:
# Hostname Hardware OS
abc.linuxforum.com vps cent6
def.linuxforum.com vps cent7
ghi.linuxforum.com metal cent6
Download / Install it
You can download gsh from here:
http://outflux.net/unix/software/gsh/
Once you unpack it and cd into its directory, you can install it with:
Code:
perl Makefile.PL
make
make install
Then, Start your /etc/ghosts file. You can have as many categories as you like. Some popular ones can be location / dc, os, hardware, etc..
Have fun with it - and let us know how it goes!