diff --git a/tasks/main.yml b/tasks/main.yml index cb71c08..6e86784 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -336,7 +336,7 @@ Domains: "{{ container_domain }}" systemd_networks: |- {% set _networks = [] %} - {% for _, value in (container_networks | combine(nspawn_networks)).items() %} + {% for _, value in nspawn_combined_networks.items() %} {% if value.bridge is defined %} {% set _network = {'interface': 'mv-mv-' + value.bridge.split('br-')[-1]} %} {% else %} diff --git a/templates/container_config.nspawn.j2 b/templates/container_config.nspawn.j2 index c118b19..180db65 100644 --- a/templates/container_config.nspawn.j2 +++ b/templates/container_config.nspawn.j2 @@ -24,8 +24,7 @@ Bind={{ bind }}:{{ bind }} [Network] {% set macvlans = [] %} -{% set _ = container_networks.update(nspawn_networks) %} -{% for key, value in container_networks.items() %} +{% for key, value in nspawn_combined_networks.items() %} {% if value.bridge is defined %} {% set _ = macvlans.append('mv-' + value.bridge.split('br-')[-1]) %} {% endif %} diff --git a/templates/container_config_old.nspawn.j2 b/templates/container_config_old.nspawn.j2 index 4b87edb..0e8f4ee 100644 --- a/templates/container_config_old.nspawn.j2 +++ b/templates/container_config_old.nspawn.j2 @@ -18,8 +18,7 @@ {% endfor %} {% endif %} {% set macvlans = [] %} -{% set _ = container_networks.update(nspawn_networks) %} -{% for key, value in container_networks.items() %} +{% for key, value in nspawn_combined_networks.items() %} {% if value.bridge is defined %} {% set macvlan = 'mv-' + value.bridge.split('br-')[-1] %} {% endif %} diff --git a/vars/main.yml b/vars/main.yml new file mode 100644 index 0000000..ed14564 --- /dev/null +++ b/vars/main.yml @@ -0,0 +1,17 @@ +--- +# Copyright 2018, Rackspace US, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A combined hash of all networks to be used within a deployment. +nspawn_combined_networks: "{{ container_networks | combine(container_extra_networks | default({})) | combine(nspawn_networks) }}"