Explorar el Código

feat(mapping): better control of the service's state

Instead of the default service.running + enabled, you can control
the actual state, via pillar.
And you can even say 'state = ignore' and no state will be generated
to control the service
tags/v1.3.0
cristi hace 4 años
padre
commit
29ffd68d34
Se han modificado 4 ficheros con 33 adiciones y 7 borrados
  1. +4
    -2
      salt/api.sls
  2. +15
    -0
      salt/defaults.yaml
  3. +6
    -3
      salt/master.sls
  4. +8
    -2
      salt/minion.sls

+ 4
- 2
salt/api.sls Ver fichero

@@ -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 %}

+ 15
- 0
salt/defaults.yaml Ver fichero

@@ -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

+ 6
- 3
salt/master.sls Ver fichero

@@ -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:

+ 8
- 2
salt/minion.sls Ver fichero

@@ -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 ] %}

Cargando…
Cancelar
Guardar