diff --git a/salt/api.sls b/salt/api.sls index 2cf9271..8576767 100644 --- a/salt/api.sls +++ b/salt/api.sls @@ -11,8 +11,9 @@ salt-api: - version: {{ salt_settings.version }} {%- endif %} {% endif %} - service.running: - - enable: True +{% if salt_settings.api_service_details.state != 'ignore' %} + service.{{ salt_settings.api_service_details.state }}: + - enable: {{ salt_settings.api_service_details.enabled }}: - name: {{ salt_settings.api_service }} - require: - service: {{ salt_settings.master_service }} @@ -21,3 +22,4 @@ salt-api: - pkg: salt-api {% endif %} - file: salt-master +{% endif %} diff --git a/salt/defaults.yaml b/salt/defaults.yaml index e36a6c8..2621ad7 100644 --- a/salt/defaults.yaml +++ b/salt/defaults.yaml @@ -19,8 +19,23 @@ salt: master_config_use_TOFS: false minion_service: salt-minion + minion_service_details: + # special name 'ignore' will not output anything about the service + state: running + enabled: true + master_service: salt-master + master_service_details: + # special name 'ignore' will not output anything about the service + state: running + enabled: true + api_service: salt-api + api_service_details: + # special name 'ignore' will not output anything about the service + state: running + enabled: true + syndic_service: salt-syndic salt_master: salt-master diff --git a/salt/master.sls b/salt/master.sls index ce08f7f..a6fdeac 100644 --- a/salt/master.sls +++ b/salt/master.sls @@ -9,10 +9,12 @@ salt-master: {%- if salt_settings.version is defined %} - version: {{ salt_settings.version }} {%- endif %} +{% if salt_settings.master_service_details.state != 'ignore' %} - require_in: - service: salt-master - watch_in: - service: salt-master +{% endif %} {% endif %} file.recurse: - name: {{ salt_settings.config_path }}/master.d @@ -28,13 +30,14 @@ salt-master: {%- endif %} - clean: {{ salt_settings.clean_config_d_dir }} - exclude_pat: _* - service.running: - - enable: True +{% if salt_settings.master_service_details.state != 'ignore' %} + service.{{ salt_settings.master_service_details.state }}: + - enable: {{ salt_settings.master_service_details.enabled }} - name: {{ salt_settings.master_service }} - watch: - file: salt-master - file: remove-old-master-conf-file - +{% endif %} {% if salt_settings.master_remove_config %} remove-default-master-conf-file: file.absent: diff --git a/salt/minion.sls b/salt/minion.sls index e61e072..e6981d3 100644 --- a/salt/minion.sls +++ b/salt/minion.sls @@ -41,8 +41,10 @@ salt-minion: - force: True - unless: - test -n "{{ salt_settings.version }}" && '/opt/salt/bin/salt-minion --version=.*{{ salt_settings.version }}.*' +{% if salt_settings.minion_service_details.state != 'ignore' %} - require_in: - service: salt-minion +{% endif %} - onchanges_in: - cmd: remove-macpackage-salt {%- elif grains.os != 'MacOS' and "workaround https://github.com/saltstack/salt/issues/49348" %} @@ -51,8 +53,10 @@ salt-minion: {%- if salt_settings.version %} - version: {{ salt_settings.version }} {%- endif %} +{% if salt_settings.minion_service_details.state != 'ignore' %} - require_in: - service: salt-minion +{% endif %} {%- endif %} {% endif %} file.recurse: @@ -71,11 +75,13 @@ salt-minion: {%- endif %} - clean: {{ salt_settings.clean_config_d_dir }} - exclude_pat: _* - service.running: - - enable: True +{% if salt_settings.minion_service_details.state != 'ignore' %} + service.{{ salt_settings.minion_service_details.state }}: + - enable: {{ salt_settings.minion_service_details.enabled }} - name: {{ salt_settings.minion_service }} - require: - file: salt-minion +{% endif %} {%- if not salt_settings.restart_via_at %} cmd.run: {%- if grains['saltversioninfo'] >= [ 2016, 3 ] %}