From 5d5a6f0b5c78c2b2230597717116820d263dbbf9 Mon Sep 17 00:00:00 2001 From: Benjamin Graillot Date: Tue, 21 Apr 2020 13:24:34 +0200 Subject: [PATCH] [interfaces] Configure adh interface --- roles/interfaces/tasks/main.yml | 7 ++++ .../templates/network/interfaces.d/23-adh.j2 | 38 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 roles/interfaces/templates/network/interfaces.d/23-adh.j2 diff --git a/roles/interfaces/tasks/main.yml b/roles/interfaces/tasks/main.yml index d9751a36..4bf0fc42 100644 --- a/roles/interfaces/tasks/main.yml +++ b/roles/interfaces/tasks/main.yml @@ -32,3 +32,10 @@ dest: /etc/network/interfaces.d/21-fil mode: 0644 when: fil_iface.stdout + +- name: Deploy adh interface config + template: + src: network/interfaces.d/23-adh.j2 + dest: /etc/network/interfaces.d/23-adh + mode: 0644 + when: adh_iface.stdout diff --git a/roles/interfaces/templates/network/interfaces.d/23-adh.j2 b/roles/interfaces/templates/network/interfaces.d/23-adh.j2 new file mode 100644 index 00000000..bc03ccc1 --- /dev/null +++ b/roles/interfaces/templates/network/interfaces.d/23-adh.j2 @@ -0,0 +1,38 @@ +{{ ansible_header | comment }} + +{% set adh = hostvars[inventory_hostname]['ansible_' + adh_iface.stdout] %} +allow-hotplug {{ adh_iface.stdout }} +iface {{ adh_iface.stdout }} inet static + address {{ adh.ipv4.address }} + network {{ adh.ipv4.network }} + netmask {{ adh.ipv4.netmask }} + broadcast {{ adh.ipv4.broadcast }} + gateway {{ adh_gateway }} + mtu 1496 + dns-nameservers {{ adh_dns }} + dns-search crans.org + up /sbin/ip link set $IFACE alias adh +{% if 'interfaces' in ansible_local %} +{% if 'sup_if_4' in ansible_local.interfaces %} +{% if adh_iface.stdout in ansible_local.interfaces.sup_if_4 %} +{% for line in ansible_local.interfaces.sup_if_4[adh_iface.stdout] %} + {{ line }} +{% endfor %} +{% endif %} +{% endif %} +{% endif %} + +iface {{ adh_iface.stdout }} inet6 static + address {{ adh.ipv6[0].address }}/{{ adh.ipv6[0].prefix }} + autoconf 1 + accept_ra 2 + up /sbin/sysctl net/ipv6/conf/$IFACE/accept_ra_defrtr=1 +{% if 'interfaces' in ansible_local %} +{% if 'sup_if_6' in ansible_local.interfaces %} +{% if adh_iface.stdout in ansible_local.interfaces.sup_if_6 %} +{% for line in ansible_local.interfaces.sup_if_6[adh_iface.stdout] %} + {{ line }} +{% endfor %} +{% endif %} +{% endif %} +{% endif %}