From 8a018af48f98b75e447c0e73f594ee5d72aa74c8 Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Thu, 12 Jan 2023 14:11:19 +1100 Subject: [PATCH] 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 --- playbooks/roles/nodepool-base/tasks/main.yaml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/playbooks/roles/nodepool-base/tasks/main.yaml b/playbooks/roles/nodepool-base/tasks/main.yaml index c185c138a4..9f2fde0b63 100644 --- a/playbooks/roles/nodepool-base/tasks/main.yaml +++ b/playbooks/roles/nodepool-base/tasks/main.yaml @@ -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