init.sls 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. site: {{site}}
  55. site_code: "{{salt['pillar.get']('nodes:' ~ grains['id'] ~ ':site_code', '')}}"
  56. location: {{salt['pillar.get']('nodes:' ~ grains['id'] ~ ':location', {})}}
  57. - require:
  58. - git: ffho-respondd
  59. respondd@{{site}}:
  60. service.running:
  61. - enable: True
  62. - require:
  63. - file: /srv/ffho-respondd/{{site}}.conf
  64. - file: /etc/systemd/system/respondd@.service
  65. - watch:
  66. - file: /srv/ffho-respondd/{{site}}.conf
  67. - git: ffho-respondd
  68. {% endfor %}