summaryrefslogtreecommitdiff
path: root/lib/ansible/plugins/callback/oneline.py
diff options
context:
space:
mode:
authorBrian Coca <brian.coca+git@gmail.com>2015-07-23 13:42:20 -0400
committerBrian Coca <brian.coca+git@gmail.com>2015-07-23 13:42:20 -0400
commita6ba149c496d20410f12a74aee3af615e62c4266 (patch)
tree0a68cf05d299ea70295e7a8bacce53880f76ed31 /lib/ansible/plugins/callback/oneline.py
parent65ae9780fa47e4d9f368643c100aad6682208aec (diff)
downloadansible-a6ba149c496d20410f12a74aee3af615e62c4266.tar.gz
implemented simplified output for adhoc adn command modules as in v1
Diffstat (limited to 'lib/ansible/plugins/callback/oneline.py')
-rw-r--r--lib/ansible/plugins/callback/oneline.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/ansible/plugins/callback/oneline.py b/lib/ansible/plugins/callback/oneline.py
index d7e76151b4..15a8aee3c8 100644
--- a/lib/ansible/plugins/callback/oneline.py
+++ b/lib/ansible/plugins/callback/oneline.py
@@ -20,6 +20,7 @@ from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible.plugins.callback import CallbackBase
+from ansible import constants as C
class CallbackModule(CallbackBase):
@@ -33,6 +34,12 @@ class CallbackModule(CallbackBase):
CALLBACK_TYPE = 'stdout'
CALLBACK_NAME = 'oneline'
+ def _command_generic_msg(self, hostname, result, caption):
+ if 'stderr' in result and result['stderr']:
+ return "%s | %s | rc=%s | (stdout) %s (stderr) %s" % (hostname, caption, result.get('rc',0), result.get('stdout',''), result.get('stderr',''))
+ else:
+ return "%s | %s | rc=%s | (stdout) %s" % (hostname, caption, result.get('rc',0), result.get('stdout',''))
+
def v2_runner_on_failed(self, result, ignore_errors=False):
if 'exception' in result._result:
if self._display.verbosity < 3:
@@ -42,7 +49,10 @@ class CallbackModule(CallbackBase):
else:
msg = "An exception occurred during task execution. The full traceback is:\n" + result._result['exception'].replace('\n','')
- self._display.display(msg, color='red')
+ if result._task.action in C.MODULE_NO_JSON:
+ self._display.display(self._command_generic_msg(result._host.get_name(), result._result,'FAILED'), color='red')
+ else:
+ self._display.display(msg, color='red')
# finally, remove the exception from the result so it's not shown every time
del result._result['exception']
@@ -50,7 +60,10 @@ class CallbackModule(CallbackBase):
self._display.display("%s | FAILED! => %s" % (result._host.get_name(), self._dump_results(result._result, indent=0).replace('\n','')), color='red')
def v2_runner_on_ok(self, result):
- self._display.display("%s | SUCCESS => %s" % (result._host.get_name(), self._dump_results(result._result, indent=0).replace('\n','')), color='green')
+ if result._task.action in C.MODULE_NO_JSON:
+ self._display.display(self._command_generic_msg(result._host.get_name(), result._result,'SUCCESS'), color='green')
+ else:
+ self._display.display("%s | SUCCESS => %s" % (result._host.get_name(), self._dump_results(result._result, indent=0).replace('\n','')), color='green')
def v2_runner_on_unreachable(self, result):