diff options
Diffstat (limited to 'lib/action_plugins/fetch_cmd.py')
-rw-r--r-- | lib/action_plugins/fetch_cmd.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/action_plugins/fetch_cmd.py b/lib/action_plugins/fetch_cmd.py index 99bdf2e..b460868 100644 --- a/lib/action_plugins/fetch_cmd.py +++ b/lib/action_plugins/fetch_cmd.py @@ -25,37 +25,38 @@ class ActionModule(ActionBase): def run(self, tmp=None, task_vars=None): if task_vars is None: task_vars = dict() if self._play_context.check_mode: return dict(skipped=True, msg='check mode not supported for this module') result = super(ActionModule, self).run(tmp, task_vars) cmd = self._task.args.get('cmd', None) stdin = self._task.args.get('stdin', None) dest = self._task.args.get('dest', None) if cmd is None or dest is None: return dict(failed=True, msg="cmd and dest are required") if stdin is not None: stdin = self._connection._shell.join_path(stdin) stdin = self._remote_expand_user(stdin) - stdout = self._connection._shell.join_path(self._make_tmp_path(), 'stdout') + remote_user = task_vars.get('ansible_ssh_user') or self._play_context.remote_user + stdout = self._connection._shell.join_path(self._make_tmp_path(remote_user), 'stdout') result.update(self._execute_module(module_args=dict(cmd=cmd, stdin=stdin, dest=stdout), task_vars=task_vars)) # calculate checksum for the local file local_checksum = checksum(dest) # calculate checksum for the remote file, don't bother if using become as slurp will be used remote_checksum = self._remote_checksum(stdout, all_vars=task_vars) if remote_checksum != local_checksum: makedirs_safe(os.path.dirname(dest)) self._connection.fetch_file(stdout, dest) if checksum(dest) == remote_checksum: result.update(dict(changed=True)) else: result.update(dict(failed=True)) return result |