interface.j2 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. {% if item.comment is defined and item.comment %}
  2. # {{ item.comment }}
  3. {% endif %}
  4. interface {{ item.interface }} {
  5. {% if item.options is defined and item.options %}
  6. {{ item.options | indent(2, true) }}
  7. {% endif %}
  8. {% if item.prefixes is defined and item.prefixes %}
  9. {% if hostvars[inventory_hostname]["ansible_" + item.interface].ipv6 is defined and hostvars[inventory_hostname]["ansible_" + item.interface].ipv6 %}
  10. {% for element in item.prefixes %}
  11. {% if element.prefix is defined and element.prefix %}
  12. {% if element.comment is defined and element.comment %}
  13. # {{ element.comment }}
  14. {% endif %}
  15. prefix {{ element.prefix }} {
  16. {% if element.options is defined and element.options %}
  17. {{ element.options | indent(4, true) }}
  18. {% endif %}
  19. };
  20. {% endif %}
  21. {% endfor %}
  22. {% else %}
  23. # No IPv6 prefixes present on the interface, prefix advertisement disabled
  24. {% endif %}
  25. {% endif %}
  26. {% if item.routes is defined and item.routes %}
  27. {% for element in item.routes %}
  28. {% if element.route is defined and element.route %}
  29. {% if element.comment is defined and element.comment %}
  30. # {{ element.comment }}
  31. {% endif %}
  32. route {{ element.route }} {
  33. {% if element.options is defined and element.options %}
  34. {{ element.options | indent(4, true) }}
  35. {% endif %}
  36. };
  37. {% endif %}
  38. {% endfor %}
  39. {% endif %}
  40. {% if item.nameservers is defined and item.nameservers %}
  41. {% for element in item.nameservers %}
  42. {% if element.comment is defined and element.comment %}
  43. # {{ element.comment }}
  44. {% endif %}
  45. RDNSS {{ element.rdnss | join(" ") }} {
  46. {% if element.options is defined and element.options %}
  47. {{ element.options | indent(4, true) }}
  48. {% endif %}
  49. };
  50. {% endfor %}
  51. {% else %}
  52. {% if hostvars[inventory_hostname]["ansible_" + item.interface].ipv6 is defined and hostvars[inventory_hostname]["ansible_" + item.interface].ipv6 %}
  53. {% set radvd_tpl_nameservers = hostvars[inventory_hostname]["ansible_" + item.interface].ipv6 | map(attribute='address') | list %}
  54. # Advertise router on {{ item.interface }} interface as local DNS server
  55. RDNSS {{ radvd_tpl_nameservers | join(" ") }} {
  56. };
  57. {% endif %}
  58. {% endif %}
  59. {% if item.domains is defined and item.domains %}
  60. {% for element in item.domains %}
  61. {% if (element.dnssl is defined and element.dnssl[0] not in [ 'False', 'false' ] and element.dnssl) %}
  62. {% if element.comment is defined and element.comment %}
  63. # {{ element.comment }}
  64. {% endif %}
  65. DNSSL {{ element.dnssl | join(" ") }} {
  66. {% if element.options is defined and element.options %}
  67. {{ element.options | indent(4, true) }}
  68. {% endif %}
  69. };
  70. {% endif %}
  71. {% endfor %}
  72. {% endif %}
  73. {% if item.clients is defined and item.clients %}
  74. clients {
  75. {% for element in item.clients %}
  76. {% if element is defined and element %}
  77. {{ element }};
  78. {% endif %}
  79. {% endfor %}
  80. };
  81. {% endif %}
  82. };