CI: Use nodepool.public_ipv4 if nodepool.private_ipv4 is empty

We've noticed cases where nodepool.private_ipv4 is empty, probably
caused by [1] or a change in nodepool provider configuration.

[1]: https://review.opendev.org/c/zuul/nodepool/+/862522

Change-Id: Ibeca7d99571d9f6d4d1b90277121d685d73c9a59
This commit is contained in:
Michal Nasiadka 2023-01-13 13:49:55 +01:00
parent 10ca82c243
commit fb8d77a146

View File

@ -6,17 +6,18 @@
- vxlan_interface_name is defined - vxlan_interface_name is defined
- vxlan_vni is defined - vxlan_vni is defined
# We have had cases where the nodepool private IP address is not assigned,
# which causes hard to diagnose errors later on. Catch it early.
- name: Assert that the nodepool private IPv4 address is assigned
assert:
that: nodepool.private_ipv4 in ansible_all_ipv4_addresses
fail_msg: >-
The nodepool private IP address {{ nodepool.private_ipv4 }} is not assigned
- name: Set VXLAN interface facts - name: Set VXLAN interface facts
set_fact: set_fact:
tunnel_local_address: "{{ nodepool.private_ipv4 }}" tunnel_local_address: "{{ nodepool.private_ipv4 if nodepool.private_ipv4 | length > 0 else nodepool.public_ipv4 }}"
# We have had cases where the nodepool private or public IP address is not assigned,
# which causes hard to diagnose errors later on. Catch it early.
- name: Assert that the nodepool private or public IPv4 address is assigned
assert:
that: tunnel_local_address in ansible_all_ipv4_addresses
fail_msg: >-
The nodepool private/public IP address {{ tunnel_local_address }} is not assigned
- name: Create VXLAN interface - name: Create VXLAN interface
become: true become: true