[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>
pull/71863/head
Rick Elrod 4 years ago committed by GitHub
parent a99212464c
commit abfb7919dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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``.

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

@ -67,6 +67,14 @@ changed: [testhost]
TASK [Second free task] ******************************************************** TASK [Second free task] ********************************************************
changed: [testhost] changed: [testhost]
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 ********************************************************************* PLAY RECAP *********************************************************************
testhost : ok=14 changed=9 unreachable=0 failed=0 skipped=1 rescued=1 ignored=2 testhost : ok=16 changed=9 unreachable=0 failed=0 skipped=1 rescued=1 ignored=2

@ -64,6 +64,14 @@ changed: [testhost]
TASK [Second free task] ******************************************************** TASK [Second free task] ********************************************************
changed: [testhost] changed: [testhost]
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 ********************************************************************* PLAY RECAP *********************************************************************
testhost : ok=14 changed=9 unreachable=0 failed=0 skipped=1 rescued=1 ignored=2 testhost : ok=16 changed=9 unreachable=0 failed=0 skipped=1 rescued=1 ignored=2

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

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

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

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

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

Loading…
Cancel
Save