Skip to content

Commit 30a3613

Browse files
committed
Fix ovn cleanup.yaml
Signed-off-by: rabi <ramishra@redhat.com>
1 parent 0cfc15d commit 30a3613

1 file changed

Lines changed: 17 additions & 8 deletions

File tree

roles/edpm_ovn/tasks/cleanup.yml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,44 +31,52 @@
3131
changed_when: false
3232
ignore_errors: true
3333

34+
- name: Initialize cleanup_ovn_cms_options_stdout variable
35+
ansible.builtin.set_fact:
36+
cleanup_ovn_cms_options_stdout: "{{ cleanup_ovn_cms_options.stdout | default('') }}"
37+
when: cleanup_ovn_cms_options.rc == 0
38+
3439
- name: Cleanup enable-chassis-as-gw when chassis GW not enabled
3540
ansible.builtin.set_fact:
36-
cleanup_ovn_cms_options: "{{ cleanup_ovn_cms_options | regex_replace('enable-chassis-as-gw' ~ ',?', '') }}"
41+
cleanup_ovn_cms_options_stdout: "{{ cleanup_ovn_cms_options_stdout | regex_replace('enable-chassis-as-gw' ~ ',?', '') }}"
3742
when:
3843
- not edpm_enable_chassis_gw | bool
3944
- cleanup_ovn_cms_options.rc == 0
45+
- cleanup_ovn_cms_options_stdout is defined
4046

4147
- name: Cleanup enable-chassis-as-extport-host when chassis extport not enabled
4248
ansible.builtin.set_fact:
43-
cleanup_ovn_cms_options: "{{ cleanup_ovn_cms_options | regex_replace('enable-chassis-as-extport-host' ~ ',?', '') }}"
49+
cleanup_ovn_cms_options_stdout: "{{ cleanup_ovn_cms_options_stdout | regex_replace('enable-chassis-as-extport-host' ~ ',?', '') }}"
4450
when:
4551
- not edpm_enable_chassis_extport | bool
4652
- cleanup_ovn_cms_options.rc == 0
53+
- cleanup_ovn_cms_options_stdout is defined
4754

4855
- name: Cleanup availability-zones
4956
when:
5057
- edpm_ovn_availability_zones | length == 0
5158
- cleanup_ovn_cms_options.rc == 0
59+
- cleanup_ovn_cms_options_stdout is defined
5260
block:
5361
- name: Filter out availability-zones from stdout when undefined
5462
ansible.builtin.set_fact:
55-
filtered_azs:
56-
stdout: "{{ cleanup_ovn_cms_options.stdout | regex_replace('availability-zones=[^,]*' ~ ',?', '') }}"
63+
filtered_azs: "{{ cleanup_ovn_cms_options_stdout | regex_replace('availability-zones=[^,]*' ~ ',?', '') }}"
5764

5865
- name: Update cleanup_ovn_cms_options with filtered azs
5966
ansible.builtin.set_fact:
60-
cleanup_ovn_cms_options: "{{ cleanup_ovn_cms_options | combine(filtered_azs | default({})) }}"
67+
cleanup_ovn_cms_options_stdout: "{{ filtered_azs }}"
6168

6269
- name: Set updated OVN CMS Options to the local OVSDB
6370
become: true
6471
ansible.builtin.shell: >
65-
ovs-vsctl set Open_vSwitch . external_ids:ovn-cms-options={{ cleanup_ovn_cms_options.stdout }}
72+
ovs-vsctl set Open_vSwitch . external_ids:ovn-cms-options={{ cleanup_ovn_cms_options_stdout }}
6673
register: cleanup_ovn_cms_options_set
6774
changed_when: cleanup_ovn_cms_options_set.rc == 0
6875
failed_when: cleanup_ovn_cms_options_set.rc != 0
6976
when:
7077
- cleanup_ovn_cms_options.rc == 0
71-
- cleanup_ovn_cms_options.stdout != ""
78+
- cleanup_ovn_cms_options_stdout is defined
79+
- cleanup_ovn_cms_options_stdout != ""
7280

7381
- name: Clear OVN CMS Options if updated string is empty
7482
become: true
@@ -79,4 +87,5 @@
7987
failed_when: cleanup_ovn_cms_options_remove.rc != 0
8088
when:
8189
- cleanup_ovn_cms_options.rc == 0
82-
- cleanup_ovn_cms_options.stdout == ""
90+
- cleanup_ovn_cms_options_stdout is defined
91+
- cleanup_ovn_cms_options_stdout == ""

0 commit comments

Comments
 (0)