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

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

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


salt_api_service: salt_api_service:
service.running: service.running:
- name: salt-api
- name: {{ api.service }}
- require: - require:
- pkg: salt_api_packages - pkg: salt_api_packages
- watch: - watch:
- file: /etc/salt/master.d/_api.conf - 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

[Service]
Restart=always
RestartSec=3

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

[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

[Service]
Restart=always
RestartSec=3

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

splay: 5 splay: 5
{%- endif %} {%- 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: /srv/salt/env:
file.directory: file.directory:
- user: root - user: root

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

- onlyif: /bin/false - onlyif: /bin/false
{%- endif %} {%- 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 #} {#- Restart salt-minion if needed but after all states are executed #}
salt_minion_service_restart: salt_minion_service_restart:
cmd.run: cmd.run:

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

{%- from "salt/map.jinja" import minion,env_vars with context %} {%- from "salt/map.jinja" import minion,env_vars with context %}


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

{%- if env_vars.engine == 'file' %}
/etc/default/salt-minion: /etc/default/salt-minion:
file.managed: file.managed:
- source: salt://salt/files/etc_default_salt-minion - source: salt://salt/files/etc_default_salt-minion
- onchanges_in: - onchanges_in:
- cmd: salt_minion_service_restart - 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: 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 - user: root
- makedirs: True - makedirs: True
- group: root - group: root
- {{ minion.install_state }} - {{ minion.install_state }}
- onchanges_in: - onchanges_in:
- cmd: salt_minion_service_restart - cmd: salt_minion_service_restart

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

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

- onlyif: /bin/false - onlyif: /bin/false
{%- endif %} {%- 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 #} {#- Restart salt-minion if needed but after all states are executed #}
salt_minion_service_restart: salt_minion_service_restart:
cmd.run: cmd.run:

Loading…
Cancel
Save