Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

network-interface-debian.j2 2.2KB

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