|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- {{ ansible_managed | comment }}
- {% set netif = item %}
-
- ### netif {{netif}}
- {% set dev = netifs[netif].device | default( 'enx' + netifs[netif].mac | regex_replace(':') ) %}
- #auto {{dev}}
- allow-hotplug {{dev}}
-
- {% if netifs[netif].type == "virt_ptp" %}
- # virt_pointopoint -> {{virt_host}} {{netifs[netif].virt_host_netif}}
-
- # ipv4
- {% for ip in netifs[netif] | json_query("ips[].ip") | ipv4("address") %}
- iface {{ dev }} inet static
- address {{ ip }}
- netmask 32
- {% if loop.index == 1 %}
- {% set gateway4 = hostvars[virt_host].netifs[netifs[netif].virt_host_netif] | json_query("ips[].ip") | ipv4("address") | first %}
- pointopoint {{ gateway4 }}
- gateway {{ gateway4 }}
- {% endif %}
- {% endfor %}
-
- # ipv6
- {% for ip in netifs[netif] | json_query("ips[].ip") | ipv6("address") %}
- iface {{ dev }} inet6 static
- address {{ ip }}
- netmask 128
- {% if loop.index == 1 %}
- gateway {{ hostvars[virt_host].netifs[netifs[netif].virt_host_netif].ll6 }}
- {% endif %}
- {% endfor %}
-
- {% else %}
-
- {% if netifs[netif].type == "bridge" %}
- # bridge
- iface {{ dev }} inet manual
- {% if netifs[netif].devices is defined %}
- bridge_ports {{ netifs[netif].devices | join(" ") }}
- {% else %}
- bridge_ports none
- {% endif %}
- {% endif %}
-
- {% for ip in netifs[netif].ips %}
- {% if ip.ip | ipv6 %}
- # ipv6 {{ip.ip}}
- iface {{ dev }} inet6 static
- address {{ ip.ip | ipv6('address') }}
- netmask {{ ip.ip | ipv6('prefix') }}
- {% endif %}
- {% if ip.ip | ipv4 %}
- # ipv4 {{ip.ip}}
- iface {{ dev }} inet static
- address {{ ip.ip | ipv4('address') }}
- network {{ ip.ip | ipv4('network') }}
- netmask {{ ip.ip | ipv4('prefix') }}
- broadcast {{ ip.ip | ipv4('broadcast') }}
- {% if loop.index == 1 and netifs[netif].routes is defined %}
- {% set default_route = netifs[netif].routes | json_query("[?to=='default']") | first %}
- gateway {{default_route.via}}
- {% endif %}
- {% endif %}
- {% endfor %}
-
- {% endif %}
-
- # dns resolvers
- iface {{ dev }} inet manual
- {% if netifs[netif].dns_resolvers is defined %}
- dns-nameservers {{ netifs[netif].dns_resolvers | join(" ") }}
- {% endif %}
- {% if netifs[netif].dns_search is defined%}
- dns-search {{ netifs[netif].dns_search | join(" ") }}
- {% endif %}
|