72 lines
2.1 KiB
Django/Jinja
72 lines
2.1 KiB
Django/Jinja
{{ ansible_header | comment }}
|
||
|
||
{% set vlan_name = (item.name | replace('_', '-')) %}
|
||
{% if vlan_name == "auto" %}
|
||
auto {{ interfaces[item.name] }}
|
||
iface {{ interfaces[item.name] }} inet dhcp
|
||
iface {{ interfaces[item.name] }} inet6 auto
|
||
{% else %}
|
||
{% set subnet_network = (lookup('ldap', 'network', vlan_name) | ansible.utils.ipaddr('network')) %}
|
||
{% set subnet_netmask = (lookup('ldap', 'network', vlan_name) | ansible.utils.ipaddr('netmask')) %}
|
||
{% set ips = query('ldap', 'ip', ansible_hostname, vlan_name) %}
|
||
{% if (ips | ansible.utils.ipv4 | length) > 0 %}
|
||
auto {{ interfaces[item.name] }}
|
||
iface {{ interfaces[item.name] }} inet static
|
||
{% for ip in (ips | ansible.utils.ipv4) %}
|
||
address {{ ip }}
|
||
{% endfor %}
|
||
network {{ subnet_network }}
|
||
netmask {{ subnet_netmask }}
|
||
{% if item.gateway is defined %}
|
||
gateway {{ item.gateway }}
|
||
{% endif %}
|
||
{% if item.metric is defined %}
|
||
metric {{ item.metric }}
|
||
{% endif %}
|
||
{% if item.dns is defined %}
|
||
dns-nameservers {{ item.dns }}
|
||
{% endif %}
|
||
{% if vlan_name == 'srv' %}
|
||
dns-search crans.org
|
||
{% else %}
|
||
dns-search {{ vlan_name }}.crans.org
|
||
{% endif %}
|
||
up /sbin/ip link set $IFACE alias {{ vlan_name }}
|
||
{% if ansible_local.interfaces.sup_if_4 is defined %}
|
||
{% if interfaces[item.name] in ansible_local.interfaces.sup_if_4 %}
|
||
{% for line in ansible_local.interfaces.sup_if_4[interfaces[item.name]] %}
|
||
{{ line }}
|
||
{% endfor %}
|
||
{% endif %}
|
||
{% endif %}
|
||
{% if item.extra is defined %}
|
||
{% for line in item.extra %}
|
||
{{ line }}
|
||
{% endfor %}
|
||
{% endif %}
|
||
{% endif %}
|
||
|
||
{% if (ips | ansible.utils.ipv6 | length) > 0 %}
|
||
iface {{ interfaces[item.name] }} inet6 static
|
||
{% for ip in (ips | ansible.utils.ipv6) %}
|
||
address {{ ip }}/64
|
||
{% endfor %}
|
||
{% if item.gateway_v6 is defined %}
|
||
gateway {{ item.gateway_v6 }}
|
||
{% endif %}
|
||
accept_ra 0
|
||
{% if ansible_local.interfaces.sup_if_6 is defined %}
|
||
{% if interfaces[item.name] in ansible_local.interfaces.sup_if_6 %}
|
||
{% for line in ansible_local.interfaces.sup_if_6[interfaces[item.name]] %}
|
||
{{ line }}
|
||
{% endfor %}
|
||
{% endif %}
|
||
{% endif %}
|
||
{% if item.extra_v6 is defined %}
|
||
{% for line in item.extra_v6 %}
|
||
{{ line }}
|
||
{% endfor %}
|
||
{% endif %}
|
||
{% endif %}
|
||
{% endif %}
|