init.sls 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #
  2. # Set up B.A.T.M.A.N. module 'n stuff
  3. #
  4. #
  5. # Only set up batman and load batman_adv kernel module if the role »batman«
  6. # has been configured for this node.
  7. #
  8. {%- set roles = salt['pillar.get']('nodes:' ~ grains['id'] ~ ':roles', []) %}
  9. {%- if 'batman' in roles %}
  10. batctl:
  11. pkg.installed:
  12. {% if grains.oscodename == 'buster' %}
  13. - fromrepo: buster-backports
  14. {% else %}
  15. - fromrepo: {{ grains.oscodename }}
  16. {% endif %}
  17. # Convenience bat-hosts file for informative batctl output
  18. /etc/bat-hosts:
  19. file.managed:
  20. - source: salt://batman/bat-hosts.tmpl
  21. - template: jinja
  22. # Make sure the batman_adv module is loaded at boot time
  23. /etc/modules-load.d/batman-adv.conf:
  24. file.managed:
  25. - source: salt://batman/batman-adv.module.conf
  26. #
  27. # Is this node a B.A.T.M.A.N. gateway?
  28. {%- if 'batman_gw' in roles %}
  29. /etc/cron.d/ff_check_gateway:
  30. file.managed:
  31. - source: salt://batman/ff_check_gateway.cron
  32. - template: jinja
  33. /usr/local/sbin/ff_check_gateway:
  34. file.managed:
  35. - source: salt://batman/ff_check_gateway
  36. - mode: 755
  37. - user: root
  38. - group: root
  39. {% endif %}
  40. #
  41. # If the role »batman» is NOT configured for this node, make sure to purge any
  42. # traces of a previous installation, if present.
  43. #
  44. {% else %}
  45. batctl:
  46. pkg.purged
  47. batman-adv-dkms:
  48. pkg.purged
  49. /etc/bat-hosts:
  50. file.absent
  51. /etc/modules-load.d/batman-adv.conf:
  52. file.absent
  53. /etc/cron.d/ff_check_gateway:
  54. file.absent
  55. /usr/local/sbin/ff_check_gateway:
  56. file.absent
  57. {% endif %}