|
|
|
|
@ -181,7 +181,7 @@ def assemble_from_fragments(src_path, delimiter=None, compiled_regexp=None, igno
|
|
|
|
|
return temp_path
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def cleanup(path, result=None):
|
|
|
|
|
def cleanup(module, path, result=None):
|
|
|
|
|
# cleanup just in case
|
|
|
|
|
if os.path.exists(path):
|
|
|
|
|
try:
|
|
|
|
|
@ -189,7 +189,7 @@ def cleanup(path, result=None):
|
|
|
|
|
except (IOError, OSError) as e:
|
|
|
|
|
# don't error on possible race conditions, but keep warning
|
|
|
|
|
if result is not None:
|
|
|
|
|
result['warnings'] = ['Unable to remove temp file (%s): %s' % (path, to_native(e))]
|
|
|
|
|
module.warn('Unable to remove temp file (%s): %s' % (path, to_native(e)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
|
@ -261,7 +261,7 @@ def main():
|
|
|
|
|
(rc, out, err) = module.run_command(validate % path)
|
|
|
|
|
result['validation'] = dict(rc=rc, stdout=out, stderr=err)
|
|
|
|
|
if rc != 0:
|
|
|
|
|
cleanup(path)
|
|
|
|
|
cleanup(module, path)
|
|
|
|
|
module.fail_json(msg="failed to validate: rc:%s error:%s" % (rc, err))
|
|
|
|
|
if backup and dest_hash is not None:
|
|
|
|
|
result['backup_file'] = module.backup_local(dest)
|
|
|
|
|
@ -269,7 +269,7 @@ def main():
|
|
|
|
|
module.atomic_move(path, dest, unsafe_writes=module.params['unsafe_writes'])
|
|
|
|
|
changed = True
|
|
|
|
|
|
|
|
|
|
cleanup(path, result)
|
|
|
|
|
cleanup(module, path, result)
|
|
|
|
|
|
|
|
|
|
# handle file permissions
|
|
|
|
|
file_args = module.load_file_common_arguments(module.params)
|
|
|
|
|
|