From db6677a867ecfbaf37c9758a549313075e2a652c Mon Sep 17 00:00:00 2001 From: Bogdan Dobrelya Date: Tue, 10 Sep 2019 10:46:49 +0200 Subject: [PATCH] Fix evaluating nodepool_ip and switch_ip facts In I32fb17bae98f13f735da4d5b9a6a01e948f21678, the evaluated facts should also fallback to public_ipv4, when private_ipv4 is "empty-like", e.g. contains no valid IP but something like '\n'. It also restores the lost switch_private_ip fact just in case. Change-Id: I139272746129213994f298a4a9178b4441d439af Signed-off-by: Bogdan Dobrelya --- roles/multi-node-bridge/tasks/peer.yaml | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/roles/multi-node-bridge/tasks/peer.yaml b/roles/multi-node-bridge/tasks/peer.yaml index c1dea7d1f..8fd4182bb 100644 --- a/roles/multi-node-bridge/tasks/peer.yaml +++ b/roles/multi-node-bridge/tasks/peer.yaml @@ -9,20 +9,31 @@ vni: "{{ offset | int + bridge_vni_offset | int }}" # To make things more readable in the following tasks -- name: Set ip address when the node private IP is not set +- name: Set ip address when the node private IP looks empty + set_fact: + nodepool_ip: "{{ nodepool.public_ipv4 }}" + when: not (nodepool.private_ipv4 | ipv4) + +- name: Set ip address when the node private IP was not defined set_fact: nodepool_ip: | {{ nodepool.private_ipv4 | default(nodepool.public_ipv4) }} + when: nodepool_ip is not defined -- name: Select the switch from group +- name: Select the switch from group and the private ip set_fact: switch: "{{ groups['switch'][0] }}" + switch_private_ip: "{{ hostvars[groups['switch'][0]].nodepool.private_ipv4 }}" -- name: Alias the primary node private IP +- name: Alias the primary node private IP, if it looks empty set_fact: - switch_ip: | - {{ hostvars[switch].nodepool.private_ipv4 | - default(hostvars[switch].nodepool.public_ipv4) }} + switch_ip: "{{ hostvars[switch].nodepool.public_ipv4 }}" + when: not (switch_private_ip | ipv4) + +- name: Alias the primary node private IP, if it was not defined + set_fact: + switch_ip: "{{ switch_private_ip | default(hostvars[switch].nodepool.public_ipv4) }}" + when: switch_ip is not defined - name: Add port to bridge on switch node become: yes