ansible/roles/network/templates/systemd-network.j2

42 lines
1.2 KiB
Plaintext
Raw Normal View History

2019-03-27 07:05:37 +00:00
# {{ ansible_managed }}
2019-10-05 21:43:05 +00:00
{% if item is defined %}
{% if item.name is defined %}
2019-03-27 07:05:37 +00:00
[Match]
Name={{ item.name }}
2019-10-05 21:43:05 +00:00
{% endif %}
{% if item.address is defined %}
2019-03-27 07:05:37 +00:00
[Network]
2019-10-05 21:43:05 +00:00
{% for addr in item.address %}
Address={{ addr }}
2019-03-27 07:05:37 +00:00
{% endfor %}
{% endif %}
2019-10-05 21:43:05 +00:00
{% if item.gateway4 is defined %}
Gateway={{ item.gateway4 }}
{% endif %}
{% if item.gateway6 is defined %}
Gateway={{ item.gateway6 }}
{% endif %}
2019-03-27 07:05:37 +00:00
{% else %}
2019-10-05 21:43:05 +00:00
{# Default network configuration #}
{% if ansible_default_ipv4.interface is defined %}
[Match]
Name={{ ansible_default_ipv4.interface }}
{% if ansible_default_ipv4.address is defined or ansible_default_ipv6.address is defined %}
[Network]
{% if ansible_default_ipv4.address is defined %}
2022-08-31 03:30:13 +00:00
Address={{ ansible_default_ipv4.address }}/{{ (ansible_default_ipv4.network + "/" + ansible_default_ipv4.netmask) | ansible.utils.ipaddr('prefix') }}
2019-10-05 21:43:05 +00:00
{% endif %}
{% if ansible_default_ipv6.address is defined %}
Address={{ ansible_default_ipv6.address }}/{{ ansible_default_ipv6.prefix }}
{% endif %}
{% if ansible_default_ipv4.gateway is defined %}
Gateway={{ ansible_default_ipv4.gateway }}
{% endif %}
{% if ansible_default_ipv6.gateway is defined %}
Gateway={{ ansible_default_ipv6.gateway }}
{% endif %}
{% endif %}
{% endif %}
2019-03-27 07:05:37 +00:00
{% endif %}