2021-07-10 02:39:21 +02:00
|
|
|
{{ ansible_managed | comment }}
|
|
|
|
|
|
|
|
network:
|
|
|
|
ethernets:
|
|
|
|
{% for item in lookup('dict', interfaces, wantlist=True) %}
|
|
|
|
{% if item.value.type not in ['wireguard', ] %}
|
2021-07-11 03:18:12 +02:00
|
|
|
{% if not ('bridge' in item.value and item.value.bridge) %}
|
2021-07-10 02:39:21 +02:00
|
|
|
{{ item.key }}:
|
|
|
|
{% if item.value.type == 'dhcp' %}
|
|
|
|
dhcp4: true
|
|
|
|
{% elif item.value.type == 'static' %}
|
|
|
|
dhcp4: false
|
|
|
|
addresses:
|
|
|
|
- {{ item.value.ipv4 }}/{{ item.value.netmaskv4 }}
|
|
|
|
{% if 'gateway' in item.value %}
|
|
|
|
gateway4: {{ item.value.gateway }}
|
|
|
|
{% endif %}
|
|
|
|
nameservers:
|
|
|
|
addresses:
|
|
|
|
- 1.1.1.1
|
|
|
|
{# the nameservers are hardcoded for now #}
|
2021-07-11 03:18:12 +02:00
|
|
|
{% elif item.value.type in ['void', 'manual'] %}
|
|
|
|
dhcp4: false
|
|
|
|
dhcp6: false
|
|
|
|
{% endif %}{# end (type == *) #}
|
|
|
|
{% if 'routes' in item.value %}{# routes #}
|
|
|
|
routes:
|
|
|
|
{% for route in item.value.routes %}
|
|
|
|
- to: {{ route.subnet }}/{{ route.netmask }}
|
|
|
|
via: {{ route.gateway }}
|
|
|
|
metric: 100
|
|
|
|
{% endfor %}
|
|
|
|
{% endif %}{# end routes #}
|
|
|
|
{% endif %}{# end not bridge #}
|
|
|
|
{% endif %}{# end (not in [wireguard, ]) #}
|
|
|
|
{% endfor %}
|
|
|
|
{% if (lookup('dict', interfaces, wantlist=True) | selectattr('value.bridge', 'defined') | selectattr('value.bridge') | list) %}
|
|
|
|
bridges:
|
|
|
|
{% for item in (lookup('dict', interfaces, wantlist=True) | selectattr('value.bridge', 'defined') | selectattr('value.bridge') | list) %}
|
|
|
|
{% if item.value.type not in ['wireguard', ] %}
|
|
|
|
{{ item.key }}:
|
|
|
|
{% if 'interfaces' in item.value and item.value.interfaces %}
|
|
|
|
interfaces: [ {{ item.value.interfaces | join(', ') }} ]
|
2021-07-11 03:26:20 +02:00
|
|
|
{% else %}
|
|
|
|
interfaces: []
|
2021-07-11 03:18:12 +02:00
|
|
|
{% endif %}
|
|
|
|
{% if item.value.type == 'dhcp' %}
|
|
|
|
dhcp4: true
|
|
|
|
{% elif item.value.type == 'static' %}
|
|
|
|
dhcp4: false
|
|
|
|
addresses:
|
|
|
|
- {{ item.value.ipv4 }}/{{ item.value.netmaskv4 }}
|
|
|
|
{% if 'gateway' in item.value %}
|
|
|
|
gateway4: {{ item.value.gateway }}
|
|
|
|
{% endif %}
|
|
|
|
nameservers:
|
|
|
|
addresses:
|
|
|
|
- 1.1.1.1
|
|
|
|
{# the nameservers are hardcoded for now #}
|
|
|
|
{% elif item.value.type in ['void', 'manual'] %}
|
|
|
|
dhcp4: false
|
|
|
|
dhcp6: false
|
2021-07-10 02:39:21 +02:00
|
|
|
{% endif %}{# end (type == *) #}
|
|
|
|
{% if 'routes' in item.value %}{# routes #}
|
|
|
|
routes:
|
|
|
|
{% for route in item.value.routes %}
|
|
|
|
- to: {{ route.subnet }}/{{ route.netmask }}
|
|
|
|
via: {{ route.gateway }}
|
|
|
|
metric: 100
|
|
|
|
{% endfor %}
|
|
|
|
{% endif %}{# end routes #}
|
|
|
|
{% endif %}{# end (not in [wireguard, ]) #}
|
|
|
|
{% endfor %}
|
2021-07-11 03:18:12 +02:00
|
|
|
{% endif %}
|
2021-07-10 02:39:21 +02:00
|
|
|
version: 2
|