Browse Source

Enable services restart on systemd lvl

* Those patch enable salt-(minion|master|api) services
    daemon auto-restart, in case any unclear exit will be
    detected. Systemd will try to run service each 3sec,
    till _StartLimitBurst_ limit will not be reached.
    (default 5)
  * Migrate systemd_minion_override.conf file
  * Duplicate patch for minion in base.sls and in service.sls

Change-Id: I65f35f1c50935af5692b740bb75ba0a629b18c48
Closes-Bug: PROD-23969 (PROD:23969)
master
azvyagintsev 6 years ago
parent
commit
dc08d60b30
9 changed files with 82 additions and 11 deletions
  1. +17
    -3
      salt/api.sls
  2. +3
    -0
      salt/files/systemd/salt-api.service_50-restarts
  3. +3
    -0
      salt/files/systemd/salt-master.service_50-restarts
  4. +0
    -0
      salt/files/systemd/salt-minion.service_40-override
  5. +3
    -0
      salt/files/systemd/salt-minion.service_50-restarts
  6. +16
    -0
      salt/master/service.sls
  7. +16
    -0
      salt/minion/base.sls
  8. +7
    -8
      salt/minion/env_vars.sls
  9. +17
    -0
      salt/minion/service.sls

+ 17
- 3
salt/api.sls View File

@@ -26,15 +26,29 @@ salt_api_init_tls:
- creates: /etc/ssl/certs/{{ api.ssl.get('name', grains.id) }}-chain.crt
- watch_in:
- service: salt_api_service

{%- endif %}

salt_api_service:
service.running:
- name: salt-api
- name: {{ api.service }}
- require:
- pkg: salt_api_packages
- watch:
- file: /etc/salt/master.d/_api.conf

{%- endif %}
{%- if grains.get('init', None) == 'systemd' %}
salt_api_systemd_override:
file.managed:
- name: /etc/systemd/system/{{ api.service }}.service.d/50-restarts.conf
- source: salt://salt/files/systemd/{{ api.service }}.service_50-restarts
- makedirs: True

salt_api_systemd_reload:
module.wait:
- name: service.systemctl_reload
- onchanges:
- file: salt_api_systemd_override
- watch_in:
- service: salt_api_service
{%- endif %}
{%- endif %}

+ 3
- 0
salt/files/systemd/salt-api.service_50-restarts View File

@@ -0,0 +1,3 @@
[Service]
Restart=always
RestartSec=3

+ 3
- 0
salt/files/systemd/salt-master.service_50-restarts View File

@@ -0,0 +1,3 @@
[Service]
Restart=always
RestartSec=3

salt/files/systemd_minion_override.conf → salt/files/systemd/salt-minion.service_40-override View File


+ 3
- 0
salt/files/systemd/salt-minion.service_50-restarts View File

@@ -0,0 +1,3 @@
[Service]
Restart=always
RestartSec=3

+ 16
- 0
salt/master/service.sls View File

@@ -109,6 +109,22 @@ salt_master_service:
splay: 5
{%- endif %}

{%- if grains.get('init', None) == 'systemd' %}
salt_master_systemd_override:
file.managed:
- name: /etc/systemd/system/{{ master.service }}.service.d/50-restarts.conf
- source: salt://salt/files/systemd/{{ master.service }}.service_50-restarts
- makedirs: True

salt_master_systemd_reload:
module.wait:
- name: service.systemctl_reload
- onchanges:
- file: salt_master_systemd_override
- watch_in:
- service: salt_master_service
{%- endif %}

/srv/salt/env:
file.directory:
- user: root

+ 16
- 0
salt/minion/base.sls View File

@@ -64,6 +64,22 @@ salt_minion_service:
- onlyif: /bin/false
{%- endif %}

{%- if grains.get('init', None) == 'systemd' %}
salt_minion_systemd_override:
file.managed:
- name: /etc/systemd/system/{{ minion.service }}.service.d/50-restarts.conf
- source: salt://salt/files/systemd/{{ minion.service }}.service_50-restarts
- makedirs: True

salt_minion_systemd_reload:
module.wait:
- name: service.systemctl_reload
- onchanges:
- file: salt_minion_systemd_override
- watch_in:
- service: salt_minion_service
{%- endif %}

{#- Restart salt-minion if needed but after all states are executed #}
salt_minion_service_restart:
cmd.run:

+ 7
- 8
salt/minion/env_vars.sls View File

@@ -1,8 +1,7 @@
{%- from "salt/map.jinja" import minion,env_vars with context %}

{%- if env_vars.engine is defined %}
{%- if env_vars.engine == 'file' %}

{%- if env_vars.engine == 'file' %}
/etc/default/salt-minion:
file.managed:
- source: salt://salt/files/etc_default_salt-minion
@@ -14,10 +13,11 @@
- onchanges_in:
- cmd: salt_minion_service_restart

{%- if grains.get('init', None) == 'systemd' %}
/etc/systemd/system/salt-minion.service.d/override.conf:
{%- if grains.get('init', None) == 'systemd' %}
/etc/systemd/system/salt-minion.service.d/40-override:
file.managed:
- source: salt://salt/files/systemd_minion_override.conf
- name: /etc/systemd/system/salt-minion.service.d/40-override
- source: salt://salt/files/systemd/salt-minion.service_40-override
- user: root
- makedirs: True
- group: root
@@ -26,7 +26,6 @@
- {{ minion.install_state }}
- onchanges_in:
- cmd: salt_minion_service_restart

{%- endif %}
{%- endif %}
{%- endif %}
{%- endif %}
{%- endif %}

+ 17
- 0
salt/minion/service.sls View File

@@ -125,6 +125,23 @@ salt_minion_service:
- onlyif: /bin/false
{%- endif %}


{%- if grains.get('init', None) == 'systemd' %}
salt_minion_systemd_override:
file.managed:
- name: /etc/systemd/system/{{ minion.service }}.service.d/50-restarts.conf
- source: salt://salt/files/systemd/{{ minion.service }}.service_50-restarts
- makedirs: True

salt_minion_systemd_reload:
module.wait:
- name: service.systemctl_reload
- onchanges:
- file: salt_minion_systemd_override
- watch_in:
- service: salt_minion_service
{%- endif %}

{#- Restart salt-minion if needed but after all states are executed #}
salt_minion_service_restart:
cmd.run:

Loading…
Cancel
Save