diff options
author | Martin Krizek <martin.krizek@gmail.com> | 2022-09-13 09:50:10 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-13 09:50:10 +0200 |
commit | a6d4c3ff7cf43c24be6622102cee834fc5096496 (patch) | |
tree | 44e0f73db03ade5bc2be1b96780b1a29f11adf15 | |
parent | uri: added use_netrc argument to allow ignoring netrc (#74397) (#78569) (diff) | |
download | ansible-a6d4c3ff7cf43c24be6622102cee834fc5096496.tar.xz ansible-a6d4c3ff7cf43c24be6622102cee834fc5096496.zip |
Print skip reason for skipped meta tasks instead of an empty msg in -vv (#78681)
Fixes #77315
-rw-r--r-- | changelogs/fragments/77315-fix-meta-vv-header.yml | 2 | ||||
-rw-r--r-- | lib/ansible/plugins/strategy/__init__.py | 6 | ||||
-rwxr-xr-x | test/integration/targets/meta_tasks/runme.sh | 4 |
3 files changed, 8 insertions, 4 deletions
diff --git a/changelogs/fragments/77315-fix-meta-vv-header.yml b/changelogs/fragments/77315-fix-meta-vv-header.yml new file mode 100644 index 0000000000..cddc7441fe --- /dev/null +++ b/changelogs/fragments/77315-fix-meta-vv-header.yml @@ -0,0 +1,2 @@ +bugfixes: + - Fix ``-vv`` output for meta tasks to not have an empty message when skipped, print the skip reason instead. (https://github.com/ansible/ansible/issues/77315) diff --git a/lib/ansible/plugins/strategy/__init__.py b/lib/ansible/plugins/strategy/__init__.py index fd295055ef..2f04a3f73f 100644 --- a/lib/ansible/plugins/strategy/__init__.py +++ b/lib/ansible/plugins/strategy/__init__.py @@ -912,7 +912,7 @@ class StrategyBase: return task.evaluate_conditional(templar, all_vars) skipped = False - msg = '' + msg = meta_action skip_reason = '%s conditional evaluated to False' % meta_action if isinstance(task, Handler): self._tqm.send_callback('v2_playbook_on_handler_task_start', task) @@ -1049,7 +1049,9 @@ class StrategyBase: else: result['changed'] = False - display.vv("META: %s" % msg) + if not task.implicit: + header = skip_reason if skipped else msg + display.vv(f"META: {header}") if isinstance(task, Handler): task.remove_host(target_host) diff --git a/test/integration/targets/meta_tasks/runme.sh b/test/integration/targets/meta_tasks/runme.sh index bee6636314..f7d8d8973f 100755 --- a/test/integration/targets/meta_tasks/runme.sh +++ b/test/integration/targets/meta_tasks/runme.sh @@ -6,7 +6,7 @@ set -eux for test_strategy in linear free; do out="$(ansible-playbook test_end_host.yml -i inventory.yml -e test_strategy=$test_strategy -vv "$@")" - grep -q "META: end_host conditional evaluated to false, continuing execution for testhost" <<< "$out" + grep -q "META: end_host conditional evaluated to False, continuing execution for testhost" <<< "$out" grep -q "META: ending play for testhost2" <<< "$out" grep -q '"skip_reason": "end_host conditional evaluated to False, continuing execution for testhost"' <<< "$out" grep -q "play not ended for testhost" <<< "$out" @@ -14,7 +14,7 @@ for test_strategy in linear free; do out="$(ansible-playbook test_end_host_fqcn.yml -i inventory.yml -e test_strategy=$test_strategy -vv "$@")" - grep -q "META: end_host conditional evaluated to false, continuing execution for testhost" <<< "$out" + grep -q "META: end_host conditional evaluated to False, continuing execution for testhost" <<< "$out" grep -q "META: ending play for testhost2" <<< "$out" grep -q '"skip_reason": "end_host conditional evaluated to False, continuing execution for testhost"' <<< "$out" grep -q "play not ended for testhost" <<< "$out" |