{{tag>Brouillon}}
= Notes cluster shell parallèle
* clustershell (clush)
* clusterssh (cssh)
* mussh
== clush
apt-get install clustershell
# ou
pip install --user ClusterShell
''/etc/clustershell/groups''
all: host1 host2
**-a** pour "all"\\
**-B** pour affichage groupé de STDOUT et STDERR si retour identique
clush -a -B
clush -w lame[1-4] -B
clush -w lame[1-6] --diff dmidecode -s bios-version
--- lame[1-4] (4)
+++ lame[5-6] (2)
@@ -1 +1 @@
-I36
+I15
=== Clush copy
Exemple SosRepport
=== Exemple
Génération du sosreport sur les cibles
clush -B -O ssh_options='-oStrictHostKeyChecking=no -oPort=2222' -l root --hostfile targets.lst
sosreport -q --case-id 000000 --since 20230813000000 --batch
Récupération des sosreports
mkdir sosreports
clush -B -O ssh_options='-oStrictHostKeyChecking=no -oPort=2222' -l root --hostfile targets.lst --rcopy '/var/tmp/sosreport-*.tar.xz' --dest sosreports/
clush -B -O ssh_options='-oStrictHostKeyChecking=no -oPort=2222' -l root --hostfile targets.lst --rcopy '/var/tmp/sosreport-*.tar.xz.sha256' --dest sosreports/
Renommage
cd sosreports/
# rename -nv '*' '' *
rename '*' '' *
rename '-' '' *
Nettoyage
clush -B -O ssh_options='-oStrictHostKeyChecking=no -oPort=2222' -l root --hostfile targets.lst
rm -f /var/tmp/sosrepor*
=== List
clush -B --hostfile=hosts.lst
clush -B -O ssh_options='-oStrictHostKeyChecking=no -oPort=2222' -l admin --hostfile hosts.lst
=== Groupes
mkdir ~/.config/clustershell/
cp /etc/clustershell/groups.conf ~/.config/clustershell/
''~/.config/clustershell/groups.d/plop.yaml''
plop:
www: 'www[1-4]'
db: 'db-alpha,db-beta'
clush -B -g plop:www
clush -B -g plop:*
== mussh
mussh -H list.txt -b -c 'uptime'
mussh -H list.txt -b -C script.sh
mussh -m 7 -H ~/dev/list.txt -b -c 'apt-get -s dist-upgrade | grep "^[[:digit:]]\+ upgraded"'
== ClusterSSH cssh
sudo apt-get install clusterssh
cssh c2-bl1 c2-bl2 c2-bl3 c2-bl4 c2-bl5 c2-bl6
== sshpass
read SSHPASS
export SSHPASS
for ip in $(cat ip_all.lst) ; do sshpass -e ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=10 $ip /bin/true && echo $ip >> ip_ok.lst || echo $ip >> ip_nok.lst ;done
for ip in $(cat ip_ok.lst) ; do sshpass -e ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=10 $ip grep 192.168.1.253 /etc/resolv.conf && echo $ip >> dns_ok.lst || echo $ip >> dns_nok.lst ;done