Only set Ironic port attributes when changed
This fixes a lint issue: [301] Commands should not change things if nothing needs doing /home/will/code/tenks/ansible/roles/ironic-enrolment/tasks/port.yml:20 Task/Handler: Set Ironic port attributes TrivialFix Change-Id: I7940fe25d3518daf268484e292e337abc925080d
This commit is contained in:
parent
207bcab1cf
commit
a5e1b65756
@ -17,14 +17,30 @@
|
|||||||
set_fact:
|
set_fact:
|
||||||
bridge: "{{ physnet | bridge_name }}"
|
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
|
- name: Set Ironic port attributes
|
||||||
|
vars:
|
||||||
|
port_attributes: "{{ port_attributes_output.stdout | from_json }}"
|
||||||
|
switch_id: "{{ hostvars[ironic_hypervisor]['ansible_' + bridge].macaddress }}"
|
||||||
|
switch_info: "{{ bridge }}"
|
||||||
|
port_id: >-
|
||||||
|
{{ source_interface
|
||||||
|
| source_to_ovs_link_name(inventory_hostname=ironic_hypervisor) }}
|
||||||
command: >-
|
command: >-
|
||||||
'{{ ironic_virtualenv_path }}/bin/openstack' baremetal port set
|
'{{ ironic_virtualenv_path }}/bin/openstack' baremetal port set
|
||||||
{{ uuid.stdout }}
|
{{ uuid.stdout }}
|
||||||
--physical-network '{{ physnet }}'
|
--physical-network '{{ physnet }}'
|
||||||
--local-link-connection switch_id='{{ hostvars[ironic_hypervisor][
|
--local-link-connection switch_id='{{ switch_id }}'
|
||||||
'ansible_' + bridge
|
|
||||||
].macaddress }}'
|
|
||||||
--local-link-connection switch_info='{{ bridge }}'
|
--local-link-connection switch_info='{{ bridge }}'
|
||||||
--local-link-connection port_id='{{ source_interface
|
--local-link-connection port_id='{{ port_id }}'
|
||||||
| source_to_ovs_link_name(inventory_hostname=ironic_hypervisor) }}'
|
when: >-
|
||||||
|
port_attributes.physical_network != physnet or
|
||||||
|
port_attributes.local_link_connection.switch_id != switch_id or
|
||||||
|
port_attributes.local_link_connection.switch_info != switch_info or
|
||||||
|
port_attributes.local_link_connection.port_id != port_id
|
||||||
|
Loading…
x
Reference in New Issue
Block a user