From cd5eed9828f0f441ad50e1d5135845360506c33e Mon Sep 17 00:00:00 2001 From: Wayne Witzel III Date: Mon, 16 Jan 2017 13:54:07 -0500 Subject: [PATCH 1/2] remove extra censoring code from tower, not needed since Ansible 2.1+ --- awx/lib/tower_display_callback/module.py | 32 +----------------------- 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/awx/lib/tower_display_callback/module.py b/awx/lib/tower_display_callback/module.py index 7336da2f08..beeddffbd5 100644 --- a/awx/lib/tower_display_callback/module.py +++ b/awx/lib/tower_display_callback/module.py @@ -77,41 +77,11 @@ class BaseCallbackModule(CallbackBase): super(BaseCallbackModule, self).__init__() self.task_uuids = set() - def censor_result(self, res, no_log=False): - if not isinstance(res, dict): - if no_log: - return "the output has been hidden due to the fact that 'no_log: true' was specified for this result" - return res - if res.get('_ansible_no_log', no_log): - new_res = {} - for k in self.CENSOR_FIELD_WHITELIST: - if k in res: - new_res[k] = res[k] - if k == 'cmd' and k in res: - if isinstance(res['cmd'], list): - res['cmd'] = ' '.join(res['cmd']) - if re.search(r'\s', res['cmd']): - new_res['cmd'] = re.sub(r'^(([^\s\\]|\\\s)+).*$', - r'\1 ', - res['cmd']) - new_res['censored'] = "the output has been hidden due to the fact that 'no_log: true' was specified for this result" - res = new_res - if 'results' in res: - if isinstance(res['results'], list): - for i in xrange(len(res['results'])): - res['results'][i] = self.censor_result(res['results'][i], res.get('_ansible_no_log', no_log)) - elif res.get('_ansible_no_log', False): - res['results'] = "the output has been hidden due to the fact that 'no_log: true' was specified for this result" - return res - @contextlib.contextmanager def capture_event_data(self, event, **event_data): event_data.setdefault('uuid', str(uuid.uuid4())) - if 'res' in event_data: - event_data['res'] = self.censor_result(copy.copy(event_data['res'])) - if event not in self.EVENTS_WITHOUT_TASK: task = event_data.pop('task', None) else: @@ -258,7 +228,7 @@ class BaseCallbackModule(CallbackBase): if task_uuid in self.task_uuids: # FIXME: When this task UUID repeats, it means the play is using the # free strategy, so different hosts may be running different tasks - # within a play. + # within a play. return self.task_uuids.add(task_uuid) self.set_task(task) From 9592c67c3194993b744474572c8b18abd5b43117 Mon Sep 17 00:00:00 2001 From: Wayne Witzel III Date: Mon, 16 Jan 2017 14:16:24 -0500 Subject: [PATCH 2/2] fixing flake8 errors --- awx/lib/tower_display_callback/module.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/awx/lib/tower_display_callback/module.py b/awx/lib/tower_display_callback/module.py index beeddffbd5..02c5eee432 100644 --- a/awx/lib/tower_display_callback/module.py +++ b/awx/lib/tower_display_callback/module.py @@ -19,8 +19,6 @@ from __future__ import (absolute_import, division, print_function) # Python import contextlib -import copy -import re import sys import uuid