Optimize 'noservices' condition
diff --git a/salt/minion/service.sls b/salt/minion/service.sls
index 5befc0c..999ea68 100644
--- a/salt/minion/service.sls
+++ b/salt/minion/service.sls
@@ -26,10 +26,8 @@
- template: jinja
- require:
- {{ minion.install_state }}
- {%- if not grains.get('noservices', False) %}
- watch_in:
- service: salt_minion_service
- {%- endif %}
{%- for service_name, service in pillar.items() %}
{%- set support_fragment_file = service_name+'/meta/salt.yml' %}
@@ -43,10 +41,8 @@
- name: /etc/salt/minion.d/_{{ name }}.conf
- contents: |
{{ conf|yaml(False)|indent(8) }}
- {%- if not grains.get('noservices', False) %}
- watch_in:
- cmd: salt_minion_service_restart
- {%- endif %}
- require:
- {{ minion.install_state }}
@@ -55,19 +51,19 @@
- name: python -c "import yaml; stream = file('/etc/salt/minion.d/_{{ name }}.conf', 'r'); yaml.load(stream); stream.close()"
- watch:
- file: salt_minion_config_{{ service_name }}_{{ name }}
- {%- if not grains.get('noservices', False) %}
- require_in:
- cmd: salt_minion_service_restart
- {%- endif %}
{%- endfor %}
{%- endif %}
{%- endfor %}
-{%- if not grains.get('noservices', False) %}
salt_minion_service:
service.running:
- name: {{ minion.service }}
- enable: true
+ {%- if grains.get('noservices') %}
+ - onlyif: /bin/false
+ {%- endif %}
{#- Restart salt-minion if needed but after all states are executed #}
salt_minion_service_restart:
@@ -75,16 +71,16 @@
- name: 'while true; do salt-call saltutil.running|grep fun: && continue; salt-call --local service.restart {{ minion.service }}; break; done'
- shell: /bin/bash
- bg: true
+ {%- if grains.get('noservices') %}
+ - onlyif: /bin/false
+ {%- endif %}
- require:
- service: salt_minion_service
-{%- endif %}
salt_minion_sync_all:
module.run:
- name: 'saltutil.sync_all'
- {%- if not grains.get('noservices', False) %}
- watch:
- service: salt_minion_service
- {%- endif %}
{%- endif %}