Print skip reason for skipped meta tasks instead of an empty msg in -vv (#78681)

Fixes #77315
pull/75715/head
Martin Krizek 2 years ago committed by GitHub
parent a26c325bd8
commit a6d4c3ff7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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

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

@ -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"

Loading…
Cancel
Save