Handle debug messages cleanly
This changes from: 2017-09-06 18:17:37.173853 | TASK [debug] 2017-09-06 18:17:37.216661 | localhost | ok: 2017-09-06 18:17:37.216882 | localhost | { 2017-09-06 18:17:37.216967 | localhost | "msg": "Job triggered from https://review.openstack.org/#/c/501485" 2017-09-06 18:17:37.217047 | localhost | } to: 2017-09-06 18:20:34.383995 | TASK [debug] 2017-09-06 18:20:34.429648 | Job triggered from https://review.openstack.org/#/c/501485 Change-Id: Iac39124c2a3b286215d175f98742d00ec5a12778
This commit is contained in:
parent
34ac31f186
commit
7b871b47f3
|
@ -10,6 +10,10 @@
|
|||
debug:
|
||||
var: setupvar
|
||||
|
||||
- name: Output a debug sentence
|
||||
debug:
|
||||
msg: This is a debug message
|
||||
|
||||
- name: Run a shell task
|
||||
command: ip addr show
|
||||
|
||||
|
|
|
@ -374,9 +374,20 @@ class CallbackModule(default.CallbackModule):
|
|||
for key in [k for k in result_dict.keys()
|
||||
if k.startswith('_ansible')]:
|
||||
del result_dict[key]
|
||||
self._log_message(
|
||||
msg=json.dumps(result_dict, indent=2, sort_keys=True),
|
||||
status=status, result=result)
|
||||
keyname = next(iter(result_dict.keys()))
|
||||
# If it has msg, that means it was like:
|
||||
#
|
||||
# debug:
|
||||
# msg: Some debug text the user was looking for
|
||||
#
|
||||
# So we log it with self._log to get just the raw string the
|
||||
# user provided.
|
||||
if keyname == 'msg':
|
||||
self._log(msg=result_dict['msg'])
|
||||
else:
|
||||
self._log_message(
|
||||
msg=json.dumps(result_dict, indent=2, sort_keys=True),
|
||||
status=status, result=result)
|
||||
elif result._task.action not in ('command', 'shell'):
|
||||
if 'msg' in result_dict:
|
||||
self._log_message(msg=result_dict['msg'],
|
||||
|
|
Loading…
Reference in New Issue