Artificial intelligent assistant

GNU Parallel and sshpass with server list in a loop With this loop we sequential update on all servers (server list = `consul members | grep awk {'print $2'} | cut -d ":" -f1`) the package `consul`. for i in $(consul members | grep awk {'print $2'} | cut -d ":" -f1) ; do sshpass -p $PASSWORD ssh -oStrictHostKeyChecking=no -q root@$i "hostname && yum clean all && yum -y update consul && systemctl restart consul.service" ; done We have over 1000 servers, so we wish to run the `sshpass` in parallel on 10 servers. I found GNU Parallel for this task. Howo use it with `sshpass` and make sure no server (server list) is done twice?

Indeed, `pssh` sounds like the better solution. If you must use `parallel` it should be fairly simple: pipe the hostnames one per line into a single command that uses `{}` as a placehold. Eg:


consul members | ... awk {'print $2'} | cut -d ":" -f1 |
parallel -j 10 sshpass -p "$PASSWORD" ssh -oStrictHostKeyChecking=no -q root@{} "hostname && yum clean all && yum -y update consul && systemctl restart consul.service"


Using `sshpass` should not make any difference. Test it first with a simple command such as just `hostname`.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy abd9e050ad09191f9b6c08aee036471a