Explicitly fetch baremetal ports and use id on openstacksdk>=0.99.0

Ansible module openstack.cloud.baremetal_node_info no longer returns
a detailed list of all baremetal ports [1] in release series 2.x.x. of
Ansible OpenStack collection, so we explicitly fetch those ports now.

With openstacksdk >=0.99.0, baremetal's node attribute 'uuid' has been
renamed to 'id'. Thus previous attribute name is no longer returned by
Ansible module openstack.cloud.baremetal_node_info in release series
2.x.x.

Both changes are backward compatible to release series 1.x.x of Ansible
OpenStack collection.

[1] https://review.opendev.org/c/openstack/ansible-collections-openstack/+/854113

Change-Id: I79aafee9537d92efdf7d2466fc7cddc301d32514
This commit is contained in:
Jakob Meng 2022-09-27 14:33:29 +02:00
parent de0d4c738e
commit 0329463d77

View File

@ -27,9 +27,18 @@
node: "{{ uuid | default(name) }}"
register: node_info
- name: "Collecting node ports"
openstack.cloud.baremetal_port_info:
cloud: "{{ cloud_name | default(omit) }}"
auth_type: "{{ auth_type | default(omit) }}"
auth: "{{ auth | default(omit) }}"
ca_cert: "{{ tls_certificate_path | default(omit) }}"
node: "{{ node_info.baremetal_nodes[0].id | default(node_info.baremetal_nodes[0].uuid) }}"
register: port_info
- name: "Set UUID from Ironic"
set_fact:
uuid: "{{ node_info.baremetal_nodes[0].uuid }}"
uuid: "{{ node_info.baremetal_nodes[0].id | default(node_info.baremetal_nodes[0].uuid) }}"
when: uuid is undefined
- name: "Identify ssh_public_key from ssh_public_key_path"
@ -62,7 +71,7 @@
ipv4_subnet_mask: "{{ ipv4_subnet_mask | default('') }}"
vlan_id: "{{ vlan_id | default(omit) }}"
network_mtu: "{{ network_mtu | default(omit) }}"
nics: "{{ node_info.baremetal_nodes[0].ports }}"
nics: "{{ port_info.baremetal_ports }}"
node_network_data: "{{ node_network_data | default(omit) }}"
when: addressing_mode is undefined or "dhcp" not in addressing_mode