init.sls 2.7 KB

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