Saltstack Official Salt Formula
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
2.6KB

  1. {%- set tplroot = tpldir.split('/')[0] %}
  2. {%- from tplroot ~ "/map.jinja" import salt_settings with context %}
  3. {%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}
  4. {% if salt_settings.pin_version and salt_settings.version and grains.os_family|lower == 'debian' %}
  5. include:
  6. - .pin
  7. {% endif %}
  8. {%- if grains.kernel != 'Windows' %}
  9. {%- if grains.os == 'MacOS' %}
  10. salt-master-macos:
  11. file.managed:
  12. - name: /Library/LaunchDaemons/com.saltstack.salt.master.plist
  13. - source: https://raw.githubusercontent.com/saltstack/salt/master/pkg/osx/scripts/com.saltstack.salt.master.plist
  14. - source_hash: {{ salt_settings.salt_master_macos_plist_hash }}
  15. - retry:
  16. attempts: 2
  17. until: True
  18. interval: 10
  19. splay: 10
  20. - require_in:
  21. - service: salt-master
  22. {%- endif %}
  23. salt-master:
  24. {% if salt_settings.install_packages %}
  25. pkg.installed:
  26. - name: {{ salt_settings.salt_master }}
  27. {%- if salt_settings.version is defined %}
  28. - version: {{ salt_settings.version }}
  29. {%- endif %}
  30. {% if salt_settings.master_service_details.state != 'ignore' %}
  31. - require_in:
  32. - service: salt-master
  33. - watch_in:
  34. - service: salt-master
  35. {% endif %}
  36. {% endif %}
  37. file.recurse:
  38. - name: {{ salt_settings.config_path }}/master.d
  39. {%- if salt_settings.master_config_use_TOFS %}
  40. - template: ''
  41. - source: {{ files_switch(['master.d'],
  42. lookup='salt-master'
  43. )
  44. }}
  45. {%- else %}
  46. - template: jinja
  47. - source: salt://{{ tplroot }}/files/master.d
  48. {%- endif %}
  49. - clean: {{ salt_settings.clean_config_d_dir }}
  50. - exclude_pat: _*
  51. {% if salt_settings.master_service_details.state != 'ignore' %}
  52. service.{{ salt_settings.master_service_details.state }}:
  53. - enable: {{ salt_settings.master_service_details.enabled }}
  54. - name: {{ salt_settings.master_service }}
  55. - watch:
  56. {%- if grains.kernel|lower == 'darwin' %}
  57. - file: salt-master-macos
  58. {%- else %}
  59. - file: salt-master
  60. {%- endif %}
  61. - file: remove-old-master-conf-file
  62. - order: last
  63. {% endif %}
  64. {% if salt_settings.master_remove_config %}
  65. remove-default-master-conf-file:
  66. file.absent:
  67. - name: {{ salt_settings.config_path }}/master
  68. - watch_in:
  69. - service: salt-master
  70. {% endif %}
  71. # clean up old _defaults.conf file if they have it around
  72. remove-old-master-conf-file:
  73. file.absent:
  74. - name: {{ salt_settings.config_path }}/master.d/_defaults.conf
  75. {%- else %}
  76. salt-master-install-skip:
  77. test.show_notification:
  78. - text: |
  79. No salt-master state for Windows
  80. {%- endif %}