From e96f3a688ef60b737d93c1650048d1344b76c991 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Thu, 13 Sep 2018 18:19:40 +0300 Subject: Change: split workers off main playbook --- ci-prep.hz | 5 +++++ ci-prod-workers.hz | 6 ++++++ ci-prod.hz | 6 ++++++ demo-workers.hz | 6 ++++++ demo.hz | 6 ++++++ group_vars/ickhost.yml | 4 +--- ick-cluster.yml | 11 ----------- ick-workers.yml | 10 ++++++++++ ickdev.hz | 6 ++++++ ickweb.hz | 5 +++++ run-workers.sh | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++ 11 files changed, 103 insertions(+), 14 deletions(-) create mode 100644 ci-prep.hz create mode 100644 ci-prod-workers.hz create mode 100644 ci-prod.hz create mode 100644 demo-workers.hz create mode 100644 demo.hz create mode 100644 ick-workers.yml create mode 100644 ickdev.hz create mode 100644 ickweb.hz create mode 100755 run-workers.sh diff --git a/ci-prep.hz b/ci-prep.hz new file mode 100644 index 0000000..3b86c64 --- /dev/null +++ b/ci-prep.hz @@ -0,0 +1,5 @@ +defaults: + type: cx31 + image: debian-9 +hosts: + - name: ick diff --git a/ci-prod-workers.hz b/ci-prod-workers.hz new file mode 100644 index 0000000..abd0f8f --- /dev/null +++ b/ci-prod-workers.hz @@ -0,0 +1,6 @@ +defaults: + type: cx11 + image: debian-9 +hosts: + - name: worker1 + - name: worker2 diff --git a/ci-prod.hz b/ci-prod.hz new file mode 100644 index 0000000..cfb74b9 --- /dev/null +++ b/ci-prod.hz @@ -0,0 +1,6 @@ +defaults: + type: cx11 + image: debian-9 +hosts: + - name: controller + type: cx21 diff --git a/demo-workers.hz b/demo-workers.hz new file mode 100644 index 0000000..abd0f8f --- /dev/null +++ b/demo-workers.hz @@ -0,0 +1,6 @@ +defaults: + type: cx11 + image: debian-9 +hosts: + - name: worker1 + - name: worker2 diff --git a/demo.hz b/demo.hz new file mode 100644 index 0000000..cfb74b9 --- /dev/null +++ b/demo.hz @@ -0,0 +1,6 @@ +defaults: + type: cx11 + image: debian-9 +hosts: + - name: controller + type: cx21 diff --git a/group_vars/ickhost.yml b/group_vars/ickhost.yml index a92b3a2..c46c6b6 100644 --- a/group_vars/ickhost.yml +++ b/group_vars/ickhost.yml @@ -10,10 +10,8 @@ ci_prefix: "" sources_lists: - repo: "deb http://deb.debian.org/debian stretch-backports main" - repo: "deb http://code.liw.fi/debian stretch main ickhost" - keyring_package: code.liw.fi-keyring signing_key: "{{ code_liw_fi_signing_key }}" - - repo: "deb http://ick-controller.h.qvarnlabs.eu/debian stretch-ci main" - signing_key: "{{ ql_ick_apt_signing_key }}" + - repo: "deb http://code.liw.fi/debian stretch-ci main ickhost" controller_port: 12765 artifact_store_port: 12766 diff --git a/ick-cluster.yml b/ick-cluster.yml index fb8fa7f..d23a82c 100644 --- a/ick-cluster.yml +++ b/ick-cluster.yml @@ -1,14 +1,3 @@ -- hosts: workers - remote_user: root - become: yes - roles: - - sane_debian_system - - comfortable - - unix_users - - ick-worker - vars: - verify_tls: yes - - hosts: ick remote_user: root become: yes diff --git a/ick-workers.yml b/ick-workers.yml new file mode 100644 index 0000000..9cda47c --- /dev/null +++ b/ick-workers.yml @@ -0,0 +1,10 @@ +- hosts: workers + remote_user: root + become: yes + roles: + - sane_debian_system + - comfortable + - unix_users + - ick-worker + vars: + verify_tls: yes diff --git a/ickdev.hz b/ickdev.hz new file mode 100644 index 0000000..18742b3 --- /dev/null +++ b/ickdev.hz @@ -0,0 +1,6 @@ +defaults: + type: cx11 + image: debian-9 +hosts: + - name: ick + type: cx51 diff --git a/ickweb.hz b/ickweb.hz new file mode 100644 index 0000000..0f8c8f5 --- /dev/null +++ b/ickweb.hz @@ -0,0 +1,5 @@ +defaults: + type: cx11 + image: debian-9 +hosts: + - name: demo 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)" \ + "$@" -- cgit v1.2.1