init.sls 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /srv/ffho-respondd:
  2. file.directory
  3. ffho-respondd:
  4. pkg.installed:
  5. - pkgs:
  6. - git
  7. - lsb-release
  8. - ethtool
  9. - python3
  10. - python3-netifaces
  11. git.latest:
  12. - name: https://github.com/FreifunkHochstift/ffho-respondd.git
  13. - target: /srv/ffho-respondd
  14. - require:
  15. - file: /srv/ffho-respondd
  16. /etc/systemd/system/respondd@.service:
  17. file.managed:
  18. - source: salt://respondd/respondd@.service
  19. - require:
  20. - git: ffho-respondd
  21. {%- set node_config = salt['pillar.get']('nodes:' ~ grains['id'], {}) %}
  22. {%- set sites_config = salt['pillar.get']('sites', {}) %}
  23. {%- set ifaces = salt['ffho_net.get_interface_config'](node_config, sites_config) %}
  24. {% set device_no = salt['pillar.get']('nodes:' ~ grains['id'] ~ ':id', -1) %}
  25. {% for site in salt['pillar.get']('nodes:' ~ grains['id'] ~ ':sites', []) %}
  26. {% set site_no = salt['pillar.get']('sites:' ~ site ~ ':site_no') %}
  27. {% set mac_address = salt['ffho_net.gen_batman_iface_mac'](site_no, device_no, 'dummy') %}
  28. /srv/ffho-respondd/{{site}}.conf:
  29. file.managed:
  30. - source: salt://respondd/respondd-config.tmpl
  31. - template: jinja
  32. - defaults:
  33. mac_address: {{ mac_address }}
  34. {% if 'batman_ext' in salt['pillar.get']('nodes:' ~ grains['id'] ~ ':roles', []) %}
  35. bat_iface: "bat-{{site}}-ext"
  36. {% else %}
  37. bat_iface: "bat-{{site}}"
  38. {% endif %}
  39. {% if 'fastd_peers' in salt['pillar.get']('nodes:' ~ grains['id'] ~ ':roles', []) %}
  40. fastd_peers: "true"
  41. {% else %}
  42. fastd_peers: "false"
  43. {% endif %}
  44. {% if salt['pillar.get']('nodes:' ~ grains['id'] ~ ':sites', [])|length > 1 %}
  45. hostname: "{{grains['id'].split('.')[0]}}-{{site}}"
  46. {% else %}
  47. hostname: "{{grains['id'].split('.')[0]}}"
  48. {% endif %}
  49. {% if 'br-' ~ site in ifaces %}
  50. mcast_iface: "br-{{site}}"
  51. {% else %}
  52. mcast_iface: "bat-{{site}}"
  53. {% endif %}
  54. {% if 'fastd' in salt['pillar.get']('nodes:' ~ grains['id'] ~ ':roles', []) %}
  55. mesh_vpn: [{{ site }}_intergw, {{ site }}_nodes4, {{ site }}_nodes6]
  56. {% else %}
  57. mesh_vpn: False
  58. {% endif %}
  59. site: {{site}}
  60. site_code: "{{salt['pillar.get']('nodes:' ~ grains['id'] ~ ':site_code', '')}}"
  61. location: {{salt['pillar.get']('nodes:' ~ grains['id'] ~ ':location', {})}}
  62. - require:
  63. - git: ffho-respondd
  64. respondd@{{site}}:
  65. service.running:
  66. - enable: True
  67. - require:
  68. - file: /srv/ffho-respondd/{{site}}.conf
  69. - file: /etc/systemd/system/respondd@.service
  70. - watch:
  71. - file: /srv/ffho-respondd/{{site}}.conf
  72. - git: ffho-respondd
  73. {% endfor %}