From cb8fb6ac4fa8508fc571a8025be8f3fac522a641 Mon Sep 17 00:00:00 2001 From: Markus Katharina Brechtel Date: Fri, 12 May 2017 19:32:18 +0000 Subject: [PATCH] current --- defaults/main.yml | 1 - templates/network-interfaces.j2 | 32 +++++++++++++++++++------------- 2 files changed, 19 insertions(+), 14 deletions(-) delete mode 100644 defaults/main.yml diff --git a/defaults/main.yml b/defaults/main.yml deleted file mode 100644 index 222750a..0000000 --- a/defaults/main.yml +++ /dev/null @@ -1 +0,0 @@ -#network_interfaces_default_interface: "{{ undefined | default(ansible_default_ipv6.interface) | default(ansible_default_ipv4.interface) }}" diff --git a/templates/network-interfaces.j2 b/templates/network-interfaces.j2 index e1c1e5c..07f8c95 100644 --- a/templates/network-interfaces.j2 +++ b/templates/network-interfaces.j2 @@ -8,7 +8,9 @@ iface lo inet loopback {% for netname,netif in network_interfaces.iteritems() %} ### {{ netname }} ### auto {{ netif.device }} +{% if netif.hotplug | default(false) %} allow-hotplug {{ netif.device }} +{% endif %} {% if netif.bridge is defined %} iface {{ netif.device }} inet manual @@ -16,17 +18,6 @@ iface {{ netif.device }} inet manual bridge_stp {{ netif.bridge.stp | default(false) | ternary('on','off') }} {% endif %} -{% for ipv6 in netif.ipv6 | default([]) %} -iface {{ netif.device }} inet6 {{ ipv6.method }} -{% if ipv6.method == "static" %} - address {{ ipv6.address | ipv6('address') }} - netmask {{ ipv6.address | ipv6('prefix') }} -{% if ipv6.gateway is defined %} - gateway {{ ipv6.gateway | ipv6('address') }} -{% endif %} -{% endif %} -{% endfor %} - {% for ipv4 in netif.ipv4 | default([]) %} iface {{ netif.device }} inet {{ ipv4.method }} {% if ipv4.method == "static" %} @@ -37,8 +28,23 @@ iface {{ netif.device }} inet {{ ipv4.method }} {% if ipv4.gateway is defined %} gateway {{ ipv4.gateway | ipv4('address') }} {% endif %} -{% if ipv4.gateway is defined %} - gateway {{ ipv4.gateway | ipv4('address') }} +{% endif %} +{% endfor %} + +{% for ipv6 in netif.ipv6 | default([]) %} +iface {{ netif.device }} inet6 {{ ipv6.method }} +{% if ipv6.method == "static" %} + address {{ ipv6.address | ipv6('address') }} + netmask {{ ipv6.address | ipv6('prefix') }} +{% if ipv6.gateway is defined %} +{% if ipv6.gateway | ipv6(ipv6.address) %} + gateway {{ ipv6.gateway | ipv6('address') }} +{% else %} + post-up sleep 5; /sbin/ip -family inet6 route add {{ ipv6.gateway }} dev {{ netif.device }} + post-up sleep 5; /sbin/ip -family inet6 route add default via {{ ipv6.gateway }} + pre-down /sbin/ip -family inet6 route del default via {{ ipv6.gateway }} + pre-down /sbin/ip -family inet6 route del {{ ipv6.gateway }} dev {{ netif.device }} +{% endif %} {% endif %} {% endif %} {% endfor %}