diff --git a/changelogs/fragments/show_host_start.yml b/changelogs/fragments/show_host_start.yml new file mode 100644 index 0000000000..43a4c768f9 --- /dev/null +++ b/changelogs/fragments/show_host_start.yml @@ -0,0 +1,2 @@ +minor_changes: + - Add toggle to show per host task start on default callback diff --git a/lib/ansible/plugins/callback/default.py b/lib/ansible/plugins/callback/default.py index 6c41e706c9..140c0e1244 100644 --- a/lib/ansible/plugins/callback/default.py +++ b/lib/ansible/plugins/callback/default.py @@ -227,6 +227,10 @@ class CallbackModule(CallbackBase): def v2_playbook_on_handler_task_start(self, task): self._task_start(task, prefix='RUNNING HANDLER') + def v2_runner_on_start(self, host, task): + if self.get_option('show_per_host_start'): + self._display.display(" [started %s on %s]" % (task, host), color=C.COLOR_OK) + def v2_playbook_on_play_start(self, play): name = play.get_name().strip() if not name: diff --git a/lib/ansible/plugins/doc_fragments/default_callback.py b/lib/ansible/plugins/doc_fragments/default_callback.py index c3c4178a5a..c426cc11c1 100644 --- a/lib/ansible/plugins/doc_fragments/default_callback.py +++ b/lib/ansible/plugins/doc_fragments/default_callback.py @@ -55,4 +55,15 @@ class ModuleDocFragment(object): ini: - key: show_custom_stats section: defaults + show_per_host_start: + name: Show per host task start + description: 'This adds output that shows when a task is started to execute for each host' + type: bool + default: no + env: + - name: ANSIBLE_SHOW_PER_HOST_START + ini: + - key: show_per_host_start + section: defaults + version_added: '2.9' ''' diff --git a/test/integration/targets/ansible-runner/tasks/playbook_example1.yml b/test/integration/targets/ansible-runner/tasks/playbook_example1.yml index 82832973f0..381d4279e8 100644 --- a/test/integration/targets/ansible-runner/tasks/playbook_example1.yml +++ b/test/integration/targets/ansible-runner/tasks/playbook_example1.yml @@ -12,5 +12,5 @@ - assert: that: - "pbexec_json.rc == 0" - - "pbexec_json.events|length == 6" + - "pbexec_json.events|length == 7" - "'localhost' in pbexec_json.stats.ok"