Feed on
Posts
Comments

I love this fanout script for running the same command on multiple servers, just in case you’re interested:

http://www.stearns.org/fanout/fanout

[root@199564-6 scripts# fanout "$SERVERS" "cp /root/.ssh/authorized_keys /home/user/.ssh/"
Starting root@db1
Starting root@db2
Starting root@nas
Starting root@www1
Starting root@www2
Starting root@www3
Fanout executing "cp /root/.ssh/authorized_keys /home/user/.ssh/"
Start time Wed Dec 23 23:45:35 EST 2009 , End time Wed Dec 23 23:45:47 EST 2009
==== As root on db1 ====

==== As root on db2 ====

==== As root on nas ====

==== As root on www1 ====

==== As root on www2 ====

==== As root on www3 ====

Exiting fanout, cleaning up...done.

[root@199564-6 scripts# fanout "$SERVERSWWW" "/etc/init.d/httpd restart"
Starting root@www1
Starting root@www2
Starting root@www3
Fanout executing "/etc/init.d/httpd restart"
Start time Wed Dec 23 23:50:52 EST 2009 , End time Wed Dec 23 23:50:59 EST 2009
==== As root on www1 ====
Stopping httpd: [ OK
Starting httpd: [ OK

==== As root on www2 ====
Stopping httpd: [ OK
Starting httpd: [ OK

==== As root on www3 ====
Stopping httpd: [ OK
Starting httpd: [ OK

Exiting fanout, cleaning up...done.

[root@199564-6 scripts# echo $SERVERS
root@www1 root@www2 root@www3 root@db1 root@db2 root@nas
[root@199564-6 scripts# echo $SERVERSWWW
root@www1 root@www2 root@www3

A great way to execute the same commands on multiple servers… if you export the $SERVERS to a standard list, in your .bashrc or whatnot… it’s even easier. Of course, you’ll probably want to setup authorized_keys for your servers so that you don’t have to authenticate to each…

Leave a Reply

Bad Behavior has blocked 182 access attempts in the last 7 days.