From 9b1107c054aa2d5948af5545a1711aab00d3254d Mon Sep 17 00:00:00 2001 From: Aaron Tan Date: Mon, 10 Apr 2017 14:39:31 -0400 Subject: [PATCH 1/2] Prevent unexpected callback module attribute warning. --- awx/lib/tower_display_callback/module.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/awx/lib/tower_display_callback/module.py b/awx/lib/tower_display_callback/module.py index 76dcb5be7f..14e6fba66d 100644 --- a/awx/lib/tower_display_callback/module.py +++ b/awx/lib/tower_display_callback/module.py @@ -63,7 +63,6 @@ class BaseCallbackModule(CallbackBase): @contextlib.contextmanager def capture_event_data(self, event, **event_data): - event_data.setdefault('uuid', str(uuid.uuid4())) if event not in self.EVENTS_WITHOUT_TASK: @@ -75,7 +74,7 @@ class BaseCallbackModule(CallbackBase): if event_data['res'].get('_ansible_no_log', False): event_data['res'] = {'censored': CENSORED} for i, item in enumerate(event_data['res'].get('results', [])): - if event_data['res']['results'][i].get('_ansible_no_log', False): + if isinstance(item, dict) and item.get('_ansible_no_log', False): event_data['res']['results'][i] = {'censored': CENSORED} with event_context.display_lock: From 6884e44bb35e89cc9e17a50001009685634cf612 Mon Sep 17 00:00:00 2001 From: Aaron Tan Date: Tue, 11 Apr 2017 10:43:00 -0400 Subject: [PATCH 2/2] Unit test added. --- awx/lib/tests/test_display_callback.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/awx/lib/tests/test_display_callback.py b/awx/lib/tests/test_display_callback.py index f84ab0df4f..2e979a67ca 100644 --- a/awx/lib/tests/test_display_callback.py +++ b/awx/lib/tests/test_display_callback.py @@ -86,7 +86,19 @@ def executor(tmpdir_factory, request): - name: Hello Message debug: msg: "Hello World!" -'''} # noqa +'''}, # noqa +{'results_included.yml': ''' +- name: Run module which generates results list + connection: local + hosts: all + gather_facts: no + vars: + results: ['foo', 'bar'] + tasks: + - name: Generate results list + debug: + var: results +'''}, # noqa ]) def test_callback_plugin_receives_events(executor, cache, event, playbook): executor.run()