mirror of
https://github.com/ansible/awx.git
synced 2026-04-28 05:05:25 -02:30
Merge branch 'release_2.4.4' into devel
* release_2.4.4: (35 commits) Update changelog for 2.4.4 release Make pycompile non-fatal during deb build Revert "Add virtualenv site-pagkages to Python path before system dist-packages, to get new setuptools" Roll back mock version due to packaging issues Add virtualenv site-pagkages to Python path before system dist-packages, to get new setuptools change to warning behavior Resolve bug when building with /bin/sh on Ubuntu Attempt to workaround pip install issue point at packages with source on pypi Mock requires a newer setuptools when building requirements requests needs openssl Properly set the shell during directory migration pyrax bumpb new python license Typo's are bad and should be vanquished Conditionally install 2.6 python requirements separate pip requirements file for python2.6 Added missing 'skipped' field for no_log Obey no_log even more when using ansible 2.0 bump shade from 0.5.0 to 1.4 RHEL5 compatibility and handling of error scenarios ...
This commit is contained in:
@@ -38,6 +38,7 @@ import os
|
||||
import pwd
|
||||
import urlparse
|
||||
import re
|
||||
from copy import deepcopy
|
||||
|
||||
# Requests
|
||||
import requests
|
||||
@@ -72,6 +73,40 @@ else:
|
||||
pass
|
||||
statsd = NoStatsClient()
|
||||
|
||||
CENSOR_FIELD_WHITELIST=[
|
||||
'msg',
|
||||
'failed',
|
||||
'changed',
|
||||
'results',
|
||||
'start',
|
||||
'end',
|
||||
'delta',
|
||||
'cmd',
|
||||
'_ansible_no_log',
|
||||
'cmd',
|
||||
'rc',
|
||||
'failed_when_result',
|
||||
'skipped',
|
||||
'skip_reason',
|
||||
]
|
||||
|
||||
def censor(obj):
|
||||
if obj.get('_ansible_no_log', False):
|
||||
new_obj = {}
|
||||
for k in CENSOR_FIELD_WHITELIST:
|
||||
if k in obj:
|
||||
new_obj[k] = obj[k]
|
||||
if k == 'cmd' and k in obj:
|
||||
if re.search(r'\s', obj['cmd']):
|
||||
new_obj['cmd'] = re.sub(r'^(([^\s\\]|\\\s)+).*$',
|
||||
r'\1 <censored>',
|
||||
obj['cmd'])
|
||||
new_obj['censored'] = "the output has been hidden due to the fact that 'no_log: true' was specified for this result"
|
||||
obj = new_obj
|
||||
if 'results' in obj:
|
||||
for i in xrange(len(obj['results'])):
|
||||
obj['results'][i] = censor(obj['results'][i])
|
||||
return obj
|
||||
|
||||
class TokenAuth(requests.auth.AuthBase):
|
||||
|
||||
@@ -211,6 +246,9 @@ class BaseCallbackModule(object):
|
||||
response.raise_for_status()
|
||||
|
||||
def _log_event(self, event, **event_data):
|
||||
if 'res' in event_data:
|
||||
event_data['res'] = censor(deepcopy(event_data['res']))
|
||||
|
||||
if self.callback_consumer_port:
|
||||
with statsd.timer('zmq_post_event_msg.{0}'.format(event)):
|
||||
self._post_job_event_queue_msg(event, event_data)
|
||||
|
||||
Reference in New Issue
Block a user