Add a single variable for combined networks

The combined networks variable will allow deployers to set basic
container networks, default nspawn networks, and any "extra" networks a
deployer may need outside of a standard build.

Change-Id: I0cfed0ad6cce99c420c31920446e0a69a82fa602
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
This commit is contained in:
melissaml 2018-05-23 21:12:51 +08:00 committed by Kevin Carter (cloudnull)
parent 5aa18e5d54
commit c93f3ec6ef
4 changed files with 20 additions and 5 deletions

View File

@ -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 %}

View File

@ -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 %}

View File

@ -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 %}

17
vars/main.yml Normal file
View File

@ -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) }}"