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))