Michael MacIsaac wrote:
> Does anyone have a simple wrapper around SSH to run the same command on
> multiple Linuxes?
Michael, I use rdist for this. With rdist, I have the ability:
1) send files to a list of hosts.
2) kick off commands to that list of hosts, can even have particular
files transfered trigger specific commands for each specific file.
3) output to standard out
4) output to standard out & email (separate email for each receiving host)
Here's how I do it:
First create an rdist template, let's call it fixes.rdist for example:
---- fixes.rdist ---- snip here
HOSTS = (
linux01
linux02
linux03
linux04
linux05
)
FILES = (
/etc/issue
/etc/issue.net
/etc/motd
/root/samplescript.sh
)
${FILES} -> ${HOSTS}
install;
special /root/samplescript.sh "/etc/init.d/appname stop";
special /root/samplescript.sh "bash -x /root/samplescript.sh";
special /root/samplescript.sh "/etc/init.d/appname start";
notify [EMAIL PROTECTED];
---- fixes.rdist ---- end snip here
Then I run the command on the main host:
rdist -F -o compare,remove -P /usr/bin/ssh -f /root/fixes.rdist
Now for this to work, you need to have your hosts setup for
passphraseless ssh access using ssh keys (or cache your passphrase with
ssh-agent), and the hosts have to allow root login via ssh (but limit it
to requiring an ssh key instead of a unix password!). Then, ssh into
all the hosts with a for loop, so that way all the hosts key finger
prints end up in your .ssh/known_hosts2 file. Then you're ready for
that rdist command.
It will copy /etc/issue, /etc/issue.net, /etc/motd, and
/root/samplescript.sh to the listed hosts... Then, for each "special"
line that references a file, when that file's copy is done, the
following command will be run on the remote host.
Also, notice I included the "compare" option to rdist. This makes it
behave like rsync, transferring only the delta of the files you
specified in the rdist template, saving bandwidth if your updating
existing files. Also, I specified "remove". This is like rsync's
--delete option. So if you listed a directory tree in FILES, it would
copy over the entire tree, and remove any files on the destination not
on the originating host. Use that option carefully.
It's handy for distributing standard updates to systems. If I have
cookie cutter systems, I can update the primary to a service pack, for
example, and then use this method to fully update it's clones, then have
it kick off mkinitrd, zipl, and a reboot of the clones. :)
*Brandon Darbro
----------------------------------------------------------------------
For LINUX-390 subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: INFO LINUX-390 or visit
http://www.marist.edu/htbin/wlvindex?LINUX-390