vm/network: Support configuring secondary network interfaces
[noc.git] / ansible / roles / vm / network / templates / interfaces.j2
1 # This file describes the network interfaces available on your system
2 # and how to activate them. For more information, see interfaces(5).
3
4 source /etc/network/interfaces.d/*
5
6 # The loopback network interface
7 auto lo
8 iface lo inet loopback
9
10 # The primary network interface
11 auto {{ network.primary.interface }}
12 iface {{ network.primary.interface }} inet static
13   address {{ network.primary.ip }}
14   netmask {{ network.primary.mask }}
15   gateway {{ network.primary.gateway }}
16   pre-up echo 0 > /proc/sys/net/ipv6/conf/$IFACE/accept_ra
17   pre-up echo 0 > /proc/sys/net/ipv6/conf/$IFACE/autoconf
18
19 {% if 'secondary' in network %}
20 # Secondary network interfaces
21 {% for iface, v in network['secondary'].items() %}
22 auto {{ iface }}
23 iface {{ iface }} inet static
24   address {{ v.ip }}
25   netmask {{ v.mask }}
26   pre-up echo 0 > /proc/sys/net/ipv6/conf/$IFACE/accept_ra
27   pre-up echo 0 > /proc/sys/net/ipv6/conf/$IFACE/autoconf
28
29 {% endfor %}
30 {% endif %}