diff options
author | Christian Pointner <equinox@spreadspace.org> | 2020-07-21 00:20:24 +0200 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2020-07-21 00:20:24 +0200 |
commit | 0ab459a63c0a083a45dc21c781729d7ff770d6b4 (patch) | |
tree | 06dd8a71421ebd17ceb544702c3f37e67a23d5c3 /roles/vm/guest/network/templates | |
parent | Merge branch 'topic/installer-again' (diff) | |
parent | vm/host network using ifconfig includes (diff) |
Merge branch 'topic/network-overlays-exteneded'
Diffstat (limited to 'roles/vm/guest/network/templates')
4 files changed, 37 insertions, 36 deletions
diff --git a/roles/vm/guest/network/templates/interfaces.j2 b/roles/vm/guest/network/templates/interfaces.j2 index 8c288669..8e2f324c 100644 --- a/roles/vm/guest/network/templates/interfaces.j2 +++ b/roles/vm/guest/network/templates/interfaces.j2 @@ -13,44 +13,10 @@ auto {{ interface.name }} iface {{ interface.name }} inet static pre-up echo 0 > /proc/sys/net/ipv6/conf/$IFACE/accept_ra pre-up echo 0 > /proc/sys/net/ipv6/conf/$IFACE/autoconf - address {{ interface.address | ipaddr('address') }} - netmask {{ interface.address | ipaddr('netmask') }} -{% if 'overlay' in interface %} - up /bin/ip addr add dev $IFACE {{ interface.overlay }}/32 -{% for route in interface.static_routes | default([]) %} - up /bin/ip route add {{ route.destination }} via {{ route.gateway }} src {{ interface.overlay }} -{% endfor %} -{% if 'gateway' in interface %} - up /bin/ip route add default via {{ interface.gateway }} src {{ interface.overlay }} - down /bin/ip route del default via {{ interface.gateway }} src {{ interface.overlay }} -{% for route in interface.static_routes | default([]) | reverse %} - down /bin/ip route del {{ route.destination }} via {{ route.gateway }} src {{ interface.overlay }} -{% endfor %} -{% endif %} - down /bin/ip addr del dev $IFACE {{ interface.overlay }}/32 -{% else %} -{% if 'gateway' in interface %} - gateway {{ interface.gateway }} -{% endif %} -{% for route in interface.static_routes | default([]) %} - up /bin/ip route add {{ route.destination }} via {{ route.gateway }} -{% endfor %} -{% for route in interface.static_routes | default([]) | reverse %} - down /bin/ip route del {{ route.destination }} via {{ route.gateway }} -{% endfor %} -{% endif %} +{% include 'interfaces/' + (interface.config | default('simple')) + '.j2' %} {% if 'address6' in interface %} iface {{ interface.name }} inet6 static - address {{ interface.address6 }} -{% if 'gateway6' in interface %} - gateway {{ interface.gateway6 }} -{% endif %} -{% for route in interface.static_routes6 | default([]) %} - up /bin/ip -6 route add {{ route.destination }} via {{ route.gateway }} -{% endfor %} -{% for route in interface.static_routes6 | default([]) | reverse %} - down /bin/ip -6 route del {{ route.destination }} via {{ route.gateway }} -{% endfor %} +{% include 'interfaces/' + (interface.config | default('simple6')) + '.j2' %} {% endif %} {% endfor %} diff --git a/roles/vm/guest/network/templates/interfaces/overlay.j2 b/roles/vm/guest/network/templates/interfaces/overlay.j2 new file mode 100644 index 00000000..a3262f9c --- /dev/null +++ b/roles/vm/guest/network/templates/interfaces/overlay.j2 @@ -0,0 +1,14 @@ + address {{ interface.address | ipaddr('address') }} + netmask {{ interface.address | ipaddr('netmask') }} + up /bin/ip addr add dev $IFACE {{ interface.overlay }}/32 +{% for route in interface.static_routes | default([]) %} + up /bin/ip route add {{ route.destination }} via {{ route.gateway }}{% if 'source' in route %} src {{ route.source }}{% endif %} +{% endfor %} +{% if 'gateway' in interface %} + up /bin/ip route add default via {{ interface.gateway }} src {{ interface.overlay }} + down /bin/ip route del default via {{ interface.gateway }} src {{ interface.overlay }} +{% for route in interface.static_routes | default([]) | reverse %} + down /bin/ip route del {{ route.destination }} via {{ route.gateway }}{% if 'source' in route %} src {{ route.source }}{% endif %} +{% endfor %} +{% endif %} + down /bin/ip addr del dev $IFACE {{ interface.overlay }}/32 diff --git a/roles/vm/guest/network/templates/interfaces/simple.j2 b/roles/vm/guest/network/templates/interfaces/simple.j2 new file mode 100644 index 00000000..c5b7dadc --- /dev/null +++ b/roles/vm/guest/network/templates/interfaces/simple.j2 @@ -0,0 +1,11 @@ + address {{ interface.address | ipaddr('address') }} + netmask {{ interface.address | ipaddr('netmask') }} +{% if 'gateway' in interface %} + gateway {{ interface.gateway }} +{% endif %} +{% for route in interface.static_routes | default([]) %} + up /bin/ip route add {{ route.destination }} via {{ route.gateway }}{% if 'source' in route %} src {{ route.source }}{% endif %} +{% endfor %} +{% for route in interface.static_routes | default([]) | reverse %} + down /bin/ip route del {{ route.destination }} via {{ route.gateway }}{% if 'source' in route %} src {{ route.source }}{% endif %} +{% endfor %} diff --git a/roles/vm/guest/network/templates/interfaces/simple6.j2 b/roles/vm/guest/network/templates/interfaces/simple6.j2 new file mode 100644 index 00000000..37fda07a --- /dev/null +++ b/roles/vm/guest/network/templates/interfaces/simple6.j2 @@ -0,0 +1,10 @@ + address {{ interface.address6 }} +{% if 'gateway6' in interface %} + gateway {{ interface.gateway6 }} +{% endif %} +{% for route in interface.static_routes6 | default([]) %} + up /bin/ip -6 route add {{ route.destination }} via {{ route.gateway }}{% if 'source' in route %} src {{ route.source }}{% endif %} +{% endfor %} +{% for route in interface.static_routes6 | default([]) | reverse %} + down /bin/ip -6 route del {{ route.destination }} via {{ route.gateway }}{% if 'source' in route %} src {{ route.source }}{% endif %} +{% endfor %} |