mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-23 19:01:26 -07:00
Fix traceback in atomic_move (#18649)
Commit 8b08a28c89
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
This commit is contained in:
parent
6169d2d49f
commit
dbbd2d79ff
1 changed files with 5 additions and 3 deletions
|
@ -2086,12 +2086,14 @@ class AnsibleModule(object):
|
||||||
try:
|
try:
|
||||||
os.rename(b_tmp_dest_name, b_dest)
|
os.rename(b_tmp_dest_name, b_dest)
|
||||||
except (shutil.Error, OSError, IOError):
|
except (shutil.Error, OSError, IOError):
|
||||||
|
e = get_exception()
|
||||||
if unsafe_writes:
|
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:
|
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):
|
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:
|
finally:
|
||||||
self.cleanup(b_tmp_dest_name)
|
self.cleanup(b_tmp_dest_name)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue