From 68f7ea60994ee00ae82266547381ce27886f0234 Mon Sep 17 00:00:00 2001 From: Gilles Cornu Date: Sat, 4 May 2013 19:31:52 -0400 Subject: [PATCH] Apply Gilles's patch to atomic_move based on github comment. (Email address not supplied since wasn't from a pull request) --- lib/ansible/module_common.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/ansible/module_common.py b/lib/ansible/module_common.py index cbfb24af45d..090dc941ba8 100644 --- a/lib/ansible/module_common.py +++ b/lib/ansible/module_common.py @@ -812,9 +812,9 @@ class AnsibleModule(object): rc = False context = None if os.path.exists(dest): - st = os.stat(dest) - os.chmod(src, st.st_mode & 07777) try: + st = os.stat(dest) + os.chmod(src, st.st_mode & 07777) os.chown(src, st.st_uid, st.st_gid) except OSError, e: if e.errno != errno.EPERM: @@ -838,6 +838,7 @@ class AnsibleModule(object): try: # leaves tmp file behind when sudo and not root if os.getenv("SUDO_USER") and os.getuid() != 0: + # cleanup will happen by 'rm' of tempdir shutil.copy(src, tmp_dest) else: shutil.move(src, tmp_dest)