summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2019-04-29 19:13:23 +0300
committerLars Wirzenius <liw@liw.fi>2019-04-29 19:13:23 +0300
commitf9ef7efd7e0d70fc9ba777304fa7bb17234e8543 (patch)
treee2b4bcbacf1b28658bf752836ef64b0a7c994271
parent2f9bcb0a8b0f042f16615aeb761a309a176755ff (diff)
downloadick2-ansible-f9ef7efd7e0d70fc9ba777304fa7bb17234e8543.tar.gz
Add: run-workers.shHEADmaster
-rwxr-xr-xrun-workers.sh52
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)" \
+ "$@"