diff --git a/awx/lib/awx_display_callback/module.py b/awx/lib/awx_display_callback/module.py index ff3b98a559..e6895d5c89 100644 --- a/awx/lib/awx_display_callback/module.py +++ b/awx/lib/awx_display_callback/module.py @@ -318,6 +318,14 @@ class BaseCallbackModule(CallbackBase): with self.capture_event_data('playbook_on_stats', **event_data): super(BaseCallbackModule, self).v2_playbook_on_stats(stats) + @staticmethod + def _get_event_loop(task): + if hasattr(task, 'loop_with'): # Ansible >=2.5 + return task.loop_with + elif hasattr(task, 'loop'): # Ansible <2.4 + return task.loop + return None + def v2_runner_on_ok(self, result): # FIXME: Display detailed results or not based on verbosity. @@ -331,7 +339,7 @@ class BaseCallbackModule(CallbackBase): remote_addr=result._host.address, task=result._task, res=result._result, - event_loop=result._task.loop if hasattr(result._task, 'loop') else None, + event_loop=self._get_event_loop(result._task), ) with self.capture_event_data('runner_on_ok', **event_data): super(BaseCallbackModule, self).v2_runner_on_ok(result) @@ -344,7 +352,7 @@ class BaseCallbackModule(CallbackBase): res=result._result, task=result._task, ignore_errors=ignore_errors, - event_loop=result._task.loop if hasattr(result._task, 'loop') else None, + event_loop=self._get_event_loop(result._task), ) with self.capture_event_data('runner_on_failed', **event_data): super(BaseCallbackModule, self).v2_runner_on_failed(result, ignore_errors) @@ -354,7 +362,7 @@ class BaseCallbackModule(CallbackBase): host=result._host.get_name(), remote_addr=result._host.address, task=result._task, - event_loop=result._task.loop if hasattr(result._task, 'loop') else None, + event_loop=self._get_event_loop(result._task), ) with self.capture_event_data('runner_on_skipped', **event_data): super(BaseCallbackModule, self).v2_runner_on_skipped(result) diff --git a/awx/lib/tests/test_display_callback.py b/awx/lib/tests/test_display_callback.py index e152e26166..fbb5bb19b8 100644 --- a/awx/lib/tests/test_display_callback.py +++ b/awx/lib/tests/test_display_callback.py @@ -177,6 +177,19 @@ def test_callback_plugin_receives_events(executor, cache, event, playbook): when: item != "SENSITIVE-SKIPPED" failed_when: item == "SENSITIVE-FAILED" ignore_errors: yes +'''}, # noqa, NOTE: with_items will be deprecated in 2.9 +{'loop.yml': ''' +- name: loop tasks should be suppressed with no_log + connection: local + hosts: all + gather_facts: no + tasks: + - shell: echo {{ item }} + no_log: true + loop: [ "SENSITIVE", "SENSITIVE-SKIPPED", "SENSITIVE-FAILED" ] + when: item != "SENSITIVE-SKIPPED" + failed_when: item == "SENSITIVE-FAILED" + ignore_errors: yes '''}, # noqa ]) def test_callback_plugin_no_log_filters(executor, cache, playbook):