batman.j2 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. # This file is managed by ansible, don't make changes here - they will be overwritten.
  2. {% set indexer = [0] -%}
  3. {% for domaene in domaenen|dictsort %}
  4. {% set group = "supernodes" -%}
  5. {% if domaene[0] == "00" -%}
  6. {% set group = "domaene-test" -%}
  7. {% endif -%}
  8. {% if "domaene-"+domaene[0] in groups -%}
  9. {% set group = "domaene-"+domaene[0] -%}
  10. {% endif -%}
  11. # BEGIN: Domäne-{{domaene[0]}}
  12. {% if indexer.append(indexer.pop() + 1) %}{% endif %}{# increment indexer by 1 #}
  13. # BATMAN Interface für Domäne-{{domaene[0]}}
  14. auto bat{{domaene[0]}}
  15. iface bat{{domaene[0]}} inet6 static
  16. address fe80::dcad:beff:feef:{{ '%02x' % indexer[0] }}{{'%02d' % server_id}}
  17. netmask 64
  18. pre-up modprobe batman-adv
  19. pre-up ip link add bat{{domaene[0]}} type batadv
  20. post-up ip link set address de:ad:be:ef:{{ '%02x' % indexer[0] }}:{{server_id}} dev bat{{domaene[0]}}
  21. post-up ip link set dev bat{{domaene[0]}} up
  22. post-up batctl -m bat{{domaene[0]}} it 10000
  23. {% for host in groups[group] %}
  24. {% if group == "supernodes" %}
  25. {% if domaene[0] in hostvars[host].domaenenliste %}
  26. post-up batctl -m bat{{domaene[0]}} if add t{{domaene[0]}}-{{ host }} ||:
  27. {% endif %}
  28. {% else %}
  29. post-up batctl -m bat{{domaene[0]}} if add tap-{{ host }} ||:
  30. {% endif %}
  31. {% endfor %}
  32. post-up ip -6 addr add {{domaene[1].ffv6_network | ipaddr(server_id) | ipaddr('address')}}/64 dev bat{{domaene[0]}}
  33. post-up pgrep -a -x -f "batadv-vis -i bat{{domaene[0]}}.*" || batadv-vis -i bat{{domaene[0]}} -u /run/batadvvis.{{domaene[0]}}.sock -s >/dev/null 2>&1&
  34. pre-down pkill -x -f "batadv-vis -i bat{{domaene[0]}}.*" ||:
  35. iface bat{{domaene[0]}} inet static
  36. address {{domaene[1].ffv4_network | ipaddr(server_id) | ipaddr('address') }}
  37. netmask {{domaene[1].ffv4_network | ipaddr('netmask')}}
  38. post-down ip link del bat{{domaene[0]}}
  39. # Tunnel-Interfaces für Domäne-{{domaene[0]}}
  40. {% for host in groups[group] %}
  41. {% if group == "supernodes" %}
  42. {% if domaene[0] in hostvars[host].domaenenliste %}
  43. {% if indexer.append(indexer.pop() + 1) %}{% endif %}{# increment indexer by 1 #}
  44. auto t{{domaene[0]}}-{{ host }}
  45. iface t{{domaene[0]}}-{{ host }} inet manual
  46. {% if build_tunnels_over_ipv6_if_available is defined and build_tunnels_over_ipv6_if_available == "yes" and ansible_default_ipv6.address is defined %}
  47. pre-up ip link add $IFACE type ip6gretap local {{ansible_default_ipv6.address}} remote {{hostvars[host]['ansible_default_ipv6']['address']}} dev {{ansible_default_ipv6.interface}} key {{domaene[0]|int}}
  48. {% else %}
  49. pre-up ip link add $IFACE type gretap local {{ansible_default_ipv4.address}} remote {{hostvars[host].ansible_ssh_host}} dev eth0 key {{domaene[0]|int}}
  50. {% endif %}
  51. pre-up ip link set dev $IFACE address de:ad:be:ef:{{ '%02x' % indexer[0] }}:{{server_id}}
  52. pre-up ip link set $IFACE up
  53. post-up batctl -m bat{{domaene[0]}} if add $IFACE ||:
  54. pre-down batctl -m bat{{domaene[0]}} if del $IFACE ||:
  55. post-down ip link del $IFACE
  56. {% endif %}
  57. {% else %}
  58. {% if indexer.append(indexer.pop() + 1) %}{% endif %}{# increment indexer by 1 #}
  59. auto tap-{{ host }}
  60. iface tap-{{ host }} inet manual
  61. pre-up ip link add $IFACE type gretap local {{ansible_default_ipv4.address}} remote {{hostvars[host].ansible_ssh_host}} dev eth0
  62. pre-up ip link set dev $IFACE address de:ad:be:ef:{{ '%02x' % indexer[0] }}:{{server_id}}
  63. pre-up ip link set $IFACE up
  64. post-up batctl -m bat{{domaene[0]}} if add $IFACE ||:
  65. pre-down batctl -m bat{{domaene[0]}} if del $IFACE ||:
  66. post-down ip link del $IFACE
  67. {% endif %}
  68. {% endfor %}
  69. # END: Domäne-{{domaene[0]}}
  70. {% endfor %}