Browse Source

Merge "Default private_ipv4 to use public_ipv4 address when null"

changes/49/633049/1
Zuul 5 months ago
parent
commit
cce734c667
1 changed files with 21 additions and 10 deletions
  1. 21
    10
      roles/multi-node-bridge/tasks/peer.yaml

+ 21
- 10
roles/multi-node-bridge/tasks/peer.yaml View File

@@ -9,19 +9,30 @@
9 9
     vni: "{{ offset | int + bridge_vni_offset | int }}"
10 10
 
11 11
 # To make things more readable in the following tasks
12
+- name: Set ip address when the node private IP is not set
13
+  set_fact:
14
+    nodepool_ip: |
15
+      {{ nodepool.private_ipv4 | default(nodepool.public_ipv4) }}
16
+
17
+- name: Select the switch from group
18
+  set_fact:
19
+    switch: "{{ groups['switch'][0] }}"
20
+
12 21
 - name: Alias the primary node private IP
13 22
   set_fact:
14
-    switch_private_ip: "{{ hostvars[groups['switch'][0]]['nodepool']['private_ipv4'] }}"
23
+    switch_ip: |
24
+      {{ hostvars[switch].nodepool.private_ipv4 |
25
+          default(hostvars[switch].nodepool.public_ipv4) }}
15 26
 
16 27
 - name: Add port to bridge on switch node
17 28
   become: yes
18 29
   command: >-
19 30
     ovs-vsctl --may-exist add-port {{ bridge_name }}
20
-    {{ bridge_name }}_{{ nodepool['private_ipv4'] }}
21
-    -- set interface {{ bridge_name }}_{{ nodepool['private_ipv4'] }}
22
-    type=vxlan options:remote_ip={{ nodepool['private_ipv4'] }} options:key={{ vni }}
23
-    options:local_ip={{ switch_private_ip }}
24
-  delegate_to: "{{ groups['switch'][0] }}"
31
+    {{ bridge_name }}_{{ nodepool_ip }}
32
+    -- set interface {{ bridge_name }}_{{ nodepool_ip}}
33
+    type=vxlan options:remote_ip={{ nodepool_ip }} options:key={{ vni }}
34
+    options:local_ip={{ switch_ip }}
35
+  delegate_to: "{{ switch }}"
25 36
 
26 37
 - name: Create bridge on peer node
27 38
   become: yes
@@ -36,10 +47,10 @@
36 47
   become: yes
37 48
   command: >-
38 49
     ovs-vsctl --may-exist add-port {{ bridge_name }}
39
-    {{ bridge_name }}_{{ switch_private_ip }}
40
-    -- set interface {{ bridge_name }}_{{ switch_private_ip }}
41
-    type=vxlan options:remote_ip={{ switch_private_ip }} options:key={{ vni }}
42
-    options:local_ip={{ nodepool['private_ipv4'] }}
50
+    {{ bridge_name }}_{{ switch_ip }}
51
+    -- set interface {{ bridge_name }}_{{ switch_ip }}
52
+    type=vxlan options:remote_ip={{ switch_ip }} options:key={{ vni }}
53
+    options:local_ip={{ nodepool_ip }}
43 54
 
44 55
 - when: bridge_configure_address
45 56
   block:

Loading…
Cancel
Save