Merge "Used named veth pairs that match container"

This commit is contained in:
Jenkins 2015-09-08 13:34:19 +00:00 committed by Gerrit Code Review
commit 70427f5a8d
2 changed files with 17 additions and 1 deletions

View File

@ -187,6 +187,19 @@
tags:
- lxc-container-networks
# NOTE(major): the lxc.network.veth.pair line must appear *immediately* after
# the lxc.network.name congfiguration line or it will be ignored. That's why
# you'll find a "insertafter" in this YAML block.
- name: Add veth pair name to match container name
lineinfile:
dest: "/var/lib/lxc/{{ inventory_hostname }}/config"
line: "lxc.network.veth.pair = {{ inventory_hostname[-8:].replace('-', '').replace('_', '') }}_eth0"
insertafter: "^lxc.network.name"
backup: "true"
delegate_to: "{{ physical_host }}"
tags:
- lxc-container-networks
- name: Container network includes
lineinfile:
dest: "/var/lib/lxc/{{ inventory_hostname }}/config"

View File

@ -4,6 +4,10 @@
lxc.network.type = {{ item.value.type|default('veth') }}
# Network device within the container
lxc.network.name = {{ item.value.interface }}
# 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 }}
# Host link to attach to, this should be a bridge
lxc.network.link = {{ item.value.bridge }}
# Hardware Address
@ -12,4 +16,3 @@ lxc.network.hwaddr = 00:16:3e:xx:xx:xx
lxc.network.flags = up
# Set the container network MTU
lxc.network.mtu = {{ item.value.mtu|default('1500') }}