Skip to content

Instantly share code, notes, and snippets.

@ThinGuy
Created November 12, 2018 17:02
Show Gist options
  • Save ThinGuy/4657cc1c691cfec043f1a08df21e4f09 to your computer and use it in GitHub Desktop.
Save ThinGuy/4657cc1c691cfec043f1a08df21e4f09 to your computer and use it in GitHub Desktop.
Run commands in parallel on deployed machines
# Run dist-upgrade all deployed machines running ubuntu
(maas admin machines read|jq -r '.[]|select((.status==6) and .osystem=="ubuntu").hostname')|\
xargs -n1 -P0 bash -c 'ssh $0 "sudo 2>/dev/null bash -c '"'"'apt update;apt dist-upgrade -y;apt autoremove -y'"'"'"'
# Run dist-upgrade all deployed machines running ubuntu with a certain tag
# To see list of tags, run: maas admin tags read|jq -r '.[].name'
(maas admin tag machines ${TAG}|jq -r '.[]|select((.status==6) and .osystem=="ubuntu").hostname')|\
xargs -n1 -P0 bash -c 'ssh $0 "sudo 2>/dev/null bash -c '"'"'apt update;apt dist-upgrade -y;apt autoremove -y'"'"'"'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment