From 1cfd941179a7ffd11f35ac2106311c87cc7c67ba Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Mon, 19 Oct 2015 13:40:25 -0400 Subject: [PATCH] Adding a v2 callback for task includes --- lib/ansible/plugins/callback/__init__.py | 4 ++++ lib/ansible/plugins/callback/default.py | 15 +++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/ansible/plugins/callback/__init__.py b/lib/ansible/plugins/callback/__init__.py index fff0a6dc56..c75cc3d710 100644 --- a/lib/ansible/plugins/callback/__init__.py +++ b/lib/ansible/plugins/callback/__init__.py @@ -292,3 +292,7 @@ class CallbackBase: def v2_playbook_on_item_skipped(self, result): pass # no v1 + + def v2_playbook_on_include(self, included_file): + pass #no v1 correspondance + diff --git a/lib/ansible/plugins/callback/default.py b/lib/ansible/plugins/callback/default.py index 2969d00526..f6ba1fe426 100644 --- a/lib/ansible/plugins/callback/default.py +++ b/lib/ansible/plugins/callback/default.py @@ -61,8 +61,7 @@ class CallbackModule(CallbackBase): def v2_runner_on_ok(self, result): if result._task.action == 'include': - msg = 'included: %s for %s' % (result._task.args.get('_raw_params'), result._host.name) - color = 'cyan' + return elif result._result.get('changed', False): if result._task.delegate_to is not None or result._task._local_action: if result._task._local_action: @@ -88,7 +87,7 @@ class CallbackModule(CallbackBase): self._process_items(result) else: - if (self._display.verbosity > 0 or '_ansible_verbose_always' in result._result) and not '_ansible_verbose_override' in result._result and result._task.action != 'include': + if (self._display.verbosity > 0 or '_ansible_verbose_always' in result._result) and not '_ansible_verbose_override' in result._result: msg += " => %s" % (self._dump_results(result._result),) self._display.display(msg, color=color) @@ -149,8 +148,7 @@ class CallbackModule(CallbackBase): def v2_playbook_item_on_ok(self, result): if result._task.action == 'include': - msg = 'included: %s for %s' % (result._task.args.get('_raw_params'), result._host.name) - color = 'cyan' + return elif result._result.get('changed', False): msg = "changed: [%s]" % result._host.get_name() color = 'yellow' @@ -160,7 +158,7 @@ class CallbackModule(CallbackBase): msg += " => (item=%s)" % (result._result['item'],) - if (self._display.verbosity > 0 or '_ansible_verbose_always' in result._result) and not '_ansible_verbose_override' in result._result and result._task.action != 'include': + if (self._display.verbosity > 0 or '_ansible_verbose_always' in result._result) and not '_ansible_verbose_override' in result._result: msg += " => %s" % self._dump_results(result._result) self._display.display(msg, color=color) @@ -187,3 +185,8 @@ class CallbackModule(CallbackBase): msg += " => %s" % self._dump_results(result._result) self._display.display(msg, color='cyan') + def v2_playbook_on_include(self, included_file): + msg = 'included: %s for %s' % (included_file._filename, ", ".join([h.name for h in included_file._hosts])) + color = 'cyan' + self._display.display(msg, color='cyan') +