[default callback] Show include_tasks task banner (#71821)

Change:
- In some cases (always with free strategy, sometimes with linear), the
  default callback would not show the task banner for include_tasks.
- This only affects the include_tasks task itself, not the tasks in the
  included file.

Test Plan:
- Updated default callback tests

Tickets:
- Fixes #71277

Signed-off-by: Rick Elrod <rick@elrod.me>
This commit is contained in:
Rick Elrod 2020-09-22 10:40:12 -05:00 committed by GitHub
parent a99212464c
commit abfb7919dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 61 additions and 14 deletions

View file

@ -0,0 +1,3 @@
minor_changes:
- default callback - task name is now shown for ``include_tasks`` when using the ``free`` strategy (https://github.com/ansible/ansible/issues/71277).
- default callback - task name is now shown for ``include_tasks`` when using the ``linear`` strategy with ``ANSIBLE_DISPLAY_SKIPPED_HOSTS=0``.

View file

@ -106,6 +106,8 @@ class CallbackModule(CallbackBase):
delegated_vars = result._result.get('_ansible_delegated_vars', None)
if isinstance(result._task, TaskInclude):
if self._last_task_banner != result._task._uuid:
self._print_task_banner(result._task)
return
elif result._result.get('changed', False):
if self._last_task_banner != result._task._uuid:

View file

@ -67,6 +67,14 @@ changed: [testhost]
TASK [Second free task] ********************************************************
changed: [testhost]
PLAY RECAP *********************************************************************
testhost : ok=14 changed=9 unreachable=0 failed=0 skipped=1 rescued=1 ignored=2
TASK [Include some tasks] ******************************************************
included: .../test/integration/targets/callback_default/include_me.yml for testhost => (item=1)
TASK [debug] *******************************************************************
ok: [testhost] => {
"item": 1
}
PLAY RECAP *********************************************************************
testhost : ok=16 changed=9 unreachable=0 failed=0 skipped=1 rescued=1 ignored=2

View file

@ -64,6 +64,14 @@ changed: [testhost]
TASK [Second free task] ********************************************************
changed: [testhost]
PLAY RECAP *********************************************************************
testhost : ok=14 changed=9 unreachable=0 failed=0 skipped=1 rescued=1 ignored=2
TASK [Include some tasks] ******************************************************
included: .../test/integration/targets/callback_default/include_me.yml for testhost => (item=1)
TASK [debug] *******************************************************************
ok: [testhost] => {
"item": 1
}
PLAY RECAP *********************************************************************
testhost : ok=16 changed=9 unreachable=0 failed=0 skipped=1 rescued=1 ignored=2

View file

@ -35,6 +35,8 @@ fatal: [testhost]: FAILED! => {"changed": false, "msg": "Failed as requested fro
TASK [Rescue task] *************************************************************
changed: [testhost]
TASK [include_tasks] ***********************************************************
included: .../test/integration/targets/callback_default/include_me.yml for testhost => (item=1)
RUNNING HANDLER [Test handler 1] ***********************************************
@ -51,6 +53,9 @@ changed: [testhost]
TASK [Second free task] ********************************************************
changed: [testhost]
PLAY RECAP *********************************************************************
testhost : ok=14 changed=9 unreachable=0 failed=0 skipped=1 rescued=1 ignored=2
TASK [Include some tasks] ******************************************************
included: .../test/integration/targets/callback_default/include_me.yml for testhost => (item=1)
PLAY RECAP *********************************************************************
testhost : ok=16 changed=9 unreachable=0 failed=0 skipped=1 rescued=1 ignored=2

View file

@ -37,6 +37,8 @@ fatal: [testhost]: FAILED! => {"changed": false, "msg": "Failed as requested fro
TASK [Rescue task] *************************************************************
changed: [testhost]
TASK [include_tasks] ***********************************************************
included: .../test/integration/targets/callback_default/include_me.yml for testhost => (item=1)
TASK [debug] *******************************************************************
@ -61,6 +63,14 @@ changed: [testhost]
TASK [Second free task] ********************************************************
changed: [testhost]
PLAY RECAP *********************************************************************
testhost : ok=14 changed=9 unreachable=0 failed=0 skipped=1 rescued=1 ignored=2
TASK [Include some tasks] ******************************************************
included: .../test/integration/targets/callback_default/include_me.yml for testhost => (item=1)
TASK [debug] *******************************************************************
ok: [testhost] => {
"item": 1
}
PLAY RECAP *********************************************************************
testhost : ok=16 changed=9 unreachable=0 failed=0 skipped=1 rescued=1 ignored=2

View file

@ -31,6 +31,8 @@ fatal: [testhost]: FAILED! => {"changed": false, "msg": "Failed as requested fro
TASK [Rescue task] *************************************************************
changed: [testhost]
TASK [include_tasks] ***********************************************************
included: .../test/integration/targets/callback_default/include_me.yml for testhost => (item=1)
RUNNING HANDLER [Test handler 1] ***********************************************
@ -47,6 +49,9 @@ changed: [testhost]
TASK [Second free task] ********************************************************
changed: [testhost]
PLAY RECAP *********************************************************************
testhost : ok=14 changed=9 unreachable=0 failed=0 skipped=1 rescued=1 ignored=2
TASK [Include some tasks] ******************************************************
included: .../test/integration/targets/callback_default/include_me.yml for testhost => (item=1)
PLAY RECAP *********************************************************************
testhost : ok=16 changed=9 unreachable=0 failed=0 skipped=1 rescued=1 ignored=2

View file

@ -86,3 +86,9 @@
- name: Second free task
command: echo foo
# Ensure include_tasks task names get shown (#71277)
- name: Include some tasks
include_tasks: include_me.yml
loop:
- 1

View file

@ -3,7 +3,7 @@
hosts: testhost
gather_facts: no
tasks:
- debug:
- debug:
msg: 'ansible_check_mode: {{ansible_check_mode}}'
- name: Command
@ -23,12 +23,12 @@
gather_facts: no
check_mode: true
tasks:
- debug:
- debug:
msg: 'ansible_check_mode: {{ansible_check_mode}}'
- name: Command
command: ls -l
- name: "Command with check_mode: false"
command: ls -l
check_mode: false
@ -43,7 +43,7 @@
gather_facts: no
check_mode: false
tasks:
- debug:
- debug:
msg: 'ansible_check_mode: {{ansible_check_mode}}'
- name: Command