Преглед на файлове

Optimize 'noservices' condition

pull/54/head
Martin Polreich преди 7 години
родител
ревизия
94414c86f9
променени са 1 файла, в които са добавени 6 реда и са изтрити 10 реда
  1. +6
    -10
      salt/minion/service.sls

+ 6
- 10
salt/minion/service.sls Целия файл

@@ -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…
Отказ
Запис