Files
Ansible-Bootstrap/roles/configuration/templates/network_eni.j2
T

29 lines
1.0 KiB
Django/Jinja

auto lo
iface lo inet loopback
{% for iface in system_cfg.network.interfaces %}
{% set ifname = iface.name if (iface.name | default('') | string | length) else (configuration_eni_detected[loop.index0] | default('eth' ~ loop.index0)) %}
auto {{ ifname }}
{% if iface.ip | default('') | string | length %}
iface {{ ifname }} inet static
address {{ iface.ip }}/{{ iface.prefix }}
{% if iface.gateway | default('') | string | length %}
gateway {{ iface.gateway }}
{% endif %}
{% if loop.index0 == 0 and configuration_dns_list %}
dns-nameservers {{ configuration_dns_list | join(' ') }}
{% endif %}
{% if loop.index0 == 0 and configuration_dns_search %}
dns-search {{ configuration_dns_search | join(' ') }}
{% endif %}
{# One stanza per extra address: classic ifupdown takes one address per stanza, ifupdown2 merges them. #}
{% for address in iface.extra_addresses | default([]) %}
iface {{ ifname }} inet static
address {{ address }}
{% endfor %}
{% else %}
iface {{ ifname }} inet dhcp
{% endif %}
{% endfor %}