summaryrefslogtreecommitdiff
path: root/roles/vm/host/network/templates/interfaces.j2
blob: 0151eb4507f68c0058af037df13247b65bd2b32b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback


## pyhiscal interfaces

{# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=990428
{% for interface in network.bonds | default([]) | map(attribute='slaves') | flatten | union(network.vlans | default({}) | list) | difference(network.bonds | default([]) | map(attribute='name') | list) | sort | unique %}
#}
{% for interface in network.vlans | default({}) | list | difference(network.bonds | default([]) | map(attribute='name') | list) | sort | unique %}
auto {{ interface }}
iface {{ interface }} inet manual
  pre-up echo 0 > /proc/sys/net/ipv6/conf/$IFACE/accept_ra
  pre-up echo 0 > /proc/sys/net/ipv6/conf/$IFACE/autoconf

{% endfor %}

{% for bond in network.bonds | default([]) %}
## Bond: {{ bond.name }}

{%   set matched = network.interfaces | selectattr('name', 'eq', bond.name) | list %}
auto {{ bond.name }}
iface {{ bond.name }} inet {{ ((matched | length) == 0) | ternary('manual', 'static') }}
  up echo 0 > /proc/sys/net/ipv6/conf/$IFACE/accept_ra
  up echo 0 > /proc/sys/net/ipv6/conf/$IFACE/autoconf
  bond-mode {{ bond.mode }}
  bond-slaves {{ bond.slaves | sort | join(' ') }}
{%   for option in (bond.options | default({}) | list | sort) %}
  bond-{{ option }} {{ bond.options[option] }}
{%   endfor %}
{%   if (matched | length) > 0 %}
{%     set interface = matched | first %}
{%     if 'content' in interface %}
  {{ interface.content | indent(2) }}
{%     else %}
{%       include 'interfaces/' + (interface.template | default('simple')) + '.j2' %}
{%     endif %}
{%     if 'content6' in interface or 'address6' in interface %}

iface {{ interface.name }} inet6 static
{%       if 'content6' in interface %}
  {{ interface.content6 | indent(2) }}
{%       else %}
{%         include 'interfaces/' + (interface.template6 | default('simple6')) + '.j2' %}
{%       endif %}
{%     endif %}
{%   endif %}


{% endfor %}
{% for parent in (network.vlans | default({}) | list | sort) %}
## vlan interfaces @ {{ parent }}

{%   for vlan in network.vlans[parent] %}
{%     set interface_name = parent+'.'+(vlan | string) %}
{%     set matched = network.interfaces | selectattr('name', 'eq', interface_name) | list %}
auto {{ interface_name }}
iface {{ interface_name }} inet {{ ((matched | length) == 0) | ternary('manual', 'static') }}
  up echo 0 > /proc/sys/net/ipv6/conf/$IFACE/accept_ra
  up echo 0 > /proc/sys/net/ipv6/conf/$IFACE/autoconf
{%   if (matched | length) > 0 %}
{%     set interface = matched | first %}
{%     if 'content' in interface %}
  {{ interface.content | indent(2) }}
{%     else %}
{%       include 'interfaces/' + (interface.template | default('simple')) + '.j2' %}
{%     endif %}
{%     if 'content6' in interface or 'address6' in interface %}

iface {{ interface.name }} inet6 static
{%       if 'content6' in interface %}
  {{ interface.content6 | indent(2) }}
{%       else %}
{%         include 'interfaces/' + (interface.template6 | default('simple6')) + '.j2' %}
{%       endif %}
{%     endif %}
{%   endif %}

{%   endfor %}

{% endfor %}

## source bridge configs

source /etc/network/interfaces.d/*