|
52 | 52 | - not internal_lb |
53 | 53 | - lb_ingress_ip is match(ipv4_regex) |
54 | 54 | block: |
55 | | - - name: Get the LB internal IP on openstack when the lb is using a FIP |
56 | | - ansible.builtin.command: openstack floating ip show {{ lb_ingress_ip }} -f json |
| 55 | + # NOTE: `openstack floating ip show … -f <any>` is broken on the |
| 56 | + # shiftstackclient OSC ("Invalid formatter provided"). Use list+filter. |
| 57 | + - name: Get the LB FIP details on openstack when the lb is using a FIP |
| 58 | + ansible.builtin.command: openstack floating ip list --floating-ip-address {{ lb_ingress_ip }} -f json |
57 | 59 | environment: |
58 | 60 | OS_CLOUD: "{{ user_cloud }}" |
59 | | - register: lb_fip_show |
| 61 | + register: lb_fip_list |
60 | 62 | changed_when: false |
61 | 63 |
|
| 64 | + - name: Check the FIP "{{ lb_ingress_ip }}" exists on OpenStack |
| 65 | + ansible.builtin.assert: |
| 66 | + that: |
| 67 | + - (lb_fip_list.stdout | from_json | length) > 0 |
| 68 | + fail_msg: Could not find floating IP "{{ lb_ingress_ip }}" in OSP |
| 69 | + |
62 | 70 | - name: Define the internal IP |
63 | 71 | ansible.builtin.set_fact: |
64 | | - lb_internal_ip: "{{ internal_lb | ternary(lb_ingress_ip, (lb_fip_show.stdout | from_json).fixed_ip_address) }}" |
| 72 | + lb_internal_ip: "{{ internal_lb | ternary(lb_ingress_ip, (lb_fip_list.stdout | from_json | first)['Fixed IP Address']) }}" |
65 | 73 |
|
66 | 74 | - name: List load balancers on OpenStack |
67 | 75 | ansible.builtin.command: openstack loadbalancer list -f json |
|
163 | 171 | - lb_internal_ip is defined |
164 | 172 | - lb_internal_ip | length > 0 |
165 | 173 |
|
| 174 | + # Prefer list over show: floating ip show -f * fails on shiftstackclient OSC. |
166 | 175 | - name: Check whether the fip "{{ lb_ingress_ip }}" still exists on OSP |
167 | | - ansible.builtin.command: openstack floating ip show {{ lb_ingress_ip }} -f json |
| 176 | + ansible.builtin.command: openstack floating ip list --floating-ip-address {{ lb_ingress_ip }} -f json |
168 | 177 | environment: |
169 | 178 | OS_CLOUD: "{{ user_cloud }}" |
170 | | - register: fip |
171 | | - failed_when: false |
| 179 | + register: fip_list |
172 | 180 | changed_when: false |
173 | 181 | when: |
174 | 182 | - lb_internal_ip is defined |
|
177 | 185 | - name: Check the fip "{{ lb_ingress_ip }}" has been removed from OSP |
178 | 186 | ansible.builtin.assert: |
179 | 187 | that: |
180 | | - - fip.rc != 0 |
| 188 | + - (fip_list.stdout | from_json | length) == 0 |
181 | 189 | fail_msg: FIP "{{ lb_ingress_ip }}" is still present in OSP |
182 | 190 | when: |
183 | 191 | - lb_internal_ip is defined |
|
0 commit comments