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. include:
  10. - apt
  11. {%- if 'batman' in roles %}
  12. batctl:
  13. pkg.installed
  14. # Convenience bat-hosts file for informative batctl output
  15. /etc/bat-hosts:
  16. file.managed:
  17. - source: salt://batman/bat-hosts.tmpl
  18. - template: jinja
  19. {% if salt['ffho.re_search'] ('-v14', grains['id']) %}
  20. batman-adv-dkms:
  21. pkg.installed:
  22. - require:
  23. - pkgrepo: apt-neoraider
  24. # The ff_fix_batman script ensures that the preferred (currently older) version
  25. # of the batman_adv kernel module is compiled via DKMS and installed into the
  26. # system.
  27. /usr/local/sbin/ff_fix_batman:
  28. file.managed:
  29. - source: salt://batman/ff_fix_batman
  30. - user: root
  31. - group: root
  32. - mode: 744
  33. - require:
  34. - pkg: batctl
  35. ff_fix_batman:
  36. cmd.wait:
  37. - name: /usr/local/sbin/ff_fix_batman
  38. - require:
  39. - file: /usr/local/sbin/ff_fix_batman
  40. - watch:
  41. - pkg: batman-adv-dkms
  42. # Install and enable a ff-fix-batman service which runs at boot time
  43. # to fix the kernel module after a kernel upgrade + reboot if neccessary.
  44. /lib/systemd/system/ff-fix-batman.service:
  45. file.managed:
  46. - source: salt://batman/ff_fix_batman.service
  47. - user: root
  48. - group: root
  49. - mode: 644
  50. - require:
  51. - file: /usr/local/sbin/ff_fix_batman
  52. enable-ff-fix-batman-service:
  53. service.enabled:
  54. - name: ff-fix-batman
  55. - require:
  56. - file: /lib/systemd/system/ff-fix-batman.service
  57. {% endif %}
  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 %}