diff --git a/library/files/file b/library/files/file index e1bdf53375..a124511d8e 100644 --- a/library/files/file +++ b/library/files/file @@ -309,7 +309,8 @@ def main(): os.symlink(src, tmppath) os.rename(tmppath, path) except OSError, e: - os.unlink(tmppath) + if os.path.exists(tmppath): + os.unlink(tmppath) module.fail_json(path=path, msg='Error while replacing: %s' % str(e)) else: try: