Default private_ipv4 to use public_ipv4 address when null

The static zuul driver returns only a public_ipv4 address for
nodes in use. The multinode bridge role accesses the node
private_ipv4 address. As such, when the private address is
empty/null the role fails.

This review defaults that private address so that the role
uses the public address when the private address is null.

Change-Id: I32fb17bae98f13f735da4d5b9a6a01e948f21678
This commit is contained in:
Ronelle Landy 2018-12-06 14:25:15 -05:00 committed by Quique Llorente
parent 0d50b773bd
commit 9853d3608f
1 changed files with 21 additions and 10 deletions

View File

@ -9,19 +9,30 @@
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
set_fact:
nodepool_ip: |
{{ nodepool.private_ipv4 | default(nodepool.public_ipv4) }}
- name: Select the switch from group
set_fact:
switch: "{{ groups['switch'][0] }}"
- name: Alias the primary node private IP
set_fact:
switch_private_ip: "{{ hostvars[groups['switch'][0]]['nodepool']['private_ipv4'] }}"
switch_ip: |
{{ hostvars[switch].nodepool.private_ipv4 |
default(hostvars[switch].nodepool.public_ipv4) }}
- name: Add port to bridge on switch node
become: yes
command: >-
ovs-vsctl --may-exist add-port {{ bridge_name }}
{{ bridge_name }}_{{ nodepool['private_ipv4'] }}
-- set interface {{ bridge_name }}_{{ nodepool['private_ipv4'] }}
type=vxlan options:remote_ip={{ nodepool['private_ipv4'] }} options:key={{ vni }}
options:local_ip={{ switch_private_ip }}
delegate_to: "{{ groups['switch'][0] }}"
{{ bridge_name }}_{{ nodepool_ip }}
-- set interface {{ bridge_name }}_{{ nodepool_ip}}
type=vxlan options:remote_ip={{ nodepool_ip }} options:key={{ vni }}
options:local_ip={{ switch_ip }}
delegate_to: "{{ switch }}"
- name: Create bridge on peer node
become: yes
@ -36,10 +47,10 @@
become: yes
command: >-
ovs-vsctl --may-exist add-port {{ bridge_name }}
{{ bridge_name }}_{{ switch_private_ip }}
-- set interface {{ bridge_name }}_{{ switch_private_ip }}
type=vxlan options:remote_ip={{ switch_private_ip }} options:key={{ vni }}
options:local_ip={{ nodepool['private_ipv4'] }}
{{ bridge_name }}_{{ switch_ip }}
-- set interface {{ bridge_name }}_{{ switch_ip }}
type=vxlan options:remote_ip={{ switch_ip }} options:key={{ vni }}
options:local_ip={{ nodepool_ip }}
- when: bridge_configure_address
block: