nodepool-base: use ipv4 ZK addresses if we don't have an ipv6 address

The new nb04 builder hosted in OSUOSL does not have an ipv6 address.
Check if the host being setup defined public_v6, if not then use the
ipv4 addresses of the ZK hosts.

Change-Id: I9ee09006cb7f61e5c1adbb489e8145e59cbbc281
This commit is contained in:
Ian Wienand 2023-01-12 14:11:19 +11:00
parent efa858c58e
commit 8a018af48f
No known key found for this signature in database
1 changed files with 8 additions and 1 deletions

View File

@ -57,6 +57,13 @@
set_fact:
nodepool_config: "{{ nodepool_config_content.content | b64decode | from_yaml }}"
# NOTE(ianw) : 2023-10-12 some nodes, e.g. osuosl, do not have ipv6.
# This determines if we should use the ipv4 or ipv6 address of the ZK
# hosts.
- name: Determine if we should use ipv4 or ipv6 for ZK servers
set_fact:
_public_addr: '{{ "public_v6" if hostvars[inventory_hostname]["public_v6"] is defined else "public_v4" }}'
# Have to run service-zookeeper before service-nodepool
# because we need top populate the fact cache.
# Also, we need IP addresses here because in the gate
@ -64,7 +71,7 @@
- name: Get zk config
set_fact:
zk_hosts:
hosts: "{{ (zk_hosts['hosts']|default([])) + [{'port': '2281', 'host': hostvars[item]['public_v6'] | default(hostvars[item]['ansible_host']) }] }}"
hosts: "{{ (zk_hosts['hosts']|default([])) + [{'port': '2281', 'host': hostvars[item][_public_addr] | default(hostvars[item]['ansible_host']) }] }}"
with_items: '{{ groups["zookeeper"] }}'
- name: Overwrite zookeeper-servers