4f1eb22919
The lxc_container_create role creates containers specified via an inventory. Multiple network interfaces can be added to a container during creation. These interfaces are provided by the task 'LXC host config for container networks' in openstack-ansible-lxc_container_create/tasks/container_create.yml The task 'LXC host config for container networks' utilizes a template file, openstack-ansible-lxc_container_create/templates/container-interface.ini.j2 The configuration for a specified interface is created using this template. The template currenlty offers the ability to modify the value 'lxc.network.type' which defaults to type 'veth' if no value is supplied. Supplying a value other than 'veth' is currently valid for this template. However, the creation of a veth pair device is hard coded into the template whether or not 'lxc.network.type' resolves to a value other than 'veth' This creates two unwanted side effects: First, a veth pair that is not being utilized by the corresponding container is created. We should not create a veth pair if it will not be used. Secondly, if the value of the variable 'lxc.network.link' defined in the same template file is something other than a bridge, the unwanted veth creation will fail resulting in a container that will not start. Additionally, if the corresponding veth pair is not created, then the template openstack-ansible-lxc_container_create/templates/veth-cleanup.sh.j2 should be modified to filter out interfaces that are not of type 'veth'. This change implements interface type detection in the template files veth-cleanup.sh.j2 and container-interface.ini.j2 to prevent creation of unwanted veth interfaces and their associated cleanup. Change-Id: I1c0a26d07e8de0ca862d21ea7b49e02ae447f83a Closes-Bug: #1531935
21 lines
880 B
Django/Jinja
21 lines
880 B
Django/Jinja
# {{ ansible_managed }}
|
|
|
|
# Create a veth pair within the container
|
|
lxc.network.type = {{ item.value.type|default('veth') }}
|
|
# Network device within the container
|
|
lxc.network.name = {{ item.value.interface }}
|
|
{% if item.value.type == 'veth' or item.value.type is none %}
|
|
# Name the veth after the container
|
|
# NOTE(major): The lxc.network.veth.pair line must appear right after
|
|
# lxc.network.name or it will be ignored.
|
|
lxc.network.veth.pair = {{ inventory_hostname[-8:].replace('-', '').replace('_', '') }}_{{ item.value.interface }}
|
|
{% endif %}
|
|
# Host link to attach to, this should be a bridge if lxc.network.type = veth
|
|
lxc.network.link = {{ item.value.bridge }}
|
|
# Hardware Address
|
|
lxc.network.hwaddr = 00:16:3e:xx:xx:xx
|
|
# enable the device on boot
|
|
lxc.network.flags = up
|
|
# Set the container network MTU
|
|
lxc.network.mtu = {{ item.value.mtu|default(lxc_container_default_mtu) }}
|