Skip to content

Commit 977ed63

Browse files
committed
Fix ovn cleanup.yaml
Signed-off-by: rabi <[email protected]>
1 parent 460af5d commit 977ed63

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

roles/edpm_ovn/tasks/cleanup.yml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,44 +31,51 @@
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 | length > 0
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 | length > 0
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 | length > 0
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 | length > 0
7279

7380
- name: Clear OVN CMS Options if updated string is empty
7481
become: true
@@ -79,4 +86,4 @@
7986
failed_when: cleanup_ovn_cms_options_remove.rc != 0
8087
when:
8188
- cleanup_ovn_cms_options.rc == 0
82-
- cleanup_ovn_cms_options.stdout == ""
89+
- cleanup_ovn_cms_options_stdout | length == 0

0 commit comments

Comments
 (0)