diff --git a/ansible/playbooks/cluster-installation.yaml b/ansible/playbooks/cluster-installation.yaml index 8c9f5ba1..7c777fec 100644 --- a/ansible/playbooks/cluster-installation.yaml +++ b/ansible/playbooks/cluster-installation.yaml @@ -54,17 +54,11 @@ - { name: servicemonitors.monitoring.coreos.com, kind: CustomResourceDefinition } - name: Coredns - when: - - k3s_primary_control_node - - (k3s_server_manifests_templates | length > 0 - or k3s_server_manifests_urls | length > 0) + when: k3s_primary_control_node ansible.builtin.include_tasks: tasks/coredns.yaml - name: Cilium - when: - - k3s_primary_control_node - - (k3s_server_manifests_templates | length > 0 - or k3s_server_manifests_urls | length > 0) + when: k3s_primary_control_node ansible.builtin.include_tasks: tasks/cilium.yaml - name: Cruft diff --git a/ansible/playbooks/tasks/cilium.yaml b/ansible/playbooks/tasks/cilium.yaml index 2d1b722f..ca242bb0 100644 --- a/ansible/playbooks/tasks/cilium.yaml +++ b/ansible/playbooks/tasks/cilium.yaml @@ -1,7 +1,16 @@ --- - name: Cilium block: + - name: Cilium | Check if Cilium HelmChart exists + kubernetes.core.k8s_info: + kubeconfig: /etc/rancher/k3s/k3s.yaml + name: cilium + kind: HelmChart + namespace: kube-system + register: cilium_helmchart + - name: Cilium | Wait for Cilium to rollout + when: cilium_helmchart.resources | count > 0 kubernetes.core.k8s_info: kubeconfig: /etc/rancher/k3s/k3s.yaml name: helm-install-cilium @@ -14,6 +23,7 @@ wait_timeout: 360 - name: Cilium | Patch the Cilium HelmChart to unmanage it + when: cilium_helmchart.resources | count > 0 kubernetes.core.k8s_json_patch: kubeconfig: /etc/rancher/k3s/k3s.yaml name: cilium @@ -25,6 +35,7 @@ value: "true" - name: Cilium | Delete the Cilium HelmChart CR + when: cilium_helmchart.resources | count > 0 kubernetes.core.k8s: kubeconfig: /etc/rancher/k3s/k3s.yaml name: cilium @@ -32,14 +43,6 @@ namespace: kube-system state: absent - - name: Cilium | Check if Cilium HelmChart was deleted - kubernetes.core.k8s_info: - kubeconfig: /etc/rancher/k3s/k3s.yaml - name: cilium - kind: HelmChart - namespace: kube-system - register: cilium_helmchart - - name: Cilium | Force delete the Cilium HelmChart when: cilium_helmchart.resources | count > 0 kubernetes.core.k8s: diff --git a/ansible/playbooks/tasks/coredns.yaml b/ansible/playbooks/tasks/coredns.yaml index 5d46fce8..d18383a7 100644 --- a/ansible/playbooks/tasks/coredns.yaml +++ b/ansible/playbooks/tasks/coredns.yaml @@ -1,7 +1,16 @@ --- - name: Coredns block: + - name: Coredns | Check if Coredns HelmChart exists + kubernetes.core.k8s_info: + kubeconfig: /etc/rancher/k3s/k3s.yaml + name: coredns + kind: HelmChart + namespace: kube-system + register: coredns_helmchart + - name: Coredns | Wait for Coredns to rollout + when: coredns_helmchart.resources | count > 0 kubernetes.core.k8s_info: kubeconfig: /etc/rancher/k3s/k3s.yaml name: helm-install-coredns @@ -14,6 +23,7 @@ wait_timeout: 360 - name: Coredns | Patch the Coredns HelmChart to unmanage it + when: coredns_helmchart.resources | count > 0 kubernetes.core.k8s_json_patch: kubeconfig: /etc/rancher/k3s/k3s.yaml name: coredns @@ -24,7 +34,8 @@ path: /metadata/annotations/helmcharts.helm.cattle.io~1unmanaged value: "true" - - name: Coredns | Delete the Cilium HelmChart CR + - name: Coredns | Delete the Coredns HelmChart CR + when: coredns_helmchart.resources | count > 0 kubernetes.core.k8s: kubeconfig: /etc/rancher/k3s/k3s.yaml name: coredns @@ -32,15 +43,7 @@ namespace: kube-system state: absent - - name: Coredns | Check if Cilium HelmChart was deleted - kubernetes.core.k8s_info: - kubeconfig: /etc/rancher/k3s/k3s.yaml - name: coredns - kind: HelmChart - namespace: kube-system - register: coredns_helmchart - - - name: Coredns | Force delete the Cilium HelmChart + - name: Coredns | Force delete the Coredns HelmChart when: coredns_helmchart.resources | count > 0 kubernetes.core.k8s: kubeconfig: /etc/rancher/k3s/k3s.yaml