You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.2KB

  1. {{ ansible_managed | comment }}
  2. {% set netif = item %}
  3. ### netif {{netif}}
  4. {% set dev = netifs[netif].device | default( 'enx' + netifs[netif].mac | regex_replace(':') ) %}
  5. auto {{dev}}
  6. {% if netifs[netif].type == "virt_ptp" %}
  7. # virt_pointopoint -> {{virt_host}} {{netifs[netif].virt_host_netif}}
  8. # ipv4
  9. {% for ip in netifs[netif] | json_query("ips[].ip") | ipv4("address") %}
  10. iface {{ dev }} inet static
  11. address {{ ip }}
  12. netmask 32
  13. {% if loop.index == 1 %}
  14. {% set gateway4 = hostvars[virt_host].netifs[netifs[netif].virt_host_netif] | json_query("ips[].ip") | ipv4("address") | first %}
  15. pointopoint {{ gateway4 }}
  16. gateway {{ gateway4 }}
  17. {% endif %}
  18. {% endfor %}
  19. # ipv6
  20. {% for ip in netifs[netif] | json_query("ips[].ip") | ipv6("address") %}
  21. iface {{ dev }} inet6 static
  22. address {{ ip }}
  23. netmask 128
  24. {% if loop.index == 1 %}
  25. gateway {{ hostvars[virt_host].netifs[netifs[netif].virt_host_netif].ll6 }}
  26. {% endif %}
  27. {% endfor %}
  28. {% else %}
  29. {% if netifs[netif].type == "bridge" %}
  30. # bridge
  31. iface {{ dev }} inet manual
  32. {% if netifs[netif].devices is defined %}
  33. bridge_ports {{ netifs[netif].devices | join(" ") }}
  34. {% else %}
  35. bridge_ports none
  36. {% endif %}
  37. {% endif %}
  38. {% for ip in netifs[netif].ips %}
  39. {% if ip.ip | ipv6 %}
  40. # ipv6 {{ip.ip}}
  41. iface {{ dev }} inet6 static
  42. address {{ ip.ip | ipv6('address') }}
  43. netmask {{ ip.ip | ipv6('prefix') }}
  44. {% endif %}
  45. {% if ip.ip | ipv4 %}
  46. # ipv4 {{ip.ip}}
  47. iface {{ dev }} inet static
  48. address {{ ip.ip | ipv4('address') }}
  49. network {{ ip.ip | ipv4('network') }}
  50. netmask {{ ip.ip | ipv4('prefix') }}
  51. broadcast {{ ip.ip | ipv4('broadcast') }}
  52. {% if loop.index == 1 and netifs[netif].routes is defined %}
  53. {% set default_route = netifs[netif].routes | json_query("[?to=='default']") | first %}
  54. gateway {{default_route.via}}
  55. {% endif %}
  56. {% endif %}
  57. {% endfor %}
  58. {% endif %}
  59. # dns resolvers
  60. iface {{ dev }} inet manual
  61. {% if netifs[netif].dns_resolvers is defined %}
  62. dns-nameservers {{ netifs[netif].dns_resolvers | join(" ") }}
  63. {% endif %}
  64. {% if netifs[netif].dns_search is defined%}
  65. dns-search {{ netifs[netif].dns_search | join(" ") }}
  66. {% endif %}