1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-06-11 10:35:34 +00:00

[PR #12168/1e3da48d backport][stable-13] portage: include msg in depclean failure fail_json (#12175)

portage: include msg in depclean failure fail_json (#12168)

cleanup_packages() called module.fail_json(cmd=, rc=, stdout=, stderr=)
without the mandatory msg= argument. When the underlying emerge --depclean
exited non-zero, AnsibleModule.fail_json() itself crashed with
"AnsibleModule.fail_json() missing 1 required positional argument: 'msg'"
before the real failure could reach the controller, leaving users with no
diagnostic about why depclean actually failed.

Same wording style as the sibling install_packages() failure branch
("Packages not installed.").

(cherry picked from commit 1e3da48d70)

Co-authored-by: Yoann Gauthier-Colin <yoann@gwerlas.net>
This commit is contained in:
patchback[bot] 2026-06-02 21:18:25 +02:00 committed by GitHub
parent 8f62bee2ac
commit f414c77e17
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 1 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- "portage - fix ``depclean: true`` crashing with ``AnsibleModule.fail_json() missing 1 required positional argument: 'msg'`` instead of reporting the actual emerge failure (https://github.com/ansible-collections/community.general/pull/12168)."

View file

@ -508,7 +508,13 @@ def cleanup_packages(module, packages):
cmd, (rc, out, err) = run_emerge(module, packages, *args)
if rc != 0:
module.fail_json(cmd=cmd, rc=rc, stdout=out, stderr=err)
module.fail_json(
cmd=cmd,
rc=rc,
stdout=out,
stderr=err,
msg="Packages not cleaned up.",
)
removed = 0
for line in out.splitlines():