init.sls 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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.latest:
  12. - name: batctl
  13. {% if grains.oscodename == 'buster' %}
  14. - fromrepo: buster-backports
  15. {% endif %}
  16. # Convenience bat-hosts file for informative batctl output
  17. /etc/bat-hosts:
  18. file.managed:
  19. - source: salt://batman/bat-hosts.tmpl
  20. - template: jinja
  21. # Make sure the batman_adv module is loaded at boot time
  22. /etc/modules-load.d/batman-adv.conf:
  23. file.managed:
  24. - source: salt://batman/batman-adv.module.conf
  25. #
  26. # Is this node a B.A.T.M.A.N. gateway?
  27. {%- if 'batman_gw' in roles %}
  28. /etc/cron.d/ff_check_gateway:
  29. file.managed:
  30. - source: salt://batman/ff_check_gateway.cron
  31. - template: jinja
  32. /usr/local/sbin/ff_check_gateway:
  33. file.managed:
  34. - source: salt://batman/ff_check_gateway
  35. - mode: 755
  36. - user: root
  37. - group: root
  38. {% endif %}
  39. #
  40. # If the role »batman» is NOT configured for this node, make sure to purge any
  41. # traces of a previous installation, if present.
  42. #
  43. {% else %}
  44. batctl:
  45. pkg.purged
  46. batman-adv-dkms:
  47. pkg.purged
  48. /etc/bat-hosts:
  49. file.absent
  50. /etc/modules-load.d/batman-adv.conf:
  51. file.absent
  52. /etc/cron.d/ff_check_gateway:
  53. file.absent
  54. /usr/local/sbin/ff_check_gateway:
  55. file.absent
  56. {% endif %}