Skip to content

Commit

Permalink
Update pod spec during deployment
Browse files Browse the repository at this point in the history
Signed-off-by: Brendan Shephard <[email protected]>
  • Loading branch information
bshephar committed Dec 2, 2024
1 parent cde9667 commit 54f7101
Showing 1 changed file with 47 additions and 4 deletions.
51 changes: 47 additions & 4 deletions roles/edpm_ovn/tasks/run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,52 @@
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({
'spec': {
'containers': ovn_controller_pod_spec.spec.containers | zip_longest([], [{'image': edpm_ovn_controller_agent_image}]) | map('combine') | list,
},
}, 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/[email protected]
dest: /etc/containers/systemd/[email protected]

- name: Update service template Yaml path
ansible.builtin.ini_file:
path: /etc/containers/systemd/[email protected]
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

0 comments on commit 54f7101

Please sign in to comment.