New version of salt-formula from Saltstack
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

108 lines
2.7KB

  1. {#- This state can be called explicitly. Do not include this file in minion.init #}
  2. {%- from "salt/map.jinja" import minion,renderer with context %}
  3. {%- if minion.enabled %}
  4. {%- if minion.source.get('engine', 'pkg') == 'pkg' %}
  5. salt_minion_packages:
  6. pkg.installed:
  7. - names: {{ minion.pkgs }}
  8. {%- if minion.source.version is defined %}
  9. - version: {{ minion.source.version }}
  10. {%- endif %}
  11. salt_minion_dependency_packages:
  12. pkg.installed:
  13. - pkgs: {{ minion.dependency_pkgs }}
  14. {%- elif minion.source.get('engine', 'pkg') == 'pip' %}
  15. salt_minion_packages:
  16. pip.installed:
  17. - name: salt{% if minion.source.version is defined %}=={{ minion.source.version }}{% endif %}
  18. salt_minion_dependency_packages:
  19. pkg.installed:
  20. - pkgs: {{ minion.dependency_pkgs_pip }}
  21. {%- endif %}
  22. /etc/salt/minion.d/minion.conf:
  23. file.managed:
  24. - source: salt://salt/files/minion.conf
  25. - user: root
  26. - group: root
  27. - mode: 600
  28. - template: jinja
  29. - require:
  30. - {{ minion.install_state }}
  31. {%- if renderer | length > 0 %}
  32. /etc/salt/minion.d/_renderer.conf:
  33. file.managed:
  34. - source: salt://salt/files/_renderer.conf
  35. - user: root
  36. - group: root
  37. - mode: 600
  38. - template: jinja
  39. - require:
  40. - {{ minion.install_state }}
  41. - watch_in:
  42. - service: salt_minion_service
  43. {%- endif %}
  44. salt_minion_service:
  45. service.running:
  46. - name: {{ minion.service }}
  47. - enable: true
  48. - require:
  49. - pkg: salt_minion_packages
  50. - pkg: salt_minion_dependency_packages
  51. {%- if grains.get('noservices') %}
  52. - onlyif: /bin/false
  53. {%- endif %}
  54. {%- if grains.get('init', None) == 'systemd' %}
  55. salt_minion_systemd_override:
  56. file.managed:
  57. - name: /etc/systemd/system/{{ minion.service }}.service.d/50-restarts.conf
  58. - source: salt://salt/files/systemd/{{ minion.service }}.service_50-restarts
  59. - makedirs: True
  60. salt_minion_systemd_reload:
  61. module.wait:
  62. - name: service.systemctl_reload
  63. - onchanges:
  64. - file: salt_minion_systemd_override
  65. - watch_in:
  66. - service: salt_minion_service
  67. {%- endif %}
  68. {#- Restart salt-minion if needed but after all states are executed #}
  69. salt_minion_service_restart:
  70. cmd.run:
  71. - name: 'while true; do salt-call saltutil.running|grep fun: && continue; salt-call --local service.restart {{ minion.service }}; break; done'
  72. - shell: /bin/bash
  73. - bg: true
  74. - order: last
  75. - onchanges:
  76. - file: /etc/salt/minion.d/minion.conf
  77. {%- if grains.get('noservices') %}
  78. - onlyif: /bin/false
  79. {%- endif %}
  80. - require:
  81. - service: salt_minion_service
  82. salt_minion_sync_all:
  83. module.run:
  84. - name: 'saltutil.sync_all'
  85. - onchanges:
  86. - service: salt_minion_service
  87. - require:
  88. - pkg: salt_minion_packages
  89. - pkg: salt_minion_dependency_packages
  90. {%- endif %}