Ensure action plugins remove tmp dirs created (#15501)

fixes #14917
This commit is contained in:
Brian Coca 2016-04-20 13:39:12 -04:00
parent 67e6bd18e4
commit a5d79a39d5
8 changed files with 29 additions and 18 deletions

View file

@ -97,16 +97,14 @@ class ActionModule(ActionBase):
result['msg'] = "src and dest are required"
return result
cleanup_remote_tmp = False
remote_user = task_vars.get('ansible_ssh_user') or self._play_context.remote_user
if not tmp:
tmp = self._make_tmp_path(remote_user)
cleanup_remote_tmp = True
self._cleanup_remote_tmp = True
if boolean(remote_src):
result.update(self._execute_module(tmp=tmp, task_vars=task_vars, delete_remote_tmp=False))
if cleanup_remote_tmp:
self._remove_tmp_path(tmp)
self._remove_tmp_path(tmp)
return result
elif self._task._role is not None:
src = self._loader.path_dwim_relative(self._task._role._role_path, 'files', src)
@ -166,7 +164,6 @@ class ActionModule(ActionBase):
else:
result.update(self._execute_module(module_name='file', module_args=new_module_args, task_vars=task_vars, tmp=tmp, delete_remote_tmp=False))
if tmp and cleanup_remote_tmp:
self._remove_tmp_path(tmp)
self._remove_tmp_path(tmp)
return result