|
|
@ -315,12 +315,16 @@ def write_file(module, dest, content):
|
|
|
|
has changed.
|
|
|
|
has changed.
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
changed = False
|
|
|
|
changed = False
|
|
|
|
# create a tempfile with some test content
|
|
|
|
# create a tempfile
|
|
|
|
_, tmpsrc = tempfile.mkstemp()
|
|
|
|
fd, tmpsrc = tempfile.mkstemp(text=False)
|
|
|
|
f = open(tmpsrc, 'wb')
|
|
|
|
f = os.fdopen(fd, 'wb')
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
f.write(content)
|
|
|
|
f.write(content)
|
|
|
|
except Exception as err:
|
|
|
|
except Exception as err:
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
f.close()
|
|
|
|
|
|
|
|
except:
|
|
|
|
|
|
|
|
pass
|
|
|
|
os.remove(tmpsrc)
|
|
|
|
os.remove(tmpsrc)
|
|
|
|
module.fail_json(msg="failed to create temporary content file: %s" % to_native(err), exception=traceback.format_exc())
|
|
|
|
module.fail_json(msg="failed to create temporary content file: %s" % to_native(err), exception=traceback.format_exc())
|
|
|
|
f.close()
|
|
|
|
f.close()
|
|
|
|