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.

78 lines
2.5KB

  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.os == 'MacOS' %}
  9. salt-master-macos:
  10. file.managed:
  11. - name: /Library/LaunchDaemons/com.saltstack.salt.master.plist
  12. - source: https://raw.githubusercontent.com/saltstack/salt/master/pkg/osx/scripts/com.saltstack.salt.master.plist
  13. - source_hash: {{ salt_settings.salt_master_macos_plist_hash }}
  14. - retry:
  15. attempts: 2
  16. until: True
  17. interval: 10
  18. splay: 10
  19. cmd.run:
  20. - names:
  21. - launchctl load -w /Library/LaunchDaemons/com.saltstack.salt.master.plist
  22. - launchctl unload /Library/LaunchDaemons/com.saltstack.salt.master.plist
  23. - require:
  24. - file: salt-master-macos
  25. - require_in:
  26. - service: salt-master
  27. {%- endif %}
  28. salt-master:
  29. {% if salt_settings.install_packages %}
  30. pkg.installed:
  31. - name: {{ salt_settings.salt_master }}
  32. {%- if salt_settings.version is defined %}
  33. - version: {{ salt_settings.version }}
  34. {%- endif %}
  35. {% if salt_settings.master_service_details.state != 'ignore' %}
  36. - require_in:
  37. - service: salt-master
  38. - watch_in:
  39. - service: salt-master
  40. {% endif %}
  41. {% endif %}
  42. file.recurse:
  43. - name: {{ salt_settings.config_path }}/master.d
  44. {%- if salt_settings.master_config_use_TOFS %}
  45. - template: ''
  46. - source: {{ files_switch(['master.d'],
  47. lookup='salt-master'
  48. )
  49. }}
  50. {%- else %}
  51. - template: jinja
  52. - source: salt://{{ tplroot }}/files/master.d
  53. {%- endif %}
  54. - clean: {{ salt_settings.clean_config_d_dir }}
  55. - exclude_pat: _*
  56. {% if salt_settings.master_service_details.state != 'ignore' %}
  57. service.{{ salt_settings.master_service_details.state }}:
  58. - enable: {{ salt_settings.master_service_details.enabled }}
  59. - name: {{ salt_settings.master_service }}
  60. - watch:
  61. - file: salt-master-macos
  62. - file: salt-master
  63. - file: remove-old-master-conf-file
  64. {% endif %}
  65. {% if salt_settings.master_remove_config %}
  66. remove-default-master-conf-file:
  67. file.absent:
  68. - name: {{ salt_settings.config_path }}/master
  69. {% endif %}
  70. # clean up old _defaults.conf file if they have it around
  71. remove-old-master-conf-file:
  72. file.absent:
  73. - name: {{ salt_settings.config_path }}/master.d/_defaults.conf