From ffd86e61dd46e27c8a6dbd34b5c1808e7bfe13f6 Mon Sep 17 00:00:00 2001 From: Brendan Shephard Date: Mon, 2 Dec 2024 10:04:47 +1000 Subject: [PATCH] Update pod spec during deployment Signed-off-by: Brendan Shephard --- roles/edpm_ovn/tasks/run.yml | 48 +++++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/roles/edpm_ovn/tasks/run.yml b/roles/edpm_ovn/tasks/run.yml index 172f46e77..dca069b5b 100644 --- a/roles/edpm_ovn/tasks/run.yml +++ b/roles/edpm_ovn/tasks/run.yml @@ -43,9 +43,49 @@ ovn_controller: "{{ lookup('template', 'kolla_ovn_controller.yaml.j2') | from_yaml }}" when: not edpm_use_bootc -- name: Run ovn_controller container - ansible.builtin.systemd_service: - name: edpm-compute@ovn_controller - state: started +- name: Configure ovn_controller for bootc deployments + block: + - name: Collect default pod spec + ansible.builtin.slurp: + src: /usr/share/containers/systemd/ovn_controller.yaml + register: ovn_controller_pod_spec + + - name: Decode and parse the YAML content + ansible.builtin.set_fact: + ovn_controller_pod_spec: "{{ ovn_controller_pod_spec.content | b64decode | from_yaml }}" + + - name: Update fields in the YAML data + ansible.builtin.set_fact: + updated_pod_spec: >- + {{ + ovn_controller_pod_spec | combine(ovn_controller_pod_spec.spec.containers.image, edpm_ovn_controller_agent_image, recursive=true) + }) + }} + + - name: Write the updated pod spec to /etc + ansible.builtin.copy: + content: "{{ updated_pod_spec | to_yaml }}" + dest: /etc/containers/systemd/ovn_controller.yaml + mode: '0644' + + - name: Copy systemd service template + ansible.builtin.copy: + remote_src: true + src: /usr/share/containers/systemd/edpm-compute@.kube + dest: /etc/containers/systemd/edpm-compute@.kube + + - name: Update service template Yaml path + ansible.builtin.ini_file: + path: /etc/containers/systemd/edpm-compute@.kube + section: Kube + option: "Yaml" + value: "/etc/containers/systemd/%i.yaml" + mode: "0644" + + - name: Run ovn_controller container + ansible.builtin.systemd_service: + daemon_reload: true + name: edpm-compute@ovn_controller + state: started become: true when: edpm_use_bootc