diff options
-rw-r--r-- | inventory/host_vars/ch-testvm-hcloud.yml | 9 | ||||
-rw-r--r-- | inventory/hosts.ini | 2 | ||||
-rw-r--r-- | roles/cloud/install/filter_plugins/hetzner.py (renamed from roles/cloud/install/filter_plugins/hroot.py) | 18 | ||||
-rw-r--r-- | roles/cloud/install/tasks/hcloud.yml | 4 | ||||
-rw-r--r-- | roles/cloud/install/tasks/hetzner_installimage.yml | 2 | ||||
-rw-r--r-- | roles/cloud/install/tasks/hroot.yml | 2 | ||||
-rw-r--r-- | roles/cloud/install/templates/hetzner_postinst.sh.j2 | 2 | ||||
-rw-r--r-- | roles/cloud/post-install/tasks/hcloud.yml | 2 | ||||
-rw-r--r-- | roles/cloud/post-install/tasks/hetzner_postinst.yml | 1 |
9 files changed, 33 insertions, 9 deletions
diff --git a/inventory/host_vars/ch-testvm-hcloud.yml b/inventory/host_vars/ch-testvm-hcloud.yml new file mode 100644 index 00000000..bd6d0ba8 --- /dev/null +++ b/inventory/host_vars/ch-testvm-hcloud.yml @@ -0,0 +1,9 @@ +--- +install: + cloud: + credentials: + token: "{{ vault_hcloud_api_token }}" + +network: {} + +apt_repo_provider: hetzner diff --git a/inventory/hosts.ini b/inventory/hosts.ini index 5df25e75..346ddd49 100644 --- a/inventory/hosts.ini +++ b/inventory/hosts.ini @@ -42,6 +42,7 @@ ch-keyserver host_name=keyserver ch-testvm-atlas host_name=testvm-atlas ch-mimas host_name=mimas ch-mimas2 host_name=mimas +ch-testvm-hcloud host_name=testvm-hcloud ch-telesto host_name=telesto ch-calypso host_name=calypso @@ -467,6 +468,7 @@ sk-2019vm sk-tomnext [hcloud] +ch-testvm-hcloud ch-mimas2 ele-lt ele-coturn diff --git a/roles/cloud/install/filter_plugins/hroot.py b/roles/cloud/install/filter_plugins/hetzner.py index d2abff1b..0aa19c17 100644 --- a/roles/cloud/install/filter_plugins/hroot.py +++ b/roles/cloud/install/filter_plugins/hetzner.py @@ -5,14 +5,23 @@ __metaclass__ = type from ansible import errors -def extract_ssh_key_fingerprints(data): +def hetzner_install_image_name_glob(data): + try: + if data[0] == 'debian' and data[1] != 'buster': + return "debian-*-%s-amd64-base.tar.gz" % (data[1]) + return "%s-*-%s-64-minimal.tar.gz" % (data[0], data[1]) + except Exception as e: + raise errors.AnsibleFilterError("hetzner_install_image_name(): %s" % str(e)) + + +def hroot_extract_ssh_key_fingerprints(data): try: return [k['key']['fingerprint'] for k in data] except Exception as e: raise errors.AnsibleFilterError("hroot_ssh_key_fingerprints(): %s" % str(e)) -def extract_serverip(data, server_name): +def hroot_extract_serverip(data, server_name): try: ips = [s['server']['server_ip'] for s in data if s['server']['server_name'] == server_name] if len(ips): @@ -28,6 +37,7 @@ class FilterModule(object): def filters(self): return { - 'hroot_extract_ssh_key_fingerprints': extract_ssh_key_fingerprints, - 'hroot_extract_serverip': extract_serverip, + 'hetzner_install_image_name_glob': hetzner_install_image_name_glob, + 'hroot_extract_ssh_key_fingerprints': hroot_extract_ssh_key_fingerprints, + 'hroot_extract_serverip': hroot_extract_serverip, } diff --git a/roles/cloud/install/tasks/hcloud.yml b/roles/cloud/install/tasks/hcloud.yml index cd46d348..49bdef1c 100644 --- a/roles/cloud/install/tasks/hcloud.yml +++ b/roles/cloud/install/tasks/hcloud.yml @@ -73,8 +73,8 @@ - name: wait for rescue system to start up wait_for_connection: - delay: 30 - timeout: 120 + delay: 10 + timeout: 300 - include_tasks: hetzner_installimage.yml diff --git a/roles/cloud/install/tasks/hetzner_installimage.yml b/roles/cloud/install/tasks/hetzner_installimage.yml index 5704b200..57397998 100644 --- a/roles/cloud/install/tasks/hetzner_installimage.yml +++ b/roles/cloud/install/tasks/hetzner_installimage.yml @@ -6,7 +6,7 @@ shell: | set -o pipefail shopt -s nocaseglob - ls /root/.oldroot/nfs/images/{{ install_distro }}-*-{{ install_codename }}-64-minimal.tar.gz | sort -r | head -n 1 + ls /root/images/{{ (install_distro, install_codename) | hetzner_install_image_name_glob }} | sort -r | head -n 1 changed_when: false register: latest_image diff --git a/roles/cloud/install/tasks/hroot.yml b/roles/cloud/install/tasks/hroot.yml index 588ae981..3ec38c7a 100644 --- a/roles/cloud/install/tasks/hroot.yml +++ b/roles/cloud/install/tasks/hroot.yml @@ -95,7 +95,7 @@ - name: wait for rescue system to start up wait_for_connection: delay: 30 - timeout: 120 + timeout: 300 - include_tasks: hetzner_installimage.yml diff --git a/roles/cloud/install/templates/hetzner_postinst.sh.j2 b/roles/cloud/install/templates/hetzner_postinst.sh.j2 index ba9d3eeb..329469be 100644 --- a/roles/cloud/install/templates/hetzner_postinst.sh.j2 +++ b/roles/cloud/install/templates/hetzner_postinst.sh.j2 @@ -5,6 +5,8 @@ OS_DISTRO=$(. /etc/os-release; echo $ID) OS_MAJOR_VERSION=$(. /etc/os-release; echo $VERSION_ID | cut -d . -f 1) export DEBIAN_FRONTEND=noninteractive +export SUDO_FORCE_REMOVE=yes +dpkg --purge sudo apt-get update -q apt-get full-upgrade -y -q diff --git a/roles/cloud/post-install/tasks/hcloud.yml b/roles/cloud/post-install/tasks/hcloud.yml index 0674d270..90b0229d 100644 --- a/roles/cloud/post-install/tasks/hcloud.yml +++ b/roles/cloud/post-install/tasks/hcloud.yml @@ -4,5 +4,5 @@ - name: install additional packages apt: name: - - qemu-guest-agent + - qemu-guest-agent state: present diff --git a/roles/cloud/post-install/tasks/hetzner_postinst.yml b/roles/cloud/post-install/tasks/hetzner_postinst.yml index aaa7d28c..2ae7beb8 100644 --- a/roles/cloud/post-install/tasks/hetzner_postinst.yml +++ b/roles/cloud/post-install/tasks/hetzner_postinst.yml @@ -10,6 +10,7 @@ - name: remove installimage artifacts loop: + - /etc/apt/sources.list.d/hetzner-security-updates.list - /installimage.conf - /installimage.debug - /post-install |