Skip to content

Instantly share code, notes, and snippets.

@shawn111
Last active April 6, 2017 08:55
Show Gist options
  • Save shawn111/bbe03642d1a917913b3bbfc023464e80 to your computer and use it in GitHub Desktop.
Save shawn111/bbe03642d1a917913b3bbfc023464e80 to your computer and use it in GitHub Desktop.
Juju nodes might lost connection with juju agent. This script help us to restart those jujud.
#!/bin/sh
# https://pastebin.canonical.com/183117/
# # trusty
# for j in $(initctl list | awk '/jujud/ {print $1}'); do echo sudo restart $j; done
# # xenial
# for j in $(systemctl list-unit-files | awk '/jujud/ {print $1}'); do echo sudo systemctl restart $j; done
for i in $(juju status --format yaml| grep 'agent lost' | awk '{print $1}');
do
## for juju 1
#for i in $(juju status --format yaml | grep 'agent is lost' | awk '{print $9}');
#do
# i=${i:0:(-1)}
JUJUD_LIST=`juju ssh $i initctl list | awk '/jujud/ {print $1}'`
for JUJUD in $JUJUD_LIST; do
juju ssh $i sudo service $JUJUD restart
done
done
@shawn111
Copy link
Author

shawn111 commented Apr 4, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment