Clustershell

Define node groups

  • Edit /etc/clustershell/groups
node_all: cluster-node[001-999].somewhere.in-the.net

Run a command on all nodes

clush -w @node_all "my_command with_params"

Iterate over nodes

for NODE in $(nodeset -e @node_all); do scp some_file root@$NODE:~/; done

Diff results

clush -w @node_all --diff "dmidecode -s bios-version"

Combine results

clush -w @node_all -b "uname -a"

Copy file

clush -v -w @node_all --copy a_file

Retrieve a file

  • Will create files like id_rsa.node001
clush -v -w @node_all --rcopy /root/.ssh/id_rsa

Clush.conf

  • Need ssh password auth? Install sshpass and edit /etc/custershell/clush.conf
ssh_user: root
ssh_path: /usr/bin/sshpass -p "password"
ssh_options: -oStrictHostKeyChecking=no
  • Need to limit number of connection or connection / command timeouts?
fanout: 256
connect_timeout: 15
command_timeout: 0

Scripting in Python

from ClusterShell.Task import task_self, NodeSet

task = task_self()
task.run("/bin/uname -r", nodes="mynode[001-123]")

for output, nodes in task.iter_buffers():
    print NodeSet.fromlist(nodes), output