Browse Source

Document adding "extra" networks

This change moves the hidden `container_extra_networks` options to the
defaults file and adds a blerb regarding how this functions.

Change-Id: I4d7a9f05cf8382d0b83dd0ce574f7f4ba3783a63
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
Kevin Carter 8 months ago
parent
commit
ca6fe7df8d
3 changed files with 15 additions and 6 deletions
  1. 5
    0
      defaults/main.yml
  2. 9
    5
      tasks/nspawn_networking.yml
  3. 1
    1
      vars/main.yml

+ 5
- 0
defaults/main.yml View File

@@ -67,6 +67,11 @@ nspawn_networks:
67 67
 #     tunnel_address:
68 68
 #       bridge: eth0.10
69 69
 #
70
+# Extra interfaces that are wholly configured by the user can be set using the
71
+# container extra networks option. This option follows all of the parameters of
72
+# both `container_networks` and `nspawn_networks`.
73
+container_extra_networks: {}
74
+
70 75
 # In this example management storage and tunnel networks will be created and
71 76
 # attached to the containers.
72 77
 #  + The management network will have a route created for its corresponding CIDR

+ 9
- 5
tasks/nspawn_networking.yml View File

@@ -74,8 +74,12 @@
74 74
           {%- set start_commands = [] %}
75 75
           {%- set seen_start_interfaces = [] %}
76 76
           {%- for key, value in nspawn_combined_networks.items() %}
77
-          {%-   set interface = value.bridge.split('br-')[-1] %}
78
-          {%-   set mv_interface = 'mv-' + interface %}
77
+          {%-   if value.interface is defined %}
78
+          {%-     set mv_interface = value.interface %}
79
+          {%-   else %}
80
+          {%-     set interface = value.bridge.split('br-')[-1] %}
81
+          {%-     set mv_interface = 'mv-' + interface %}
82
+          {%-   endif %}
79 83
           {%-   if value.bridge not in seen_start_interfaces %}
80 84
           {%-     if value.private_device | default(false) | bool %}
81 85
           {%-       set _ = start_commands.append('-/sbin/ip link add dev ' + value.bridge + ' type dummy') %}
@@ -118,11 +122,11 @@
118 122
   vars:
119 123
     systemd_networkd_prefix: "nspawn_host"
120 124
     systemd_run_networkd: true
121
-    systemd_interface_cleanup: false
125
+    systemd_interface_cleanup: true
122 126
     systemd_netdevs: |-
123 127
       {% set seen_netdevs = [] %}
124 128
       {% set _netdevs = [] %}
125
-      {% for _, value in (nspawn_networks | combine(container_extra_networks | default({}))).items() %}
129
+      {% for _, value in (nspawn_networks | combine(container_extra_networks)).items() %}
126 130
       {%   set netname = value.interface | default('mv-' + value.bridge.split('br-')[-1]) %}
127 131
       {%   set _netdev = {'NetDev': {'Name': netname, 'Kind': 'macvlan'}, 'MACVLAN': {'Mode': 'bridge'}} %}
128 132
       {%   if netname not in seen_netdevs %}
@@ -136,7 +140,7 @@
136 140
       {% set _networks = [] %}
137 141
       {# All nspawn_networks and container_extra_networks will be iterated over. #}
138 142
       {# If a device is found, a networkd config will be generated for it. #}
139
-      {% for _, value in (nspawn_networks | combine(container_extra_networks | default({}))).items() %}
143
+      {% for _, value in (nspawn_networks | combine(container_extra_networks)).items() %}
140 144
       {%   set netname = value.interface | default('mv-' + value.bridge.split('br-')[-1]) %}
141 145
       {%   set _network = {'interface': netname} %}
142 146
       {%   if netname not in seen_networks %}

+ 1
- 1
vars/main.yml View File

@@ -21,4 +21,4 @@ nspawn_architecture_mapping:
21 21
   armv7l: armhf
22 22
 
23 23
 # A combined hash of all networks to be used within a deployment.
24
-nspawn_combined_networks: "{{ container_networks | combine(container_extra_networks | default({})) | combine(nspawn_networks) }}"
24
+nspawn_combined_networks: "{{ container_networks | combine(container_extra_networks) | combine(nspawn_networks) }}"

Loading…
Cancel
Save