diff options
author | Abhijeet Kasurde <akasurde@redhat.com> | 2020-06-01 15:40:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-01 15:40:52 +0200 |
commit | 723a904f4e1fc7c17ebdf1a6276f9e4f46e606b2 (patch) | |
tree | 2f1f569a3d7db2d0b73f226a7d8a251293cd9989 /lib | |
parent | [ansiballz] ensure that '' is not in sys.path (#69342) (diff) | |
download | ansible-723a904f4e1fc7c17ebdf1a6276f9e4f46e606b2.tar.xz ansible-723a904f4e1fc7c17ebdf1a6276f9e4f46e606b2.zip |
Handle disabled service units (#69349)
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ansible/modules/service_facts.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/ansible/modules/service_facts.py b/lib/ansible/modules/service_facts.py index b3a4e74664..79556baeb3 100644 --- a/lib/ansible/modules/service_facts.py +++ b/lib/ansible/modules/service_facts.py @@ -218,7 +218,11 @@ class SystemctlScanService(BaseService): except IndexError: self.module.fail_json(msg="Malformed output discovered from systemd list-unit-files: {0}".format(line)) if service_name not in services: - services[service_name] = {"name": service_name, "state": "unknown", "status": status_val, "source": "systemd"} + rc, stdout, stderr = self.module.run_command("%s show %s --property=ActiveState" % (systemctl_path, service_name), use_unsafe_shell=True) + state = 'unknown' + if not rc and stdout != '': + state = stdout.replace('ActiveState=', '').rstrip() + services[service_name] = {"name": service_name, "state": state, "status": status_val, "source": "systemd"} else: services[service_name]["status"] = status_val return services |