From b5b66f1489a54724e13f2b8086b25fff6b68ab67 Mon Sep 17 00:00:00 2001 From: Vladimir Kozhukalov Date: Tue, 31 Oct 2023 17:23:50 -0500 Subject: [PATCH] Fix deploy-env when buildset_registry is defined It used to configure /etc/hosts in two different places. The buildset registry record was added while configuing Containerd and then this record was removed while configuring Kubernetes. The PR adds the buildset registry record to the /etc/hosts template and the task is moved to the tasks/main.yaml. Change-Id: I7d1ae6c7d33a33d8ca80b63ef9d69decb283e0a6 --- roles/deploy-env/files/hosts | 3 +++ roles/deploy-env/tasks/common_k8s.yaml | 5 ----- roles/deploy-env/tasks/containerd.yaml | 11 ----------- roles/deploy-env/tasks/main.yaml | 9 +++++++-- 4 files changed, 10 insertions(+), 18 deletions(-) diff --git a/roles/deploy-env/files/hosts b/roles/deploy-env/files/hosts index daf6251a4..dea9afeb9 100644 --- a/roles/deploy-env/files/hosts +++ b/roles/deploy-env/files/hosts @@ -1,2 +1,5 @@ 127.0.0.1 localhost {{ ansible_default_ipv4['address'] }} {{ ansible_hostname }} +{% if buildset_registry is defined and (buildset_registry.host | ipaddr) %} +{{ buildset_registry.host }} zuul-jobs.buildset-registry +{% endif %} diff --git a/roles/deploy-env/tasks/common_k8s.yaml b/roles/deploy-env/tasks/common_k8s.yaml index 2d942ec04..ad222dfde 100644 --- a/roles/deploy-env/tasks/common_k8s.yaml +++ b/roles/deploy-env/tasks/common_k8s.yaml @@ -85,11 +85,6 @@ - /etc/resolv.conf - /run/systemd/resolve/resolv.conf -- name: Configure /etc/hosts - template: - src: files/hosts - dest: /etc/hosts - # We download Calico manifest on all nodes because we then want to download # Calico images BEFORE deploying it - name: Download Calico manifest diff --git a/roles/deploy-env/tasks/containerd.yaml b/roles/deploy-env/tasks/containerd.yaml index 01065b68a..372933ec9 100644 --- a/roles/deploy-env/tasks/containerd.yaml +++ b/roles/deploy-env/tasks/containerd.yaml @@ -87,17 +87,6 @@ include_tasks: file: buildset_registry_alias.yaml - - name: Configure /etc/hosts for buildset_registry to workaround docker not understanding ipv6 addresses - lineinfile: - path: /etc/hosts - state: present - regex: "^{{ buildset_registry.host }}\tzuul-jobs.buildset-registry$" - line: "{{ buildset_registry.host }}\tzuul-jobs.buildset-registry" - insertafter: EOF - when: - - buildset_registry is defined - - buildset_registry.host | ipaddr - - name: Write buildset registry TLS certificate copy: content: "{{ buildset_registry.cert }}" diff --git a/roles/deploy-env/tasks/main.yaml b/roles/deploy-env/tasks/main.yaml index 7ba7fec0f..e6a4d0d28 100644 --- a/roles/deploy-env/tasks/main.yaml +++ b/roles/deploy-env/tasks/main.yaml @@ -3,11 +3,16 @@ include_tasks: file: prerequisites.yaml -- name: Include common tasks +- name: Configure /etc/hosts + template: + src: files/hosts + dest: /etc/hosts + +- name: Deploy Containerd include_tasks: file: containerd.yaml -- name: Include common tasks +- name: Common K8s tasks include_tasks: file: common_k8s.yaml