diff --git a/lib/ansible/plugins/callback/__init__.py b/lib/ansible/plugins/callback/__init__.py
index 776ad15717..17a6606fb8 100644
--- a/lib/ansible/plugins/callback/__init__.py
+++ b/lib/ansible/plugins/callback/__init__.py
@@ -16,7 +16,7 @@
# along with Ansible. If not, see .
# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
+from __future__ import (absolute_import, division)
__metaclass__ = type
__all__ = ["CallbackBase"]
@@ -34,6 +34,11 @@ class CallbackBase:
def __init__(self, display):
self._display = display
+ if self._display.verbosity >= 4:
+ name = getattr(self, 'CALLBACK_NAME', 'with no defined name')
+ ctype = getattr(self, 'CALLBACK_TYPE', 'unknwon')
+ version = getattr(self, 'CALLBACK_VERSION', 'unknwon')
+ self._display.vvvv('Loaded callback %s of type %s, v%s' % (name, ctype, version))
def set_connection_info(self, conn_info):
pass
diff --git a/lib/ansible/plugins/callback/context_demo.py b/lib/ansible/plugins/callback/context_demo.py
index f204ecb3be..ad22ead07d 100644
--- a/lib/ansible/plugins/callback/context_demo.py
+++ b/lib/ansible/plugins/callback/context_demo.py
@@ -24,6 +24,7 @@ class CallbackModule(CallbackBase):
"""
CALLBACK_VERSION = 2.0
CALLBACK_TYPE = 'aggregate'
+ CALLBACK_TYPE = 'context_demo'
def v2_on_any(self, *args, **kwargs):
i = 0
diff --git a/lib/ansible/plugins/callback/default.py b/lib/ansible/plugins/callback/default.py
index 2c4a8cea88..00ba9c72c8 100644
--- a/lib/ansible/plugins/callback/default.py
+++ b/lib/ansible/plugins/callback/default.py
@@ -32,6 +32,7 @@ class CallbackModule(CallbackBase):
CALLBACK_VERSION = 2.0
CALLBACK_TYPE = 'stdout'
+ CALLBACK_NAME = 'default'
def v2_runner_on_failed(self, result, ignore_errors=False):
if 'exception' in result._result:
diff --git a/lib/ansible/plugins/callback/hipchat.py b/lib/ansible/plugins/callback/hipchat.py
index a2709e3d5b..b0d1bfb67e 100644
--- a/lib/ansible/plugins/callback/hipchat.py
+++ b/lib/ansible/plugins/callback/hipchat.py
@@ -42,7 +42,8 @@ class CallbackModule(CallbackBase):
"""
CALLBACK_VERSION = 2.0
- CALLBACK_TYPE = 'notification'
+ CALLBACK_VERSION = 2.0
+ CALLBACK_NAME = 'hipchat'
def __init__(self, display):
diff --git a/lib/ansible/plugins/callback/log_plays.py b/lib/ansible/plugins/callback/log_plays.py
index 65036e6763..7cdedcb00e 100644
--- a/lib/ansible/plugins/callback/log_plays.py
+++ b/lib/ansible/plugins/callback/log_plays.py
@@ -34,6 +34,7 @@ class CallbackModule(CallbackBase):
"""
CALLBACK_VERSION = 2.0
CALLBACK_TYPE = 'notification'
+ CALLBACK_NAME = 'log_plays'
TIME_FORMAT="%b %d %Y %H:%M:%S"
MSG_FORMAT="%(now)s - %(category)s - %(data)s\n\n"
diff --git a/lib/ansible/plugins/callback/mail.py b/lib/ansible/plugins/callback/mail.py
index c82acdf2fc..af86e61df9 100644
--- a/lib/ansible/plugins/callback/mail.py
+++ b/lib/ansible/plugins/callback/mail.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
# Copyright 2012 Dag Wieers
#
# This file is part of Ansible
@@ -17,6 +18,7 @@
import os
import smtplib
+import json
from ansible.plugins.callback import CallbackBase
def mail(subject='Ansible error mail', sender=None, to=None, cc=None, bcc=None, body=None, smtphost=None):
@@ -58,6 +60,7 @@ class CallbackModule(CallbackBase):
"""
CALLBACK_VERSION = 2.0
CALLBACK_TYPE = 'notification'
+ CALLBACK_NAME = 'mail'
def v2_runner_on_failed(self, res, ignore_errors=False):
@@ -66,8 +69,9 @@ class CallbackModule(CallbackBase):
if ignore_errors:
return
sender = '"Ansible: %s" ' % host
- subject = 'Failed: %s' % (res._task.action)
- body = 'The following task failed for host ' + host + ':\n\n%s\n\n' % (res._task.action)
+ attach = "%s: %s" % (res._result['invocation']['module_name'], json.dumps(res._result['invocation']['module_args']))
+ subject = 'Failed: %s' % attach
+ body = 'The following task failed for host ' + host + ':\n\n%s\n\n' % attach
if 'stdout' in res._result.keys() and res._result['stdout']:
subject = res._result['stdout'].strip('\r\n').split('\n')[-1]
@@ -78,7 +82,7 @@ class CallbackModule(CallbackBase):
if 'msg' in res._result.keys() and res._result['msg']:
subject = res._result['msg'].strip('\r\n').split('\n')[0]
body += 'with the following message:\n\n' + res._result['msg'] + '\n\n'
- body += 'A complete dump of the error:\n\n' + str(res._result['msg'])
+ body += 'A complete dump of the error:\n\n' + json.dumps(res._result, indent=4)
mail(sender=sender, subject=subject, body=body)
def v2_runner_on_unreachable(self, result):
diff --git a/lib/ansible/plugins/callback/minimal.py b/lib/ansible/plugins/callback/minimal.py
index d0c314e1b9..d5950fae01 100644
--- a/lib/ansible/plugins/callback/minimal.py
+++ b/lib/ansible/plugins/callback/minimal.py
@@ -33,6 +33,7 @@ class CallbackModule(CallbackBase):
CALLBACK_VERSION = 2.0
CALLBACK_TYPE = 'stdout'
+ CALLBACK_NAME = 'minimal'
def v2_on_any(self, *args, **kwargs):
pass
diff --git a/lib/ansible/plugins/callback/osx_say.py b/lib/ansible/plugins/callback/osx_say.py
index bb785b3872..36b053026e 100644
--- a/lib/ansible/plugins/callback/osx_say.py
+++ b/lib/ansible/plugins/callback/osx_say.py
@@ -33,6 +33,7 @@ class CallbackModule(CallbackBase):
"""
CALLBACK_VERSION = 2.0
CALLBACK_TYPE = 'notification'
+ CALLBACK_NAME = 'osx_say'
def __init__(self, display):
diff --git a/lib/ansible/plugins/callback/syslog_json.py b/lib/ansible/plugins/callback/syslog_json.py
index 3be64ee154..fe0281b780 100644
--- a/lib/ansible/plugins/callback/syslog_json.py
+++ b/lib/ansible/plugins/callback/syslog_json.py
@@ -21,6 +21,7 @@ class CallbackModule(CallbackBase):
"""
CALLBACK_VERSION = 2.0
CALLBACK_TYPE = 'aggregate'
+ CALLBACK_NAME = 'syslog_json'
def __init__(self, display):
diff --git a/lib/ansible/plugins/callback/timer.py b/lib/ansible/plugins/callback/timer.py
index d7f2b42a96..058cb4f4a4 100644
--- a/lib/ansible/plugins/callback/timer.py
+++ b/lib/ansible/plugins/callback/timer.py
@@ -10,6 +10,7 @@ class CallbackModule(CallbackBase):
"""
CALLBACK_VERSION = 2.0
CALLBACK_TYPE = 'aggregate'
+ CALLBACK_NAME = 'timer'
start_time = datetime.now()