diff --git a/cloud.production/cleanup.nomad.periodic.sh b/cloud.production/cleanup.nomad.periodic.sh new file mode 120000 index 0000000..2c3f5e5 --- /dev/null +++ b/cloud.production/cleanup.nomad.periodic.sh @@ -0,0 +1 @@ +../share/cleanup.nomad.periodic.sh \ No newline at end of file diff --git a/cloud.staging/cleanup.nomad.periodic.sh b/cloud.staging/cleanup.nomad.periodic.sh new file mode 120000 index 0000000..2c3f5e5 --- /dev/null +++ b/cloud.staging/cleanup.nomad.periodic.sh @@ -0,0 +1 @@ +../share/cleanup.nomad.periodic.sh \ No newline at end of file diff --git a/share/cleanup.nomad.periodic.sh b/share/cleanup.nomad.periodic.sh new file mode 100755 index 0000000..2fb60ce --- /dev/null +++ b/share/cleanup.nomad.periodic.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +set -euxo pipefail + +source vars.sh + +ips=( "${jump_ips[@]}" ) +for N in "${!ips[@]}"; +do + ip="${C}.${ips[$N]}" + cleanup_nomad_periodic $ip +done; diff --git a/share/lib.sh b/share/lib.sh index 9458fa6..70f2e7c 100644 --- a/share/lib.sh +++ b/share/lib.sh @@ -101,7 +101,8 @@ function patch () { local ip=$1 ssh -T -i ${ssh_key} "${user}@${ip}" << EOF set -euxo pipefail -sudo apt-get update && \ +export DEBIAN_FRONTEND=noninteractive +sudo apt-get -y upgrade -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" && \ sudo apt-get -y upgrade && \ sudo apt-get -y autoremove EOF @@ -301,6 +302,18 @@ fi; EOF } +function cleanup_nomad_periodic () { + # can be run on jump box with access to nomad binary + local ip=$1 + ssh -T -i ${ssh_key} "${user}@${ip}" << EOF +set -euxo pipefail +sudo apt-get install parallel +nomad job status | grep 'periodic-' awk '{print $1}' > jobs.txt +cat jobs.txt | parllel -j32 nomad stop -detach -purge +rm jobs.txt +EOF +} + function restart_nomad () { local ip=$1 ssh -T -i ${ssh_key} "${user}@${ip}" << EOF