Saltstack Official Salt Formula

90 lines
2.8KB

  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: {{ salt_settings.retry_options | json }}
  16. - require_in:
  17. - service: salt-master
  18. {%- endif %}
  19. salt-master:
  20. {% if salt_settings.install_packages %}
  21. pkg.installed:
  22. - name: {{ salt_settings.salt_master }}
  23. {%- if salt_settings.version is defined %}
  24. - version: {{ salt_settings.version }}
  25. {%- endif %}
  26. {% if salt_settings.master_service_details.state != 'ignore' %}
  27. - require_in:
  28. - service: salt-master
  29. - watch_in:
  30. - service: salt-master
  31. {% endif %}
  32. {% endif %}
  33. file.recurse:
  34. - name: {{ salt_settings.config_path }}/master.d
  35. {%- if salt_settings.master_config_use_TOFS %}
  36. - template: ''
  37. - source: {{ files_switch(['master.d'],
  38. lookup='salt-master'
  39. )
  40. }}
  41. {%- else %}
  42. - template: jinja
  43. - source: salt://{{ tplroot }}/files/master.d
  44. {%- endif %}
  45. - clean: {{ salt_settings.clean_config_d_dir }}
  46. - exclude_pat:
  47. - _*
  48. - raas.conf
  49. {% if salt_settings.master_service_details.state != 'ignore' %}
  50. service.{{ salt_settings.master_service_details.state }}:
  51. - enable: {{ salt_settings.master_service_details.enabled }}
  52. - name: {{ salt_settings.master_service }}
  53. {%- if grains.os_family in ['FreeBSD', 'Gentoo'] %}
  54. - retry: {{ salt_settings.retry_options | json }}
  55. {%- endif %}
  56. - watch:
  57. {%- if grains.kernel|lower == 'darwin' %}
  58. - file: salt-master-macos
  59. {%- else %}
  60. - file: salt-master
  61. {%- endif %}
  62. - file: remove-old-master-conf-file
  63. - order: last
  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. - watch_in:
  70. - service: salt-master
  71. {% endif %}
  72. # clean up old _defaults.conf file if they have it around
  73. remove-old-master-conf-file:
  74. file.absent:
  75. - name: {{ salt_settings.config_path }}/master.d/_defaults.conf
  76. {%- else %}
  77. salt-master-install-skip:
  78. test.show_notification:
  79. - text: |
  80. No salt-master state for Windows
  81. {%- endif %}