|
31 | 31 | changed_when: false |
32 | 32 | ignore_errors: true |
33 | 33 |
|
| 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 | + |
34 | 39 | - name: Cleanup enable-chassis-as-gw when chassis GW not enabled |
35 | 40 | 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' ~ ',?', '') }}" |
37 | 42 | when: |
38 | 43 | - not edpm_enable_chassis_gw | bool |
39 | 44 | - cleanup_ovn_cms_options.rc == 0 |
| 45 | + - cleanup_ovn_cms_options_stdout | length > 0 |
40 | 46 |
|
41 | 47 | - name: Cleanup enable-chassis-as-extport-host when chassis extport not enabled |
42 | 48 | 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' ~ ',?', '') }}" |
44 | 50 | when: |
45 | 51 | - not edpm_enable_chassis_extport | bool |
46 | 52 | - cleanup_ovn_cms_options.rc == 0 |
| 53 | + - cleanup_ovn_cms_options_stdout | length > 0 |
47 | 54 |
|
48 | 55 | - name: Cleanup availability-zones |
49 | 56 | when: |
50 | 57 | - edpm_ovn_availability_zones | length == 0 |
51 | 58 | - cleanup_ovn_cms_options.rc == 0 |
| 59 | + - cleanup_ovn_cms_options_stdout | length > 0 |
52 | 60 | block: |
53 | 61 | - name: Filter out availability-zones from stdout when undefined |
54 | 62 | 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=[^,]*' ~ ',?', '') }}" |
57 | 64 |
|
58 | 65 | - name: Update cleanup_ovn_cms_options with filtered azs |
59 | 66 | 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 }}" |
61 | 68 |
|
62 | 69 | - name: Set updated OVN CMS Options to the local OVSDB |
63 | 70 | become: true |
64 | 71 | 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 }} |
66 | 73 | register: cleanup_ovn_cms_options_set |
67 | 74 | changed_when: cleanup_ovn_cms_options_set.rc == 0 |
68 | 75 | failed_when: cleanup_ovn_cms_options_set.rc != 0 |
69 | 76 | when: |
70 | 77 | - cleanup_ovn_cms_options.rc == 0 |
71 | | - - cleanup_ovn_cms_options.stdout != "" |
| 78 | + - cleanup_ovn_cms_options_stdout | length > 0 |
72 | 79 |
|
73 | 80 | - name: Clear OVN CMS Options if updated string is empty |
74 | 81 | become: true |
|
79 | 86 | failed_when: cleanup_ovn_cms_options_remove.rc != 0 |
80 | 87 | when: |
81 | 88 | - cleanup_ovn_cms_options.rc == 0 |
82 | | - - cleanup_ovn_cms_options.stdout == "" |
| 89 | + - cleanup_ovn_cms_options_stdout | length == 0 |
0 commit comments