50 lines
1.4 KiB
Django/Jinja
50 lines
1.4 KiB
Django/Jinja
# {{ ansible_managed }}
|
|
|
|
[Match]
|
|
Name={{ item.1.interface }}
|
|
|
|
{% if item.1.address is defined %}
|
|
[Address]
|
|
{% set addr_cidr = (item.1.address | string + '/' + item.1.netmask | string) | ipaddr('prefix') %}
|
|
Address={{ item.1.address }}/{{ addr_cidr }}
|
|
{% elif item.1.address is defined and (item.1.address | lower) == 'dhcp' %}
|
|
[DHCP]
|
|
UseDNS={{ (item.1.usedns | default(false) | bool) | ternary('yes', 'no') }}
|
|
UseNTP=yes
|
|
RouteMetric=20
|
|
{% endif %}
|
|
|
|
{% for route in item.1.static_routes | default([]) %}
|
|
[Route]
|
|
Source={{ route['cidr'] }}
|
|
Gateway={{ route['gateway'] }}
|
|
Metric={{ 20 + loop.index }}
|
|
|
|
{% endfor %}
|
|
[Network]
|
|
{% if item.1.address is defined %}
|
|
{% set addr_cidr = (item.1.address | string + '/' + item.1.netmask | string) | ipaddr('prefix') %}
|
|
Address={{ item.1.address }}/{{ addr_cidr }}
|
|
{% elif item.1.address is defined and (item.1.address | lower) == 'dhcp' %}
|
|
DHCP=yes
|
|
{% endif %}
|
|
{% if item.1.address is defined and item.1.gateway is defined %}
|
|
Gateway={{ item.1.gateway }}
|
|
{% endif %}
|
|
{% if item.1.bridge is defined %}
|
|
Bridge={{ item.1.bridge }}
|
|
{% elif item.1.bond is defined %}
|
|
Bond={{ item.1.bond }}
|
|
{% elif item.1.vlan is defined %}
|
|
VLAN={{ item.1.vlan }}
|
|
{% elif item.1.macvlan is defined %}
|
|
MACVLAN={{ item.1.macvlan }}
|
|
{% elif item.1.vxlan is defined %}
|
|
VXLAN={{ item.1.vxlan }}
|
|
{% endif %}
|
|
|
|
[Link]
|
|
{% if item.1.mtu is defined %}
|
|
MTUBytes={{ item.1.mtu }}
|
|
{% endif %}
|