Saltstack Official Salt Formula
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

11 роки тому
5 роки тому
11 роки тому
5 роки тому
11 роки тому
11 роки тому
7 роки тому
11 роки тому
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. {% from "salt/map.jinja" import salt_settings with context %}
  2. {% if salt_settings.install_packages and grains.os == 'MacOS' and salt_settings.salt_minion_pkg_source != '' and salt_settings.version != '' %}
  3. {# only download IF we know where to get the pkg from and if we know what version to check the current install (if installed) against #}
  4. {# e.g. don't download unless it appears as though we're about to try and upgrade the minion #}
  5. download-salt-minion:
  6. file.managed:
  7. - name: '/tmp/salt.pkg'
  8. - source: {{ salt_settings.salt_minion_pkg_source }}
  9. {% if salt_settings.salt_minion_pkg_hash != '' %}
  10. - source_hash: {{ salt_settings.salt_minion_pkg_hash }}
  11. {% else %}
  12. - skip_verify: True
  13. {% endif %}
  14. - user: root
  15. - group: wheel
  16. - mode: 0644
  17. - unless:
  18. - '/opt/salt/bin/salt-minion --version | grep {{ salt_settings.version }}'
  19. - require_in:
  20. - macpackage: salt-minion
  21. {% endif %}
  22. salt-minion:
  23. {% if salt_settings.install_packages %}
  24. {%- if grains.os == 'MacOS' and salt_settings.salt_minion_pkg_source != '' and salt_settings.version != '' %}
  25. macpackage.installed:
  26. - name: '/tmp/salt.pkg'
  27. - target: /
  28. {# macpackage.installed behaves weirdly with version_check; version_check detects difference but fails to actually complete install. #}
  29. {# use force == True as workaround #}
  30. - force: True
  31. - version_check: /opt/salt/bin/salt-minion --version=.*{{ salt_settings.version }}.*
  32. - require_in:
  33. - service: salt-minion
  34. {%- else %}
  35. pkg.installed:
  36. - name: {{ salt_settings.salt_minion }}
  37. {%- if salt_settings.version is defined %}
  38. - version: {{ salt_settings.version }}
  39. {%- endif %}
  40. - require_in:
  41. - service: salt-minion
  42. {%- endif %}
  43. {% endif %}
  44. file.recurse:
  45. - name: {{ salt_settings.config_path }}/minion.d
  46. - template: jinja
  47. - source: salt://{{ slspath }}/files/minion.d
  48. - clean: {{ salt_settings.clean_config_d_dir }}
  49. - exclude_pat: _*
  50. - context:
  51. standalone: False
  52. service.running:
  53. - enable: True
  54. - name: {{ salt_settings.minion_service }}
  55. - require:
  56. - file: salt-minion
  57. {%- if not salt_settings.restart_via_at %}
  58. cmd.run:
  59. {%- if grains['saltversioninfo'][0] >= 2016 and grains['saltversioninfo'][1] >= 3 %}
  60. {%- if grains['kernel'] == 'Windows' %}
  61. - name: 'salt-call.bat --local service.restart {{ salt_settings.minion_service }}'
  62. {%- else %}
  63. - name: 'salt-call --local service.restart {{ salt_settings.minion_service }} --out-file /dev/null'
  64. {%- endif %}
  65. - bg: True
  66. {%- else %}
  67. {%- if grains['kernel'] == 'Windows' %}
  68. - name: 'start powershell "Restart-Service -Name {{ salt_settings.minion_service }}"'
  69. {%- else %}
  70. # old style, pre 2016.3. fork and disown the process
  71. - name: |-
  72. exec 0>&- # close stdin
  73. exec 1>&- # close stdout
  74. exec 2>&- # close stderr
  75. nohup salt-call --local service.restart {{ salt_settings.minion_service }} --out-file /dev/null &
  76. {%- endif %}
  77. {%- endif %}
  78. - onchanges:
  79. {%- if salt_settings.install_packages %}
  80. {%- if grains.os == 'MacOS' %}
  81. - macpackage: salt-minion
  82. {%- else %}
  83. - pkg: salt-minion
  84. {%- endif %}
  85. {%- endif %}
  86. - file: salt-minion
  87. - file: remove-old-minion-conf-file
  88. {%- else %}
  89. {% if grains.os != 'MacOS' %}
  90. {# MacOS has 'at' command; but there's no package to install #}
  91. at:
  92. pkg.installed: []
  93. {% endif %}
  94. restart-salt-minion:
  95. cmd.run:
  96. - name: echo salt-call --local service.restart {{ salt_settings.minion_service }} | at now + 1 minute
  97. - order: last
  98. - require:
  99. - pkg: at
  100. - onchanges:
  101. {%- if salt_settings.install_packages %}
  102. {%- if grains.os == 'MacOS' %}
  103. - macpackage: salt-minion
  104. {%- else %}
  105. - pkg: salt-minion
  106. {%- endif %}
  107. {%- endif %}
  108. - file: salt-minion
  109. - file: remove-old-minion-conf-file
  110. {%- endif %}
  111. {% if 'inotify' in salt_settings.get('minion', {}).get('beacons', {}) and salt_settings.get('pyinotify', False) %}
  112. salt-minion-beacon-inotify:
  113. pkg.installed:
  114. - name: {{ salt_settings.pyinotify }}
  115. - require_in:
  116. - service: salt-minion
  117. - watch_in:
  118. - service: salt-minion
  119. {% endif %}
  120. {% if salt_settings.minion_remove_config %}
  121. remove-default-minion-conf-file:
  122. file.absent:
  123. - name: {{ salt_settings.config_path }}/minion
  124. {% endif %}
  125. # clean up old _defaults.conf file if they have it around
  126. remove-old-minion-conf-file:
  127. file.absent:
  128. - name: {{ salt_settings.config_path }}/minion.d/_defaults.conf
  129. {% if grains.os == 'MacOS' %}
  130. remove-macpackage-salt:
  131. cmd.run:
  132. - name: 'rm -f /tmp/salt.pkg'
  133. - onchanges:
  134. - macpackage: salt-minion
  135. {% endif %}