lxc-containers: generate hwaddrs
This commit is contained in:
parent
67056cf2fa
commit
89be4dae61
|
@ -10,9 +10,11 @@ lxc.rootfs.backend = dir
|
||||||
lxc.autodev = 1
|
lxc.autodev = 1
|
||||||
lxc.kmsg = 0
|
lxc.kmsg = 0
|
||||||
|
|
||||||
|
{%- set n = 0 %}
|
||||||
{%- for net, conf in container['interfaces'].items() %}
|
{%- for net, conf in container['interfaces'].items() %}
|
||||||
lxc.network.type={{ conf['type'] }}
|
lxc.network.type={{ conf['type'] }}
|
||||||
lxc.network.flags=up
|
lxc.network.flags=up
|
||||||
|
lxc.network.hwaddr={{ hwaddr_prefix }}:{{ n.__str()__.rjust(2, '0') }}
|
||||||
{%- if conf['type'] == 'veth' %}
|
{%- if conf['type'] == 'veth' %}
|
||||||
lxc.network.veth.pair={{ id }}-{{ net }}
|
lxc.network.veth.pair={{ id }}-{{ net }}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
@ -34,6 +36,8 @@ lxc.network.ipv4.gateway={{ pillar['hosts-inet'][net][gw] }}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
#lxc.network.ipv6=
|
#lxc.network.ipv6=
|
||||||
#lxc.network.ipv6.gateway=fe80::1
|
#lxc.network.ipv6.gateway=fe80::1
|
||||||
|
|
||||||
|
{%- set n = n + 1 %}
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
lxc:
|
lxc:
|
||||||
pkg.installed: []
|
pkg.installed: []
|
||||||
|
|
||||||
{% for id, container in pillar['containers'].items() %}
|
{%- set n = 0 %}
|
||||||
|
{%- for id, container in pillar['containers'].items() %}
|
||||||
|
|
||||||
/var/lib/lxc/{{ id }}:
|
/var/lib/lxc/{{ id }}:
|
||||||
cmd.run:
|
cmd.run:
|
||||||
|
@ -17,6 +18,7 @@ lxc:
|
||||||
- context:
|
- context:
|
||||||
id: {{ id }}
|
id: {{ id }}
|
||||||
container: {{ container }}
|
container: {{ container }}
|
||||||
|
hwaddr_prefix: '0A:14:48:01:{{ n.__str__().rjust(2, '0') }}'
|
||||||
- require:
|
- require:
|
||||||
- cmd: /var/lib/lxc/{{ id }}
|
- cmd: /var/lib/lxc/{{ id }}
|
||||||
|
|
||||||
|
@ -55,4 +57,5 @@ start-{{ id }}:
|
||||||
require:
|
require:
|
||||||
- service: autostart-{{ id }}
|
- service: autostart-{{ id }}
|
||||||
|
|
||||||
|
{%- set n = n + 1 %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
Loading…
Reference in New Issue