Used named veth pairs that match container
The default veth names from LXC make it difficult to tell which veth corresponds to each container. This patch sets a unique veth name that matches the container as well as the network device inside the container. It should make troubleshooting a little easier. Oddly enough, this patch seems to fix or greatly reduce the occurence of the issues seen in ticket 1491440. Partial-Bug: 1491440 Implements: blueprint named-veths Change-Id: I28553fd1b4f36991e11d55d56c3f0f46af9e52be
This commit is contained in:
parent
614b37621b
commit
5e6dea8ab6
@ -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"
|
||||
|
@ -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') }}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user