network/salt/lxc-containers/config

53 lines
1.4 KiB
Plaintext

# For lxcfs and sane defaults
lxc.include = /usr/share/lxc/config/common.conf
lxc.utsname = {{ id }}
# Handled by lxc@.service
lxc.start.auto = 0
lxc.rootfs = /var/lib/lxc/{{ id }}/rootfs
lxc.rootfs.backend = dir
lxc.autodev = 1
lxc.kmsg = 0
{%- set n = 0 %}
{%- for net, conf in container['interfaces'].items() %}
lxc.network.type={{ conf['type'] }}
lxc.network.flags=up
lxc.network.hwaddr={{ hwaddr_prefix }}:{{ n.__str()__.rjust(2, '0') }}
{%- if conf['type'] == 'veth' %}
lxc.network.veth.pair={{ id }}-{{ net }}
{%- endif %}
{%- set hosts = pillar['hosts-inet'].get(net) %}
{%- set inet_addr = hosts and hosts.get(id) %}
{%- if inet_addr %}
{%- set prefix_len = pillar['subnets-inet'][net].split('/')[1] %}
lxc.network.ipv4={{ inet_addr }}/{{ prefix_len }}
{%- endif %}
{%- if conf['type'] == 'veth' %}
lxc.network.link=br-{{ net }}
{%- elif conf['type'] == 'phys' %}
lxc.network.link=bond0.{{ pillar['vlans'].get(net) }}
{%- endif %}
lxc.network.name={{ net }}
{%- set gw = conf.get('gw') %}
{%- if gw %}
lxc.network.ipv4.gateway={{ pillar['hosts-inet'][net][gw] }}
{%- endif %}
#lxc.network.ipv6=
#lxc.network.ipv6.gateway=fe80::1
{%- set n = n + 1 %}
{%- endfor %}
lxc.cap.drop = sys_module sys_time sys_nice sys_pacct sys_rawio sys_time mknod
lxc.cgroup.memory.limit_in_bytes = 512M
lxc.cgroup.memory.kmem.tcp.limit_in_bytes = 128M
# tuntap
lxc.cgroup.devices.allow = c 10:200 rw
lxc.hook.autodev = /var/lib/lxc/autodev.sh