From d6115887fafcb0c7c97dc63f658aee9756291353 Mon Sep 17 00:00:00 2001 From: Sam Doran Date: Tue, 27 Oct 2020 17:43:36 -0400 Subject: [PATCH] systemd - use list-unit-files rather than list-units (#72363) list-unit-files will return all files on the system. list-units omits those that are disabled. Co-authored-by: Ken Dreyer --- changelogs/fragments/71528-systemd-list-unit-files.yml | 5 +++++ lib/ansible/modules/systemd.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/71528-systemd-list-unit-files.yml diff --git a/changelogs/fragments/71528-systemd-list-unit-files.yml b/changelogs/fragments/71528-systemd-list-unit-files.yml new file mode 100644 index 00000000000..7b63f674a60 --- /dev/null +++ b/changelogs/fragments/71528-systemd-list-unit-files.yml @@ -0,0 +1,5 @@ +bugfixes: + - > + systemd - follow up fix to https://github.com/ansible/ansible/issues/72338 + to use ``list-unit-files`` rather than ``list-units`` in order to show + all units files on the system. diff --git a/lib/ansible/modules/systemd.py b/lib/ansible/modules/systemd.py index 8b95750f4b9..5446e523da7 100644 --- a/lib/ansible/modules/systemd.py +++ b/lib/ansible/modules/systemd.py @@ -405,7 +405,7 @@ def main(): elif err and rc == 1 and 'Failed to parse bus message' in err: result['status'] = parse_systemctl_show(to_native(out).split('\n')) - (rc, out, err) = module.run_command("{systemctl} list-units '{unit}*'".format(systemctl=systemctl, unit=unit)) + (rc, out, err) = module.run_command("{systemctl} list-unit-files '{unit}*'".format(systemctl=systemctl, unit=unit)) is_systemd = unit in out (rc, out, err) = module.run_command("{systemctl} is-active '{unit}'".format(systemctl=systemctl, unit=unit))