diff options
author | Lars Wirzenius <liw@liw.fi> | 2019-04-29 19:13:23 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2019-04-29 19:13:23 +0300 |
commit | f9ef7efd7e0d70fc9ba777304fa7bb17234e8543 (patch) | |
tree | e2b4bcbacf1b28658bf752836ef64b0a7c994271 | |
parent | 2f9bcb0a8b0f042f16615aeb761a309a176755ff (diff) | |
download | ick2-ansible-f9ef7efd7e0d70fc9ba777304fa7bb17234e8543.tar.gz |
Add: run-workers.sh
-rwxr-xr-x | run-workers.sh | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/run-workers.sh b/run-workers.sh new file mode 100755 index 0000000..0332027 --- /dev/null +++ b/run-workers.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +set -eu + + +getaddr() +{ + awk -v "name=$1" '$1 == name { print $2 }' "$hosts_in" | + sed 's/ansible_ssh_host=//' +} + + +count_workers() +{ + grep -Ec '^worker[[:digit:]]+' "$1" +} + + +mkhosts() +{ + local n="$1" + for i in $(seq "$n") + do + echo "worker$i hostname=worker$i ansible_ssh_host=$(getaddr worker$i)" + done + echo + + echo "[ickhost]" + for i in $(seq "$n") + do + echo "worker$i" + done + echo + + echo "[workers]" + for i in $(seq "$n") + do + echo "worker$i" + done +} + +hosts_in="$1" +controller_domain="$2" +apt_domain="$controller_domain" +shift 2 + +nw="$(count_workers "$hosts_in")" +mkhosts "$nw" > hosts.tmp +ansible-playbook -i hosts.tmp ick-workers.yml \ + -e "controller_domain=$controller_domain" \ + -e "apt_domain=$apt_domain)" \ + "$@" |