From 358770eb146f623f84993fd4847dc158d121f2d7 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Fri, 5 Jun 2026 13:47:30 +0200 Subject: [PATCH] [PR #12185/213581be backport][stable-12] fix: treat chdev execution failures as module errors in aix_devices (#12196) fix: treat chdev execution failures as module errors in aix_devices (#12185) * fix: treat chdev execution failures as module errors in aix_devices ##### SUMMARY Fix the aix_devices module so that a failed chdev command is reported as a module failure instead of a successful result. The previous implementation called fail_json incorrectly by returning success through the normal completion path when chdev returned a non-zero exit status. This could allow a playbook to continue even though the requested device attribute change was not applied. This change replaces the success-style error handling with proper failure handling in the chdev execution path, making task results consistent with the actual command outcome. ##### ISSUE TYPE - Bugfix Pull Request ##### COMPONENT NAME aix_devices ##### ADDITIONAL INFORMATION The affected code path is in change_device_attr() when the module executes chdev to apply attribute updates. Before this change: - chdev could fail - the module could still report success - later tasks could run against an unexpected system state After this change: - chdev failures are returned through fail_json - the task stops with an error - playbook behavior matches the real execution result ```paste below Before: module.exit_json(msg="Failed to run chdev.", rc=rc, err=err) After: module.fail_json(msg="Failed to run chdev.", rc=rc, err=err) ``` * Add changelog fragment for aix_devices chdev failure fix (#12185) --------- (cherry picked from commit 213581bef88728dca938edeb24acd421c1045c75) Co-authored-by: Hirofumi Arimoto Co-authored-by: Hirofumi Arimoto --- changelogs/fragments/12185-aix-devices-chdev-fail.yml | 2 ++ plugins/modules/aix_devices.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/12185-aix-devices-chdev-fail.yml diff --git a/changelogs/fragments/12185-aix-devices-chdev-fail.yml b/changelogs/fragments/12185-aix-devices-chdev-fail.yml new file mode 100644 index 0000000000..20c31ee050 --- /dev/null +++ b/changelogs/fragments/12185-aix-devices-chdev-fail.yml @@ -0,0 +1,2 @@ +bugfixes: + - "aix_devices - fix ``chdev`` command failures being incorrectly reported as successful results, now properly fails the task when device attribute changes cannot be applied (https://github.com/ansible-collections/community.general/pull/12185)." diff --git a/plugins/modules/aix_devices.py b/plugins/modules/aix_devices.py index 93fa95960b..37d117b1e5 100644 --- a/plugins/modules/aix_devices.py +++ b/plugins/modules/aix_devices.py @@ -235,7 +235,7 @@ def change_device_attr(module, attributes, device, force): if not module.check_mode: rc, chdev_out, err = module.run_command(cmd) if rc != 0: - module.exit_json(msg="Failed to run chdev.", rc=rc, err=err) + module.fail_json(msg="Failed to run chdev.", rc=rc, err=err) attr_changed.append(attributes[attr]) else: