From 8217e0706fe748e932a06d982834c96f50ea0cbc Mon Sep 17 00:00:00 2001 From: Kavin Kankeshwar Date: Wed, 29 May 2013 00:03:12 -0700 Subject: [PATCH] Avoid crash in module_common when the file cannot be moved/copy --- lib/ansible/module_common.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ansible/module_common.py b/lib/ansible/module_common.py index 8565f16d203..a8083100ea0 100644 --- a/lib/ansible/module_common.py +++ b/lib/ansible/module_common.py @@ -815,7 +815,7 @@ class AnsibleModule(object): self.fail_json(msg='Could not make backup of %s to %s: %s' % (fn, backupdest, e)) return backupdest - def cleanup(tmpfile): + def cleanup(self,tmpfile): if os.path.exists(tmpfile): try: os.unlink(tmpfile) @@ -856,7 +856,7 @@ class AnsibleModule(object): # rename might not preserve context self.set_context_if_different(dest, context, False) except (shutil.Error, OSError, IOError), e: - cleanup(tmp_dest) + self.cleanup(tmp_dest) self.fail_json(msg='Could not replace file: %s to %s: %s' % (src, dest, e)) def run_command(self, args, check_rc=False, close_fds=False, executable=None, data=None):