From 8c6b5621f87c9ef28b44dbd7b09cf8051fe75377 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Wed, 11 Jan 2017 20:32:44 -0500 Subject: [PATCH] deal with remote_src and tmp dirs properly fixes #20128 --- lib/ansible/plugins/action/assemble.py | 11 +++++------ lib/ansible/plugins/action/copy.py | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/ansible/plugins/action/assemble.py b/lib/ansible/plugins/action/assemble.py index 3a3f0fc29f..51ceea5110 100644 --- a/lib/ansible/plugins/action/assemble.py +++ b/lib/ansible/plugins/action/assemble.py @@ -103,13 +103,8 @@ class ActionModule(ActionBase): return result remote_user = task_vars.get('ansible_ssh_user') or self._play_context.remote_user - if not tmp: - tmp = self._make_tmp_path(remote_user) - self._cleanup_remote_tmp = True - if boolean(remote_src): - result.update(self._execute_module(tmp=tmp, task_vars=task_vars, delete_remote_tmp=False)) - self._remove_tmp_path(tmp) + result.update(self._execute_module(tmp=tmp, task_vars=task_vars)) return result else: try: @@ -119,6 +114,10 @@ class ActionModule(ActionBase): result['msg'] = to_native(e) return result + if not tmp: + tmp = self._make_tmp_path(remote_user) + self._cleanup_remote_tmp = True + if not os.path.isdir(src): result['failed'] = True result['msg'] = u"Source (%s) is not a directory" % src diff --git a/lib/ansible/plugins/action/copy.py b/lib/ansible/plugins/action/copy.py index fe300b23e4..7f79952c90 100644 --- a/lib/ansible/plugins/action/copy.py +++ b/lib/ansible/plugins/action/copy.py @@ -87,7 +87,7 @@ class ActionModule(ActionBase): # if we have first_available_file in our vars # look up the files and use the first one we find as src elif remote_src: - result.update(self._execute_module(module_name='copy', module_args=self._task.args, task_vars=task_vars, delete_remote_tmp=False)) + result.update(self._execute_module(module_name='copy', module_args=self._task.args, task_vars=task_vars)) return result else: # find in expected paths try: