diff --git a/lib/ansible/plugins/callback/foreman.py b/lib/ansible/plugins/callback/foreman.py index 24b3fcc416..48922dcb57 100644 --- a/lib/ansible/plugins/callback/foreman.py +++ b/lib/ansible/plugins/callback/foreman.py @@ -189,10 +189,8 @@ class CallbackModule(CallbackBase): def v2_runner_on_ok(self, result): res = result._result - try: - module = res['invocation']['module_name'] - except KeyError: - module = None + module = result._task.action + if module == 'setup': host = result._host.get_name() self.send_facts(host, res) diff --git a/lib/ansible/plugins/callback/mail.py b/lib/ansible/plugins/callback/mail.py index 71d54073a4..443bcba567 100644 --- a/lib/ansible/plugins/callback/mail.py +++ b/lib/ansible/plugins/callback/mail.py @@ -87,7 +87,7 @@ class CallbackModule(CallbackBase): sender = '"Ansible: %s" ' % host attach = res._task.action if 'invocation' in res._result: - attach = "%s: %s" % (res._result['invocation']['module_name'], json.dumps(res._result['invocation']['module_args'])) + attach = "%s: %s" % (res._task.action, 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