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
(cherry picked from commit fb8d77a146)
This commit is contained in:
Michal Nasiadka 2023-01-13 13:49:55 +01:00
parent 458020e2ba
commit bb372745c2
1 changed files with 10 additions and 9 deletions

View File

@ -6,17 +6,18 @@
- vxlan_interface_name 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
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
become: true