diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fc63db9fe6..bc5b59571b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -301,7 +301,6 @@ you avoid ever writing sensitive plaintext to disk. * Configuration items defined as paths (local only) now all support shell style interpolations. * Many fixes and new options added to modules, too many to list here. * Now you can see task file and line number when using verbosity of 3 or above. -* Removed the automatically added invocation field from output of modules. It's no longer needed by the code. ## 1.9.4 "Dancing In the Street" - Oct 9, 2015 diff --git a/lib/ansible/plugins/action/__init__.py b/lib/ansible/plugins/action/__init__.py index 561763696d4..6e3cb6f3f84 100644 --- a/lib/ansible/plugins/action/__init__.py +++ b/lib/ansible/plugins/action/__init__.py @@ -441,6 +441,13 @@ class ActionBase: if 'stdout' in data and 'stdout_lines' not in data: data['stdout_lines'] = data.get('stdout', u'').splitlines() + # store the module invocation details back into the result + if self._task.async != 0: + data['invocation'] = dict( + module_args = module_args, + module_name = module_name, + ) + self._display.debug("done with _execute_module (%s, %s)" % (module_name, module_args)) return data diff --git a/lib/ansible/plugins/callback/log_plays.py b/lib/ansible/plugins/callback/log_plays.py index d8a834cadce..f816951fe7a 100644 --- a/lib/ansible/plugins/callback/log_plays.py +++ b/lib/ansible/plugins/callback/log_plays.py @@ -58,7 +58,10 @@ class CallbackModule(CallbackBase): data = 'omitted' else: data = data.copy() + invocation = data.pop('invocation', None) data = json.dumps(data) + if invocation is not None: + data = json.dumps(invocation) + " => %s " % data path = os.path.join("/var/log/ansible/hosts", host) now = time.strftime(self.TIME_FORMAT, time.localtime()) diff --git a/test/integration/roles/test_apt/tasks/apt.yml b/test/integration/roles/test_apt/tasks/apt.yml index 5d331b192da..c02a1bd4a09 100644 --- a/test/integration/roles/test_apt/tasks/apt.yml +++ b/test/integration/roles/test_apt/tasks/apt.yml @@ -63,6 +63,7 @@ - name: verify apt module outputs assert: that: + - "'invocation' in apt_result" - "'changed' in apt_result" - "'stderr' in apt_result" - "'stdout' in apt_result" diff --git a/test/integration/roles/test_yum/tasks/yum.yml b/test/integration/roles/test_yum/tasks/yum.yml index 95b4477739b..923717552b5 100644 --- a/test/integration/roles/test_yum/tasks/yum.yml +++ b/test/integration/roles/test_yum/tasks/yum.yml @@ -67,6 +67,7 @@ - name: verify yum module outputs assert: that: + - "'invocation' in yum_result" - "'changed' in yum_result" - "'msg' in yum_result" - "'rc' in yum_result"