init.sls 1.4 KB

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