summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorStephen Fromm <sfromm@gmail.com>2013-12-20 14:46:44 -0800
committerStephen Fromm <sfromm@gmail.com>2013-12-20 14:58:34 -0800
commit833e1f6e2aa1f38f611e2423aa5979aaed7ade8b (patch)
treee9c4b897f47e2864bd57d55b730eef8143a58220 /lib
parent0d4294da423d7d370f60d98c64ce336673e1b525 (diff)
downloadansible-833e1f6e2aa1f38f611e2423aa5979aaed7ade8b.tar.gz
Make sure action plugin copy cleans up tmp dir
The copy action plugin creates its own tmp dir for each file that it copies to the target machine. However, it does not clean up the original tmp path it was given when run() is called. This cleans up the tmp path before it begins looping on source files.
Diffstat (limited to 'lib')
-rw-r--r--lib/ansible/runner/action_plugins/copy.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/ansible/runner/action_plugins/copy.py b/lib/ansible/runner/action_plugins/copy.py
index e65cab4426..7364de9b10 100644
--- a/lib/ansible/runner/action_plugins/copy.py
+++ b/lib/ansible/runner/action_plugins/copy.py
@@ -125,6 +125,9 @@ class ActionModule(object):
changed = False
diffs = []
module_result = {"changed": False}
+ # Remove tmp path since a new one is created below. Should be empty.
+ if tmp.find("tmp") != -1:
+ self.runner._low_level_exec_command(conn, "rm -rf %s > /dev/null 2>&1" % tmp, tmp)
for source_full, source_rel in source_files:
# We need to get a new tmp path for each file, otherwise the copy module deletes the folder.
tmp = self.runner._make_tmp_path(conn)