Skip to content

Commit 3ed31c1

Browse files
Use floating ip list instead of broken show -f formatters
On shiftstackclient OSC, `openstack floating ip show … -f *` always returns Invalid formatter provided. Look up Fixed IP Address via `floating ip list --floating-ip-address … -f json` instead. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent f7026c8 commit 3ed31c1

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

collection/stages/roles/verification/tasks/check_lb_svc.yml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,24 @@
5252
- not internal_lb
5353
- lb_ingress_ip is match(ipv4_regex)
5454
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
5759
environment:
5860
OS_CLOUD: "{{ user_cloud }}"
59-
register: lb_fip_show
61+
register: lb_fip_list
6062
changed_when: false
6163

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+
6270
- name: Define the internal IP
6371
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']) }}"
6573

6674
- name: List load balancers on OpenStack
6775
ansible.builtin.command: openstack loadbalancer list -f json
@@ -163,12 +171,12 @@
163171
- lb_internal_ip is defined
164172
- lb_internal_ip | length > 0
165173

174+
# Prefer list over show: floating ip show -f * fails on shiftstackclient OSC.
166175
- 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
168177
environment:
169178
OS_CLOUD: "{{ user_cloud }}"
170-
register: fip
171-
failed_when: false
179+
register: fip_list
172180
changed_when: false
173181
when:
174182
- lb_internal_ip is defined
@@ -177,7 +185,7 @@
177185
- name: Check the fip "{{ lb_ingress_ip }}" has been removed from OSP
178186
ansible.builtin.assert:
179187
that:
180-
- fip.rc != 0
188+
- (fip_list.stdout | from_json | length) == 0
181189
fail_msg: FIP "{{ lb_ingress_ip }}" is still present in OSP
182190
when:
183191
- lb_internal_ip is defined

0 commit comments

Comments
 (0)