From 6b6d03290a783690624ebad60d03322421af7827 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Thu, 22 Oct 2015 08:25:20 -0700 Subject: [PATCH] Restore the automatic addition of invocation to the output Revert "Remove auto-added invocation return value as it is not used by v2 and could leak sensitive data." This reverts commit 6ce6b202684e35313deea54f89bbb8e40e48cc79. Remove the note that invocation was removed as we've now restored it. Revert "keyword not in ubuntu 14.04" This reverts commit 5c016224570fc9d68f9e3d02ed8b0d4999d20457. Revert "remove invocation keyword check" This reverts commit 5177cb3f746caa104bf8e29e3469b5682d466534. --- CHANGELOG.md | 1 - lib/ansible/plugins/action/__init__.py | 7 +++++++ lib/ansible/plugins/callback/log_plays.py | 3 +++ test/integration/roles/test_apt/tasks/apt.yml | 1 + test/integration/roles/test_yum/tasks/yum.yml | 1 + 5 files changed, 12 insertions(+), 1 deletion(-) 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"