Merge pull request #5989 from jangsutsr/5986_prevent_unexpected_callback_module_attribute_warning

Prevent unexpected callback module attribute warning
This commit is contained in:
Aaron Tan 2017-04-11 14:54:38 -04:00 committed by GitHub
commit 9027616420
2 changed files with 14 additions and 3 deletions

View File

@ -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()

View File

@ -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: