From c57291af6d53552aa1ef1c67ae8924d9f41d404b Mon Sep 17 00:00:00 2001 From: Danny Bessems Date: Tue, 16 Aug 2022 15:16:20 +0200 Subject: [PATCH] Force apply manifests w/ handler;Add dependency --- .../files/ansible_payload/playbook.yml | 6 ++++++ .../roles/metacluster/tasks/main.yml | 20 +++++++++++++++++++ .../roles/metacluster/tasks/components.yml | 6 +++++- ansible/roles/metacluster/tasks/k3s.yml | 5 +++++ ansible/vars/metacluster.yml | 1 + 5 files changed, 37 insertions(+), 1 deletion(-) diff --git a/ansible/roles/firstboot/files/ansible_payload/playbook.yml b/ansible/roles/firstboot/files/ansible_payload/playbook.yml index 9e7373b..bbb4610 100644 --- a/ansible/roles/firstboot/files/ansible_payload/playbook.yml +++ b/ansible/roles/firstboot/files/ansible_payload/playbook.yml @@ -14,3 +14,9 @@ - workloadcluster - tty - cleanup + handlers: + - name: Apply manifests + kubernetes.core.k8s: + src: "{{ item }}" + state: present + with_fileglob: /var/lib/rancher/k3s/server/manifests/*.yaml diff --git a/ansible/roles/firstboot/files/ansible_payload/roles/metacluster/tasks/main.yml b/ansible/roles/firstboot/files/ansible_payload/roles/metacluster/tasks/main.yml index 44a0a78..40f242b 100644 --- a/ansible/roles/firstboot/files/ansible_payload/roles/metacluster/tasks/main.yml +++ b/ansible/roles/firstboot/files/ansible_payload/roles/metacluster/tasks/main.yml @@ -34,6 +34,11 @@ services: - kind: TraefikService name: api@internal + notify: + - Apply manifests + + - name: Trigger handlers + ansible.builtin.meta: flush_handlers - name: Ensure API availability ansible.utils.cli_parse: @@ -137,6 +142,11 @@ ansible.builtin.template: dest: /etc/rancher/k3s/registries.yaml src: registries.j2 + notify: + - Apply manifests + +- name: Trigger handlers + ansible.builtin.meta: flush_handlers - block: @@ -169,6 +179,11 @@ services: - name: gitea-ssh port: 22 + notify: + - Apply manifests + + - name: Trigger handlers + ansible.builtin.meta: flush_handlers - name: Ensure gitea API availability ansible.utils.cli_parse: @@ -338,6 +353,11 @@ namespace: argo-cd uid: "{{ lookup('ansible.builtin.password', '/dev/null length=5 chars=ascii_lowercase,digits seed=inventory_hostname') }}" privatekey: "{{ lookup('ansible.builtin.file', '~/.ssh/git_rsa_id') | indent(4, true) }}" + notify: + - Apply manifests + + - name: Trigger handlers + ansible.builtin.meta: flush_handlers module_defaults: ansible.builtin.uri: diff --git a/ansible/roles/metacluster/tasks/components.yml b/ansible/roles/metacluster/tasks/components.yml index f3dc885..41e1375 100644 --- a/ansible/roles/metacluster/tasks/components.yml +++ b/ansible/roles/metacluster/tasks/components.yml @@ -55,7 +55,6 @@ docker-archive:./{{ ( item | regex_findall('[^/:]+'))[-2] }}.tar:{{ item }} chdir: /opt/metacluster/container-images loop: "{{ (containerimages.results | map(attribute='stdout_lines') | flatten) + dependencies.container_images }}" - # loop: "{{ (containerimages.results | map(attribute='stdout_lines') | flatten) }}" # - name: Inject manifests # ansible.builtin.template: @@ -67,6 +66,11 @@ # loop: "{{ lookup('ansible.builtin.dict', components) | map(attribute='value.manifests') | list | select('defined') | flatten }}" # loop_control: # label: "{{ item.type + '/' + item.name }}" +# notify: +# - Apply manifests + +# - name: Trigger handlers +# ansible.builtin.meta: flush_handlers - name: Compress tarballs community.general.archive: diff --git a/ansible/roles/metacluster/tasks/k3s.yml b/ansible/roles/metacluster/tasks/k3s.yml index d4cf30a..7947c06 100644 --- a/ansible/roles/metacluster/tasks/k3s.yml +++ b/ansible/roles/metacluster/tasks/k3s.yml @@ -38,3 +38,8 @@ loop: "{{ platform.packaged_components }}" loop_control: label: "{{ item.name }}" + notify: + - Apply manifests + +- name: Trigger handlers + ansible.builtin.meta: flush_handlers diff --git a/ansible/vars/metacluster.yml b/ansible/vars/metacluster.yml index 4cfaf1c..be7ca1f 100644 --- a/ansible/vars/metacluster.yml +++ b/ansible/vars/metacluster.yml @@ -150,5 +150,6 @@ dependencies: - lvm2 pip: - jmespath + - kubernetes - passlib - pyvmomi