diff options
author | Brian Coca <bcoca@users.noreply.github.com> | 2024-09-10 19:32:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-10 19:32:52 +0200 |
commit | 47e64dc37153b5584ce0a467d086b8edd6300e85 (patch) | |
tree | b0bf49b601a1cce440728a29c2175d5b1884a753 /lib/ansible/modules/service_facts.py | |
parent | fact gathering, mounts, fixes for single proc code and tests (#83866) (diff) | |
download | ansible-47e64dc37153b5584ce0a467d086b8edd6300e85.tar.xz ansible-47e64dc37153b5584ce0a467d086b8edd6300e85.zip |
service_facts, fix systemd/ubuntu failed reporting (#83424)
Avoid check description, better comments
Diffstat (limited to '')
-rw-r--r-- | lib/ansible/modules/service_facts.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/ansible/modules/service_facts.py b/lib/ansible/modules/service_facts.py index 5be5119bd2..810e8d2a38 100644 --- a/lib/ansible/modules/service_facts.py +++ b/lib/ansible/modules/service_facts.py @@ -263,7 +263,7 @@ class SystemctlScanService(BaseService): def _list_from_units(self, systemctl_path, services): # list units as systemd sees them - rc, stdout, stderr = self.module.run_command("%s list-units --no-pager --type service --all" % systemctl_path, use_unsafe_shell=True) + rc, stdout, stderr = self.module.run_command("%s list-units --no-pager --type service --all --plain" % systemctl_path, use_unsafe_shell=True) if rc != 0: self.module.warn("Could not list units from systemd: %s" % stderr) else: @@ -272,16 +272,18 @@ class SystemctlScanService(BaseService): state_val = "stopped" status_val = "unknown" fields = line.split() + + # systemd sometimes gives misleading status + # check all fields for bad states for bad in self.BAD_STATES: - if bad in fields: # dot is 0 + # except description + if bad in fields[:-1]: status_val = bad - fields = fields[1:] break else: # active/inactive status_val = fields[2] - # array is normalize so predictable now service_name = fields[0] if fields[3] == "running": state_val = "running" |