Thursday, March 8, 2018

for loop example - for remote ssh

instead of mcollective:

for server in qtvr-els03  qtvr-els04  qtvr-els05  qtor-els601  qtor-els602  qtor-els603  qtvr-els005  qtvr-els0029 ; do ssh root@$server "hostname; /etc/init.d/elasticsearch status "; done


Or also
for server in `zoom --HF lpcluster=z2_elasticsearch_agent_manager_01 -f hostname`; do ssh $server 'echo $HOSTNAME'; done;



in another word:

for server in server1 server2 server3 ; do ssh root@$server "hostname; echo do something"; done


Very useful!