vm-ansible/roles/netplan/templates/netplan.yaml

42 lines
1.2 KiB
YAML
Raw Normal View History

# {{ansible_managed}}
network:
version: 2
renderer: networkd
ethernets:
2022-04-13 19:23:12 +02:00
{{ ansible_default_ipv4.interface }}:
dhcp4: true
2022-02-05 19:10:11 +01:00
dhcp-identifier: mac
dhcp4-overrides:
use-routes: false
2022-04-16 19:55:29 +02:00
{% if netplan.default_gateway is defined and netplan.default_gateway|length > 0 %}
2022-04-16 19:09:47 +02:00
gateway4: {{netplan.default_gateway}}
2022-04-16 19:56:38 +02:00
{% endif %}
2022-04-16 19:55:29 +02:00
{% if netplan.additionalinterfaces is defined and netplan.additionalinterfaces|length > 0 %}
{% for interface in netplan.additionalinterfaces %}
2022-04-16 19:09:47 +02:00
{{ interface.name }}:
dhcp4: {{ interface.dhcp4 }}
dhcp6: {{ interface.dhcp6 }}
dhcp-identifier: mac
dhcp4-overrides:
use-routes: false
2022-04-16 19:55:29 +02:00
{% if interface.addresses is defined and interface.addresses|length > 0 %}
2022-04-16 19:09:47 +02:00
addresses:
2022-04-16 19:55:29 +02:00
{% for address in interface.addresses %}
2022-04-16 19:09:47 +02:00
- {{address}}
2022-04-16 19:56:38 +02:00
{% endfor %}
{% endif %}
2022-04-16 19:55:29 +02:00
{% if interface.gateway4 is defined and interface.gateway4|length > 0 %}
2022-04-16 19:09:47 +02:00
gateway4: {{interface.gateway4}}
2022-04-16 19:56:38 +02:00
{% endif %}
2022-04-16 19:55:29 +02:00
{% if interface.gateway6 is defined and interface.gateway6|length > 0 %}
2022-04-16 19:09:47 +02:00
gateway4: {{interface.gateway6}}
2022-04-16 19:56:38 +02:00
{% endif %}
2022-04-16 19:55:29 +02:00
{% if interface.denydns %}
2022-04-16 19:09:47 +02:00
nameservers:
addresses: []
search: []
2022-04-16 19:56:38 +02:00
{% endif %}
{% endfor %}
{% endif %}
2022-04-16 19:55:29 +02:00
...