I’ve been busy at work lately… setting up a new patch process to include implementation, migration from our old, counter-intuitive system (apt on Red Hat servers, :|), so lots of registering systems with Spacewalk has been necessary (until we finish a Puppet module that is).
During our regularly scheduled patching, we have to do blocks of 80+ servers at a time once in a while. Until the module is done, it’s necessary to connect to all of them manually and run some commands. I’ve been using ClusterSSH for a little while now, and figured I’d share a quick script that will read a list of system names from a variable, then launch blocks of ClusterSSH windows (the number of windows also based on a variable).
Here it is, boring and not the greatest way to run commands on multiple systems, but it works in a bind…
PKG=clusterssh; if [ "$(rpm -qa | grep ${PKG})x" == "x" ]; then echo "$PKG is not installed, you should install it using your favorite package manager first."; exit 1 else echo "$PKG is installed, continuing"; fi SERVERS=''; COUNT=0; ATATIME=25 if [ $(rpm -qa | grep -q for i in $(awk '{print $1}' /tmp/asdf); do ((COUNT++)); SERVERS="${SERVERS} $i"; if [ $((${COUNT} % ${ATATIME})) -eq 0 ] ; then echo $SERVERS; cssh $SERVERS; SERVERS=''; fi; done