Saltstack Official Salt Formula
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.

92 lines
2.7KB

  1. {% from "salt/map.jinja" import salt_settings with context %}
  2. {% if grains.os != "MacOS" %}
  3. salt-minion:
  4. {% if salt_settings.install_packages %}
  5. pkg.installed:
  6. - name: {{ salt_settings.salt_minion }}
  7. {%- if salt_settings.version is defined %}
  8. - version: {{ salt_settings.version }}
  9. {%- endif %}
  10. {% endif %}
  11. file.recurse:
  12. - name: {{ salt_settings.config_path }}/minion.d
  13. - template: jinja
  14. - source: salt://{{ slspath }}/files/minion.d
  15. - clean: {{ salt_settings.clean_config_d_dir }}
  16. - exclude_pat: _*
  17. - context:
  18. standalone: False
  19. service.running:
  20. - enable: True
  21. - name: {{ salt_settings.minion_service }}
  22. - require:
  23. - file: salt-minion
  24. {%- if not salt_settings.restart_via_at %}
  25. cmd.run:
  26. {%- if grains['saltversioninfo'][0] >= 2016 and grains['saltversioninfo'][1] >= 3 %}
  27. {%- if grains['kernel'] == 'Windows' %}
  28. - name: 'salt-call.bat --local service.restart {{ salt_settings.minion_service }}'
  29. {%- else %}
  30. - name: 'salt-call --local service.restart {{ salt_settings.minion_service }} --out-file /dev/null'
  31. {%- endif %}
  32. - bg: True
  33. {%- else %}
  34. {%- if grains['kernel'] == 'Windows' %}
  35. - name: 'start powershell "Restart-Service -Name {{ salt_settings.minion_service }}"'
  36. {%- else %}
  37. # old style, pre 2016.3. fork and disown the process
  38. - name: |-
  39. exec 0>&- # close stdin
  40. exec 1>&- # close stdout
  41. exec 2>&- # close stderr
  42. nohup salt-call --local service.restart {{ salt_settings.minion_service }} --out-file /dev/null &
  43. {%- endif %}
  44. {%- endif %}
  45. - onchanges:
  46. {%- if salt_settings.install_packages %}
  47. - pkg: salt-minion
  48. {%- endif %}
  49. - file: salt-minion
  50. - file: remove-old-minion-conf-file
  51. {%- else %}
  52. at:
  53. pkg.installed: []
  54. restart-salt-minion:
  55. cmd.run:
  56. - name: echo salt-call --local service.restart salt-minion | at now + 1 minute
  57. - order: last
  58. - require:
  59. - pkg: at
  60. - onchanges:
  61. {%- if salt_settings.install_packages %}
  62. - pkg: salt-minion
  63. {%- endif %}
  64. - file: salt-minion
  65. - file: remove-old-minion-conf-file
  66. {%- endif %}
  67. {% if 'inotify' in salt_settings.get('minion', {}).get('beacons', {}) and salt_settings.get('pyinotify', False) %}
  68. salt-minion-beacon-inotify:
  69. pkg.installed:
  70. - name: {{ salt_settings.pyinotify }}
  71. - require_in:
  72. - service: salt-minion
  73. - watch_in:
  74. - service: salt-minion
  75. {% endif %}
  76. {% if salt_settings.minion_remove_config %}
  77. remove-default-minion-conf-file:
  78. file.absent:
  79. - name: {{ salt_settings.config_path }}/minion
  80. {% endif %}
  81. # clean up old _defaults.conf file if they have it around
  82. remove-old-minion-conf-file:
  83. file.absent:
  84. - name: {{ salt_settings.config_path }}/minion.d/_defaults.conf
  85. {% endif %}