Fix traceback in atomic_move (#18649)
Commit8b08a28c89
removed a call to get_exception() that was needed. Without it, the fail_json references an undefined variable ('exception') and throws an exception. Add the get_exception() back in where needed and update references. Now the proper module failure is returned. Fixes #18628 (cherry picked from commitdbbd2d79ff
)
This commit is contained in:
parent
b878e8f0f0
commit
288f6684cf
1 changed files with 5 additions and 3 deletions
|
@ -1995,12 +1995,14 @@ class AnsibleModule(object):
|
|||
try:
|
||||
os.rename(b_tmp_dest_name, b_dest)
|
||||
except (shutil.Error, OSError, IOError):
|
||||
e = get_exception()
|
||||
if unsafe_writes:
|
||||
self._unsafe_writes(b_tmp_dest_name, b_dest, get_exception())
|
||||
self._unsafe_writes(b_tmp_dest_name, b_dest, e)
|
||||
else:
|
||||
self.fail_json(msg='Could not replace file: %s to %s: %s' % (src, dest, exception))
|
||||
self.fail_json(msg='Could not replace file: %s to %s: %s' % (src, dest, e))
|
||||
except (shutil.Error, OSError, IOError):
|
||||
self.fail_json(msg='Could not replace file: %s to %s: %s' % (src, dest, exception))
|
||||
e = get_exception()
|
||||
self.fail_json(msg='Could not replace file: %s to %s: %s' % (src, dest, e))
|
||||
finally:
|
||||
self.cleanup(b_tmp_dest_name)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue