From 96b02bc6a8b6cf9ac1a45b28c779105f290aaa2c Mon Sep 17 00:00:00 2001 From: "Adrien \"ze\" Urban" Date: Fri, 25 Jun 2021 09:51:33 +0200 Subject: [PATCH 1/2] fix(systemd): fix service detection Fix service detection to properly ensure the service is running. Command also updated at other service.running/dead onlyif. --- mongodb/service/clean.sls | 2 +- mongodb/service/running.sls | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mongodb/service/clean.sls b/mongodb/service/clean.sls index 9c7ea478..47c7d19c 100644 --- a/mongodb/service/clean.sls +++ b/mongodb/service/clean.sls @@ -29,7 +29,7 @@ include: service.dead: - name: {{ servicename }} {% if grains.kernel|lower == 'linux' %} - - onlyif: systemctl list-units |grep {{ servicename }} >/dev/null 2>&1 + - onlyif: systemctl list-unit-files |grep {{ servicename }} >/dev/null 2>&1 {%- endif %} {# linux #} - enable: False {%- endif %} diff --git a/mongodb/service/running.sls b/mongodb/service/running.sls index 7db2a860..5bea18a6 100644 --- a/mongodb/service/running.sls +++ b/mongodb/service/running.sls @@ -34,7 +34,7 @@ include: - reload_modules: true service.running: - name: firewalld - - onlyif: systemctl list-units | grep firewalld >/dev/null 2>&1 + - onlyif: systemctl list-unit-files | grep firewalld >/dev/null 2>&1 - enable: True {%- endif %} {%- endif %} @@ -236,7 +236,7 @@ include: - name: {{ servicename }} - onlyif: - {{ grains.kernel|lower == 'linux' }} - - systemctl list-units | grep {{ servicename }} >/dev/null 2>&1 + - systemctl list-unit-files | grep {{ servicename }} >/dev/null 2>&1 - require: - sls: {{ sls_software_install }} - sls: {{ sls_config_users }} @@ -253,7 +253,7 @@ include: service.running: - name: {{ servicename }} - enable: True - - onlyif: systemctl list-units | grep {{ servicename }} >/dev/null 2>&1 + - onlyif: systemctl list-unit-files | grep {{ servicename }} >/dev/null 2>&1 {%- endif %} - require: - sls: {{ sls_software_install }} From ce9c356ad45ef14f51b79797480c1e299d0e9d0c Mon Sep 17 00:00:00 2001 From: "Adrien \"ze\" Urban" Date: Thu, 7 Jul 2022 15:11:01 +0200 Subject: [PATCH 2/2] fix(services): split enable/running mongos Test shows: Service mongos has been enabled, and is dead Attempt to split running and enable states --- mongodb/service/running.sls | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/mongodb/service/running.sls b/mongodb/service/running.sls index 5bea18a6..93fe736b 100644 --- a/mongodb/service/running.sls +++ b/mongodb/service/running.sls @@ -252,14 +252,23 @@ include: {%- else %} service.running: - name: {{ servicename }} - - enable: True + - onlyif: systemctl list-unit-files | grep {{ servicename }} >/dev/null 2>&1 + - require: + - sls: {{ sls_software_install }} + - sls: {{ sls_config_users }} + {%- if 'config' in software and software['config'] is mapping %} + - watch: + - file: {{ formula }}-config-file-{{ servicename }}-file-managed + {%- endif %} +{{ formula }}-service-running-{{ comp }}-{{ servicename }}-enabled: + service.enabled: + - name: {{ servicename }} - onlyif: systemctl list-unit-files | grep {{ servicename }} >/dev/null 2>&1 {%- endif %} - require: - sls: {{ sls_software_install }} - sls: {{ sls_config_users }} {%- if 'config' in software and software['config'] is mapping %} - - watch: - file: {{ formula }}-config-file-{{ servicename }}-file-managed {%- endif %}