Sfoglia il codice sorgente

Merge pull request #54 from Martin819/master

Optimize 'noservices' condition
pull/53/head
Filip Pytloun 7 anni fa
parent
commit
e0127cc8d3
1 ha cambiato i file con 6 aggiunte e 10 eliminazioni
  1. +6
    -10
      salt/minion/service.sls

+ 6
- 10
salt/minion/service.sls Vedi File

@@ -26,10 +26,8 @@ salt_minion_packages:
- 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 @@ salt_minion_config_{{ service_name }}_{{ name }}:
- 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 @@ salt_minion_config_{{ service_name }}_{{ name }}_validity_check:
- 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 @@ salt_minion_service_restart:
- 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 %}

Loading…
Annulla
Salva