From 9d9d4fdc70ec0ac276f3795f5ccea39d6b94b995 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Thu, 23 Apr 2020 04:59:13 +0200 Subject: further cleanup host bootstraping --- chaos-at-home/ch-gw-lan.yml | 7 ------- chaos-at-home/ch-router-obsd.yml | 7 ------- chaos-at-home/ch-testvm.yml | 7 ------- chaos-at-home/common.yml | 7 +++++++ chaos-at-home/r3-cccamp19-feedcode.yml | 7 ------- common/cloud-install.yml | 8 +++++++- common/utils.sh | 4 ++-- common/vm-install.yml | 8 +++++++- dan/common.yml | 7 +++++++ dan/emc-00.yml | 11 ----------- dan/emc-01.yml | 11 ----------- dan/emc-02.yml | 11 ----------- dan/emc-03.yml | 11 ----------- dan/emc-dist.yml | 7 ------- dan/emc-dist0.yml | 7 ------- dan/emc-xx.yml | 2 +- dan/sk-testvm.yml | 7 ------- install.sh | 8 +++++++- inventory/group_vars/emc-dist.yml | 21 -------------------- inventory/group_vars/emc-xx/main.yml | 22 ++------------------- inventory/group_vars/emc/main.yml | 21 +++++++++++++++++++- inventory/group_vars/lendwirbel-live-xx/main.yml | 5 +++++ inventory/group_vars/lendwirbel-live/main.yml | 23 ++++++++++++++++++++++ inventory/hosts.ini | 17 ++++++++++++++++ roles/cloud/install/tasks/hcloud.yml | 2 +- roles/cloud/install/tasks/hroot.yml | 2 +- .../install/templates/hetzner_installimage.conf.j2 | 2 +- spreadspace/common.yml | 7 +++++++ spreadspace/group_vars/lendwirbel-live.yml | 10 ++++++++++ spreadspace/lendwirbel-live-xx.yml | 11 +++++++++++ 30 files changed, 136 insertions(+), 144 deletions(-) delete mode 100644 chaos-at-home/ch-gw-lan.yml delete mode 100644 chaos-at-home/ch-router-obsd.yml delete mode 100644 chaos-at-home/ch-testvm.yml create mode 100644 chaos-at-home/common.yml delete mode 100644 chaos-at-home/r3-cccamp19-feedcode.yml create mode 100644 dan/common.yml delete mode 100644 dan/emc-00.yml delete mode 100644 dan/emc-01.yml delete mode 100644 dan/emc-02.yml delete mode 100644 dan/emc-03.yml delete mode 100644 dan/emc-dist.yml delete mode 100644 dan/emc-dist0.yml delete mode 100644 dan/sk-testvm.yml delete mode 100644 inventory/group_vars/emc-dist.yml create mode 100644 inventory/group_vars/lendwirbel-live-xx/main.yml create mode 100644 inventory/group_vars/lendwirbel-live/main.yml create mode 100644 spreadspace/common.yml create mode 100644 spreadspace/group_vars/lendwirbel-live.yml create mode 100644 spreadspace/lendwirbel-live-xx.yml diff --git a/chaos-at-home/ch-gw-lan.yml b/chaos-at-home/ch-gw-lan.yml deleted file mode 100644 index a1d81d88..00000000 --- a/chaos-at-home/ch-gw-lan.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- -- name: Basic Setup - hosts: ch-gw-lan - roles: - - role: base - - role: sshd - - role: zsh diff --git a/chaos-at-home/ch-router-obsd.yml b/chaos-at-home/ch-router-obsd.yml deleted file mode 100644 index 76b79316..00000000 --- a/chaos-at-home/ch-router-obsd.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- -- name: Basic Setup - hosts: ch-router-obsd - roles: - - role: base - - role: sshd - - role: zsh diff --git a/chaos-at-home/ch-testvm.yml b/chaos-at-home/ch-testvm.yml deleted file mode 100644 index c10c8b57..00000000 --- a/chaos-at-home/ch-testvm.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- -- name: Basic Setup - hosts: ch-testvm - roles: - - role: base - - role: sshd - - role: zsh diff --git a/chaos-at-home/common.yml b/chaos-at-home/common.yml new file mode 100644 index 00000000..494f434f --- /dev/null +++ b/chaos-at-home/common.yml @@ -0,0 +1,7 @@ +--- +- name: Basic Setup + hosts: "{{ install_hostname }}" + roles: + - role: base + - role: sshd + - role: zsh diff --git a/chaos-at-home/r3-cccamp19-feedcode.yml b/chaos-at-home/r3-cccamp19-feedcode.yml deleted file mode 100644 index 65485be7..00000000 --- a/chaos-at-home/r3-cccamp19-feedcode.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- -- name: Basic Setup - hosts: r3-cccamp19-feedcode - roles: - - role: base - - role: sshd - - role: zsh diff --git a/common/cloud-install.yml b/common/cloud-install.yml index 57ebc9e6..e21d4bf1 100644 --- a/common/cloud-install.yml +++ b/common/cloud-install.yml @@ -29,7 +29,13 @@ roles: - role: cloud/post-install -- import_playbook: "../{{ install_environment }}/{{ hostvars[install_hostname].install_playbook | default(install_hostname) }}.yml" +- name: run host playbook + vars: + params: + files: + - "../{{ install_environment }}/{{ install_hostname }}.yml" + - "../{{ install_environment }}/{{ install_playbook | default('common') }}.yml" + import_playbook: "{{ q('first_found', params) | first }}" - name: reboot and wait for machine come back hosts: "{{ install_hostname }}" diff --git a/common/utils.sh b/common/utils.sh index 262926c7..bb14381e 100644 --- a/common/utils.sh +++ b/common/utils.sh @@ -19,8 +19,8 @@ ansible_variable__get() { local _var_name="$1" local _hosts="$2" - local _result=$(env ANSIBLE_STDOUT_CALLBACK="json" ansible "$_hosts" -m debug -a "var=$_var_name" | \ - jq -r ".plays[].tasks[].hosts[].$_var_name" | sort | uniq) + local _result=$(env ANSIBLE_STDOUT_CALLBACK="json" ansible "$_hosts" -m debug -a "msg={{ $_var_name }}" | \ + jq -r '.plays[].tasks[].hosts[] | select(.failed != true) | .msg' | sort | uniq) if [ $? -ne 0 ] || [ -z "$_result" ]; then print_error "failed to get value of variable '$_var_name' for host(s) '$_hosts'" return 1 diff --git a/common/vm-install.yml b/common/vm-install.yml index c3e7a25c..d449926e 100644 --- a/common/vm-install.yml +++ b/common/vm-install.yml @@ -58,7 +58,13 @@ - role: vm/guest when: install_distro in ['debian', 'ubuntu'] -- import_playbook: "../{{ install_environment }}/{{ hostvars[install_hostname].install_playbook | default(install_hostname) }}.yml" +- name: run host playbook + vars: + params: + files: + - "../{{ install_environment }}/{{ install_hostname }}.yml" + - "../{{ install_environment }}/{{ install_playbook | default('common') }}.yml" + import_playbook: "{{ q('first_found', params) | first }}" - name: reboot and wait for VM come back hosts: "{{ install_hostname }}" diff --git a/dan/common.yml b/dan/common.yml new file mode 100644 index 00000000..494f434f --- /dev/null +++ b/dan/common.yml @@ -0,0 +1,7 @@ +--- +- name: Basic Setup + hosts: "{{ install_hostname }}" + roles: + - role: base + - role: sshd + - role: zsh diff --git a/dan/emc-00.yml b/dan/emc-00.yml deleted file mode 100644 index 2238f0c4..00000000 --- a/dan/emc-00.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- -- name: Basic Setup - hosts: emc-00 - roles: - - role: base - - role: sshd - - role: zsh - - role: apt-repo/spreadspace - - role: acmetool/base - - role: acmetool/cert - acmetool_cert_name: "{{ host_name }}.{{ host_domain }}" diff --git a/dan/emc-01.yml b/dan/emc-01.yml deleted file mode 100644 index d8582867..00000000 --- a/dan/emc-01.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- -- name: Basic Setup - hosts: emc-01 - roles: - - role: base - - role: sshd - - role: zsh - - role: apt-repo/spreadspace - - role: acmetool/base - - role: acmetool/cert - acmetool_cert_name: "{{ host_name }}.{{ host_domain }}" diff --git a/dan/emc-02.yml b/dan/emc-02.yml deleted file mode 100644 index 78b4737a..00000000 --- a/dan/emc-02.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- -- name: Basic Setup - hosts: emc-02 - roles: - - role: base - - role: sshd - - role: zsh - - role: apt-repo/spreadspace - - role: acmetool/base - - role: acmetool/cert - acmetool_cert_name: "{{ host_name }}.{{ host_domain }}" diff --git a/dan/emc-03.yml b/dan/emc-03.yml deleted file mode 100644 index 87814119..00000000 --- a/dan/emc-03.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- -- name: Basic Setup - hosts: emc-03 - roles: - - role: base - - role: sshd - - role: zsh - - role: apt-repo/spreadspace - - role: acmetool/base - - role: acmetool/cert - acmetool_cert_name: "{{ host_name }}.{{ host_domain }}" diff --git a/dan/emc-dist.yml b/dan/emc-dist.yml deleted file mode 100644 index 0e2318f4..00000000 --- a/dan/emc-dist.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- -- name: Basic Setup - hosts: emc-dist - roles: - - role: base - - role: sshd - - role: zsh diff --git a/dan/emc-dist0.yml b/dan/emc-dist0.yml deleted file mode 100644 index 9efb2731..00000000 --- a/dan/emc-dist0.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- -- name: Basic Setup - hosts: emc-dist0 - roles: - - role: base - - role: sshd - - role: zsh diff --git a/dan/emc-xx.yml b/dan/emc-xx.yml index 7b80f76e..eb9586ac 100644 --- a/dan/emc-xx.yml +++ b/dan/emc-xx.yml @@ -1,6 +1,6 @@ --- - name: Basic Setup - hosts: emc-xx + hosts: "{{ install_hostname }}" roles: - role: base - role: sshd diff --git a/dan/sk-testvm.yml b/dan/sk-testvm.yml deleted file mode 100644 index 39c775aa..00000000 --- a/dan/sk-testvm.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- -- name: Basic Setup - hosts: sk-testvm - roles: - - role: base - - role: sshd - - role: zsh diff --git a/install.sh b/install.sh index e329856b..e91ed60b 100755 --- a/install.sh +++ b/install.sh @@ -26,4 +26,10 @@ rm -f ".cache/facts/$name" echo "" echo "######## running the install playbook ########" -exec ansible-playbook -e "install_hostname=$name" -e "install_distro=$distro" -e "install_codename=$codename" -e "install_environment=$env_group" $@ "$env_group/$(basename "$0" .sh).yml" +declare -a extra_vars +extra_vars+=(-e "install_hostname=$name") +extra_vars+=(-e "install_distro=$distro") +extra_vars+=(-e "install_codename=$codename") +extra_vars+=(-e "install_environment=$env_group") +ansible_variable__get install_playbook "$name" > /dev/null 2>&1 && extra_vars+=(-e "install_playbook=$install_playbook") +exec ansible-playbook ${extra_vars[@]} $@ "$env_group/$(basename "$0" .sh).yml" diff --git a/inventory/group_vars/emc-dist.yml b/inventory/group_vars/emc-dist.yml deleted file mode 100644 index e53a98ad..00000000 --- a/inventory/group_vars/emc-dist.yml +++ /dev/null @@ -1,21 +0,0 @@ ---- -install: - cloud: - credentials: - token: "{{ vault_hcloud_api_token }}" - disks: - root_lvm_size: all - -network: {} - -docker_lvm: - vg: "{{ host_name }}" - lv: docker - size: 15G - fs: ext4 - -kubelet_lvm: - vg: "{{ host_name }}" - lv: kubelet - size: 10G - fs: ext4 diff --git a/inventory/group_vars/emc-xx/main.yml b/inventory/group_vars/emc-xx/main.yml index c73b8962..1e0dd476 100644 --- a/inventory/group_vars/emc-xx/main.yml +++ b/inventory/group_vars/emc-xx/main.yml @@ -1,23 +1,5 @@ --- +acmetool_account_email: equinox@spreadspace.org acmetool_directory_server: "{{ acmetool_directory_server_le_live_v2 }}" -install: - cloud: - credentials: - token: "{{ vault_hcloud_api_token }}" - disks: - root_lvm_size: all - -network: {} - -docker_lvm: - vg: "{{ host_name }}" - lv: docker - size: 15G - fs: ext4 - -kubelet_lvm: - vg: "{{ host_name }}" - lv: kubelet - size: 10G - fs: ext4 +install_playbook: emc-xx diff --git a/inventory/group_vars/emc/main.yml b/inventory/group_vars/emc/main.yml index d3b3dc12..02a2e25c 100644 --- a/inventory/group_vars/emc/main.yml +++ b/inventory/group_vars/emc/main.yml @@ -1,4 +1,23 @@ --- zsh_banner: elevate -acmetool_account_email: equinox@spreadspace.org +install: + cloud: + credentials: + token: "{{ vault_hcloud_api_token }}" + disks: + root_lvm_size: all + +network: {} + +docker_lvm: + vg: "{{ host_name }}" + lv: docker + size: 15G + fs: ext4 + +kubelet_lvm: + vg: "{{ host_name }}" + lv: kubelet + size: 10G + fs: ext4 diff --git a/inventory/group_vars/lendwirbel-live-xx/main.yml b/inventory/group_vars/lendwirbel-live-xx/main.yml new file mode 100644 index 00000000..cf094bd1 --- /dev/null +++ b/inventory/group_vars/lendwirbel-live-xx/main.yml @@ -0,0 +1,5 @@ +--- +acmetool_account_email: equinox@spreadspace.org +# acmetool_directory_server: "{{ acmetool_directory_server_le_live_v2 }}" + +install_playbook: lendwirbel-live-xx diff --git a/inventory/group_vars/lendwirbel-live/main.yml b/inventory/group_vars/lendwirbel-live/main.yml new file mode 100644 index 00000000..d3df4b61 --- /dev/null +++ b/inventory/group_vars/lendwirbel-live/main.yml @@ -0,0 +1,23 @@ +--- +zsh_banner: spreadspace + +install: + cloud: + credentials: + token: "{{ vault_hcloud_api_token }}" + disks: + root_lvm_size: all + +network: {} + +docker_lvm: + vg: "{{ host_name }}" + lv: docker + size: 15G + fs: ext4 + +kubelet_lvm: + vg: "{{ host_name }}" + lv: kubelet + size: 10G + fs: ext4 diff --git a/inventory/hosts.ini b/inventory/hosts.ini index 2be67e06..7aaf4c97 100644 --- a/inventory/hosts.ini +++ b/inventory/hosts.ini @@ -91,6 +91,21 @@ s2-dione host_name=dione s2-helene host_name=helene +[lendwirbel-live:vars] +host_domain=lndwrbl.live +env_group=spreadspace + +[lendwirbel-live:children] +lendwirbel-live-dist +lendwirbel-live-xx + +[lendwirbel-live-dist] +lw-live-dist0 host_name=cdn-dist0 + +[lendwirbel-live-xx] +lw-live-00 host_name=cdn-00 + + ############################### # environment: dan @@ -235,6 +250,8 @@ ele-lt [hcloud:children] emc-dist emc-xx +lendwirbel-live-dist +lendwirbel-live-xx [hetzner] emc-master diff --git a/roles/cloud/install/tasks/hcloud.yml b/roles/cloud/install/tasks/hcloud.yml index 983b3dec..b716f4ac 100644 --- a/roles/cloud/install/tasks/hcloud.yml +++ b/roles/cloud/install/tasks/hcloud.yml @@ -76,7 +76,7 @@ delay: 30 timeout: 120 -- import_tasks: hetzner_installimage.yml +- include_tasks: hetzner_installimage.yml - name: reboot shell: sleep 2 && shutdown -r now "triggered by ansible after running installimage" diff --git a/roles/cloud/install/tasks/hroot.yml b/roles/cloud/install/tasks/hroot.yml index b7d511a0..1ff4a55d 100644 --- a/roles/cloud/install/tasks/hroot.yml +++ b/roles/cloud/install/tasks/hroot.yml @@ -97,7 +97,7 @@ delay: 30 timeout: 120 -- import_tasks: hetzner_installimage.yml +- include_tasks: hetzner_installimage.yml - name: reboot shell: sleep 2 && shutdown -r now "triggered by ansible after running installimage" diff --git a/roles/cloud/install/templates/hetzner_installimage.conf.j2 b/roles/cloud/install/templates/hetzner_installimage.conf.j2 index a30fb94a..0881b110 100644 --- a/roles/cloud/install/templates/hetzner_installimage.conf.j2 +++ b/roles/cloud/install/templates/hetzner_installimage.conf.j2 @@ -1,4 +1,4 @@ -HOSTNAME {{ host_name }} +HOSTNAME {{ host_name }}{% if host_domain %}.{{ host_domain }}{% endif %}{{ '' }} {% if cloud_provider == "hroot" %} {% if install_cooked.disks.layout == "nvme_raid" %} DRIVE1 /dev/nvme0n1 diff --git a/spreadspace/common.yml b/spreadspace/common.yml new file mode 100644 index 00000000..494f434f --- /dev/null +++ b/spreadspace/common.yml @@ -0,0 +1,7 @@ +--- +- name: Basic Setup + hosts: "{{ install_hostname }}" + roles: + - role: base + - role: sshd + - role: zsh diff --git a/spreadspace/group_vars/lendwirbel-live.yml b/spreadspace/group_vars/lendwirbel-live.yml new file mode 100644 index 00000000..198d3cfe --- /dev/null +++ b/spreadspace/group_vars/lendwirbel-live.yml @@ -0,0 +1,10 @@ +$ANSIBLE_VAULT;1.2;AES256;spreadspace +34316134383639356635643636313263633466313436346232383263393736393961343764386662 +6336393866353663383330303030396534393362643631630a316334613635303364303134306435 +61623037663764376561383731343830346236613536326431383963303165303134326634613061 +3035323031303739380a383662383464323635363636386237313831643231346339353265336337 +30616664633066643739383132346537613165623339333037383062326234633137306535326534 +62393437643565616565613038396462643731333663363461636232346336323834616439346130 +34663966376433613335653039346362323332656238626237653533666332653164363531656435 +66326436626633636563646533326131303935623633633032333438613134373437663332356432 +3930 diff --git a/spreadspace/lendwirbel-live-xx.yml b/spreadspace/lendwirbel-live-xx.yml new file mode 100644 index 00000000..eb9586ac --- /dev/null +++ b/spreadspace/lendwirbel-live-xx.yml @@ -0,0 +1,11 @@ +--- +- name: Basic Setup + hosts: "{{ install_hostname }}" + roles: + - role: base + - role: sshd + - role: zsh + - role: apt-repo/spreadspace + - role: acmetool/base + - role: acmetool/cert + acmetool_cert_name: "{{ host_name }}.{{ host_domain }}" -- cgit v1.2.3