From 37901bba41702b1398360cfc7798c8bcacd88f36 Mon Sep 17 00:00:00 2001 From: Jordan Borean Date: Fri, 6 Apr 2018 07:18:53 +1000 Subject: [PATCH] win_copy: added fix for win_copy deleting local tmp folder (#37978) --- CHANGELOG.md | 11 +++++++++++ lib/ansible/plugins/action/win_copy.py | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 36f587450c7..a34f2d90fc7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,17 @@ Ansible Changes By Release ========================== + + +## 2.4.5 "Dancing Days" - TBD + +### Bugfixes + +* Fix win_copy to preserve the global Ansible local tmp path instead of + deleting it when dealing with multiple files + (https://github.com/ansible/ansible/pull/37964) + + ## 2.4.4 "Dancing Days" - 2018-04-04 diff --git a/lib/ansible/plugins/action/win_copy.py b/lib/ansible/plugins/action/win_copy.py index ac0367df24b..d4619adf713 100644 --- a/lib/ansible/plugins/action/win_copy.py +++ b/lib/ansible/plugins/action/win_copy.py @@ -11,6 +11,7 @@ import base64 import json import os import os.path +import shutil import tempfile import traceback import zipfile @@ -320,11 +321,10 @@ class ActionModule(ActionBase): ) ) copy_args.pop('content', None) - os.remove(zip_path) - os.removedirs(os.path.dirname(zip_path)) module_return = self._execute_module(module_args=copy_args, task_vars=task_vars) self._remove_tmp_path(tmp_path) + shutil.rmtree(os.path.dirname(zip_path)) return module_return def run(self, tmp=None, task_vars=None):