From 50f221c63e3aba80e8671fb8413e3a75d78c528f Mon Sep 17 00:00:00 2001 From: Martin Krizek Date: Thu, 27 Aug 2020 21:49:53 +0200 Subject: [PATCH] Fix incorrect msg in the results dict in loops (#71482) --- changelogs/fragments/fix-incorrect-msg-in-loops-results.yml | 2 ++ lib/ansible/executor/task_executor.py | 2 +- .../callback_default/callback_default.out.default.stdout | 2 +- .../callback_default.out.failed_to_stderr.stderr | 2 +- .../callback_default/callback_default.out.hide_ok.stdout | 2 +- .../callback_default/callback_default.out.hide_skipped.stdout | 2 +- .../callback_default.out.hide_skipped_ok.stdout | 2 +- 7 files changed, 8 insertions(+), 6 deletions(-) create mode 100644 changelogs/fragments/fix-incorrect-msg-in-loops-results.yml diff --git a/changelogs/fragments/fix-incorrect-msg-in-loops-results.yml b/changelogs/fragments/fix-incorrect-msg-in-loops-results.yml new file mode 100644 index 00000000000..81f2b66e6ff --- /dev/null +++ b/changelogs/fragments/fix-incorrect-msg-in-loops-results.yml @@ -0,0 +1,2 @@ +bugfixes: + - Fix incorrect msg in the results dict in loops diff --git a/lib/ansible/executor/task_executor.py b/lib/ansible/executor/task_executor.py index d71a5905615..145de983a7d 100644 --- a/lib/ansible/executor/task_executor.py +++ b/lib/ansible/executor/task_executor.py @@ -145,7 +145,7 @@ class TaskExecutor: res[array] = res[array] + item[array] del item[array] - if not res.get('Failed', False): + if not res.get('failed', False): res['msg'] = 'All items completed' else: res = dict(changed=False, skipped=True, skipped_reason='No items in the list', results=[]) diff --git a/test/integration/targets/callback_default/callback_default.out.default.stdout b/test/integration/targets/callback_default/callback_default.out.default.stdout index 05f90beb12f..9754a6265fc 100644 --- a/test/integration/targets/callback_default/callback_default.out.default.stdout +++ b/test/integration/targets/callback_default/callback_default.out.default.stdout @@ -33,7 +33,7 @@ ok: [testhost] => (item=debug-3) => { "msg": "debug-3" } skipping: [testhost] => (item=debug-4) -fatal: [testhost]: FAILED! => {"msg": "All items completed"} +fatal: [testhost]: FAILED! => {"msg": "One or more items failed"} ...ignoring TASK [EXPECTED FAILURE Failed task to be rescued] ****************************** diff --git a/test/integration/targets/callback_default/callback_default.out.failed_to_stderr.stderr b/test/integration/targets/callback_default/callback_default.out.failed_to_stderr.stderr index 932a2e4f501..45d4af21f3d 100644 --- a/test/integration/targets/callback_default/callback_default.out.failed_to_stderr.stderr +++ b/test/integration/targets/callback_default/callback_default.out.failed_to_stderr.stderr @@ -1,5 +1,5 @@ + ansible-playbook -i inventory test.yml ++ set +x fatal: [testhost]: FAILED! => {"changed": false, "msg": "no reason"} -fatal: [testhost]: FAILED! => {"msg": "All items completed"} +fatal: [testhost]: FAILED! => {"msg": "One or more items failed"} fatal: [testhost]: FAILED! => {"changed": false, "msg": "Failed as requested from task"} diff --git a/test/integration/targets/callback_default/callback_default.out.hide_ok.stdout b/test/integration/targets/callback_default/callback_default.out.hide_ok.stdout index c1e1846bc5f..02ad0b6c7dd 100644 --- a/test/integration/targets/callback_default/callback_default.out.hide_ok.stdout +++ b/test/integration/targets/callback_default/callback_default.out.hide_ok.stdout @@ -27,7 +27,7 @@ failed: [testhost] (item=debug-2) => { "msg": "debug-2" } skipping: [testhost] => (item=debug-4) -fatal: [testhost]: FAILED! => {"msg": "All items completed"} +fatal: [testhost]: FAILED! => {"msg": "One or more items failed"} ...ignoring TASK [EXPECTED FAILURE Failed task to be rescued] ****************************** diff --git a/test/integration/targets/callback_default/callback_default.out.hide_skipped.stdout b/test/integration/targets/callback_default/callback_default.out.hide_skipped.stdout index 660c7285484..d897a7fc081 100644 --- a/test/integration/targets/callback_default/callback_default.out.hide_skipped.stdout +++ b/test/integration/targets/callback_default/callback_default.out.hide_skipped.stdout @@ -29,7 +29,7 @@ failed: [testhost] (item=debug-2) => { ok: [testhost] => (item=debug-3) => { "msg": "debug-3" } -fatal: [testhost]: FAILED! => {"msg": "All items completed"} +fatal: [testhost]: FAILED! => {"msg": "One or more items failed"} ...ignoring TASK [EXPECTED FAILURE Failed task to be rescued] ****************************** diff --git a/test/integration/targets/callback_default/callback_default.out.hide_skipped_ok.stdout b/test/integration/targets/callback_default/callback_default.out.hide_skipped_ok.stdout index 13948b9f229..3354ae495d8 100644 --- a/test/integration/targets/callback_default/callback_default.out.hide_skipped_ok.stdout +++ b/test/integration/targets/callback_default/callback_default.out.hide_skipped_ok.stdout @@ -23,7 +23,7 @@ changed: [testhost] => (item=debug-1) => { failed: [testhost] (item=debug-2) => { "msg": "debug-2" } -fatal: [testhost]: FAILED! => {"msg": "All items completed"} +fatal: [testhost]: FAILED! => {"msg": "One or more items failed"} ...ignoring TASK [EXPECTED FAILURE Failed task to be rescued] ******************************