1
0
IaC/ansible/playbooks/templates/vlan.network.j2

51 lines
1.2 KiB
Django/Jinja

[Match]
Name={{ item.name | regex_replace('^[0-9]*-', '') | regex_replace('\.network', '') }}
[Link]
ARP={{ item.arp | default(true) }}
[Network]
DHCP={{ item.dhcp | default(true) }}
LinkLocalAddressing=False
LLDP={{ item.lldp | default(true) }}
{% if item.nameserver is defined and item.nameserver.ipv4 is defined -%}
{% for nameserver in item.nameserver.ipv4 -%}
DNS={{ nameserver }}
{% endfor -%}
{% endif -%}
{% if item.nameserver is defined and item.nameserver.ipv6 is defined -%}
{% for nameserver in item.nameserver.ipv6 -%}
DNS={{ nameserver }}
{% endfor -%}
{% endif -%}
{% if item.address is defined %}
[Address]
{% if item.address.ipv4 is defined -%}
{% for address in item.address.ipv4 -%}
Address={{ address }}
{% endfor -%}
{% endif -%}
{% if item.address.ipv6 is defined -%}
{% for address in item.address.ipv6 -%}
Address={{ address }}
{% endfor -%}
{% endif -%}
{% endif -%}
{% if item.gateway is defined and item.gateway.ipv4 is defined %}
[Route]
Destination=0.0.0.0/0
Gateway={{ item.gateway.ipv4 }}
Scope=global
Protocol=static
Type=unicast
{% endif -%}
{% if item.gateway is defined and item.gateway.ipv6 is defined %}
[Route]
Destination=::/0
Gateway={{ item.gateway.ipv6 }}
Protocol=static
Type=unicast
{% endif -%}