Support configuring IPv6 interfaces on Debian/Ubuntu
This change modifies the Debian /etc/network/interfaces.d template
to support provisioning an IPv6 address on a network interface.
Change-Id: I413a68a2eb35e718025759988ed889015b433643
Signed-off-by: Cian Johnston <cian.johnston@est.tech>
diff --git a/playbooks/roles/configure-targethosts/templates/Debian.interface.j2 b/playbooks/roles/configure-targethosts/templates/Debian.interface.j2
index 513c987..d514709 100644
--- a/playbooks/roles/configure-targethosts/templates/Debian.interface.j2
+++ b/playbooks/roles/configure-targethosts/templates/Debian.interface.j2
@@ -3,19 +3,23 @@
{%- for selected_net_name, selected_net in idf.net_config.items() if node.interfaces[selected_net.interface].mac_address == macaddress -%}
{%- set selected_inf = node.interfaces[selected_net.interface] -%}
{%- set ifname = device if selected_inf.vlan == 'native' else device + '.' + selected_inf.vlan -%}
+{%- set proto = "inet6" if selected_net.network | ipv6 else "inet" -%}
+{%- set method = selected_inf.address if selected_inf.address in ["dhcp", "manual"] else "static" -%}
auto {{ ifname }}
-{% if selected_inf.address == "dhcp" %}
-iface {{ ifname }} inet dhcp
+iface {{ ifname }} {{ proto }} {{ method }}
{% if selected_net.gateway is defined %}
up route add default gateway {{ selected_net.gateway | ipaddr('address') }}
{% endif %}
-{% elif selected_inf.address == "manual" %}
-iface {{ ifname }} inet manual
-{% else %}
-iface {{ ifname }} inet static
+{% if method != "manual" %}
address {{ selected_inf.address | ipaddr('address') }}
+{% endif %}
+{% if selected_inf.address | ipv6 %}
+netmask {{ selected_net.mask }}
+{% endif %}
+{% if selected_inf.address | ipv4 %}
netmask {{ (selected_net.network + "/" + (selected_net.mask | string)) | ipaddr('netmask') }}
+{% endif %}
{% if selected_net.gateway is defined %}
gateway {{ selected_net.gateway | ipaddr('address') }}
{% endif %}
@@ -24,6 +28,5 @@
up route add -net {{ route.network }}/{{ route.mask }} gw {{ route.gateway }}
{% endfor %}
{% endif %}
-{% endif %}
{%- endfor -%}