init.sls 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. include:
  11. - apt
  12. batman-adv-dkms:
  13. pkg.installed:
  14. - require:
  15. - pkgrepo: apt-neoraider
  16. batctl:
  17. pkg.installed:
  18. - require:
  19. - pkgrepo: apt-neoraider
  20. # Conveniance bat-hosts file for informative batctl output
  21. /etc/bat-hosts:
  22. file.managed:
  23. - source: salt://batman/bat-hosts.tmpl
  24. - template: jinja
  25. # The ff_fix_batman script ensures that the preferred (currently older) version
  26. # of the batman_adv kernel module is compiled via DKMS and installed into the
  27. # system.
  28. /usr/local/sbin/ff_fix_batman:
  29. file.managed:
  30. - source: salt://batman/ff_fix_batman
  31. - user: root
  32. - group: root
  33. - mode: 744
  34. - require:
  35. - pkg: batctl
  36. ff_fix_batman:
  37. cmd.wait:
  38. - name: /usr/local/sbin/ff_fix_batman
  39. - require:
  40. - file: /usr/local/sbin/ff_fix_batman
  41. - watch:
  42. - pkg: batman-adv-dkms
  43. # Install and enable a ff-fix-batman service which runs at boot time
  44. # to fix the kernel module after a kernel upgrade + reboot if neccessary.
  45. /lib/systemd/system/ff-fix-batman.service:
  46. file.managed:
  47. - source: salt://batman/ff_fix_batman.service
  48. - user: root
  49. - group: root
  50. - mode: 644
  51. - require:
  52. - file: /usr/local/sbin/ff_fix_batman
  53. enable-ff-fix-batman-service:
  54. service.enabled:
  55. - name: ff-fix-batman
  56. - require:
  57. - file: /lib/systemd/system/ff-fix-batman.service
  58. # Make sure the batman_adv module is loaded at boot time
  59. /etc/modules-load.d/batman-adv.conf:
  60. file.managed:
  61. - source: salt://batman/batman-adv.module.conf
  62. #
  63. # Is this node a B.A.T.M.A.N. gateway?
  64. {%- if 'batman_gw' in roles %}
  65. /etc/cron.d/ff_check_gateway:
  66. file.managed:
  67. - source: salt://batman/ff_check_gateway.cron
  68. - template: jinja
  69. /usr/local/sbin/ff_check_gateway:
  70. file.managed:
  71. - source: salt://batman/ff_check_gateway
  72. - mode: 755
  73. - user: root
  74. - group: root
  75. {% endif %}
  76. #
  77. # If the role »batman» is NOT configured for this node, make sure to purge any
  78. # traces of a previous installation, if present.
  79. #
  80. {% else %}
  81. batctl:
  82. pkg.purged
  83. batman-adv-dkms:
  84. pkg.purged
  85. /usr/local/sbin/ff_fix_batman:
  86. file.absent
  87. disable-ff-fix-batman-service:
  88. service.disabled:
  89. - name: ff-fix-batman
  90. /lib/systemd/system/ff-fix-batman.service:
  91. file.absent
  92. /etc/modules-load.d/batman-adv.conf:
  93. file.absent
  94. /etc/bat-hosts:
  95. file.absent
  96. /etc/cron.d/ff_check_gateway:
  97. file.absent
  98. /usr/local/sbin/ff_check_gateway:
  99. file.absent
  100. {% endif %}