Files
tenks/ansible/roles/ironic-enrolment/tasks/port.yml
Mark Goddard 2c2c8b9504 Fix CI failures
* new ansible-lint complaints
* clamp ansible-lint to <7
* tox 4 support
* switch to CentOS NFV Open vSwitch repository for OVS - rocky 9 RDO install was failing
* switch from Kayobe CentOS stream 8 to Rocky Linux 9 and Ubuntu Jammy
  jobs - these are the current supported distros in Kayobe master

Change-Id: Ic607ccccc866da65c100053bfa15ee141a98679e
2023-05-18 09:24:55 +01:00

56 lines
1.8 KiB
YAML

---
- name: Get Ironic port UUID
command: >-
'{{ ironic_virtualenv_path }}/bin/openstack' baremetal port list
--format value
--column UUID
--address {{ mac }}
register: uuid
changed_when: false
- name: Fail if port is not found
fail:
msg: Ironic port with MAC address {{ mac }} not found
when: not uuid.stdout
- name: Get physical network name
set_fact:
physnet: >-
{{ source_interface |
source_link_to_physnet_name(inventory_hostname=ironic_hypervisor) }}
- name: Get bridge name
set_fact:
bridge: "{{ physnet | bridge_name }}"
- name: Get existing Ironic port attributes
command: >-
{{ ironic_virtualenv_path }}/bin/openstack baremetal port show
{{ uuid.stdout }} -f json
register: port_attributes_output
changed_when: false
- name: Set Ironic port attributes
vars:
port_attributes: "{{ port_attributes_output.stdout | from_json }}"
switch_id: "{{ hostvars[ironic_hypervisor].ansible_facts[bridge].macaddress }}"
switch_info: "{{ bridge }}"
port_id: >-
{{ source_interface
| source_to_peer_link_name(inventory_hostname=ironic_hypervisor) }}
command: >-
'{{ ironic_virtualenv_path }}/bin/openstack' baremetal port set
{{ uuid.stdout }}
{% if supports_port_physnet %}
--physical-network '{{ physnet }}'
{% endif %}
--local-link-connection switch_id='{{ switch_id }}'
--local-link-connection switch_info='{{ bridge }}'
--local-link-connection port_id='{{ port_id }}'
changed_when: true
when: >-
(supports_port_physnet and port_attributes.physical_network != physnet) or
port_attributes.local_link_connection.get('switch_id') != switch_id or
port_attributes.local_link_connection.get('switch_info') != switch_info or
port_attributes.local_link_connection.get('port_id') != port_id