Temporarily revert c119d54

There were bugs in this that needed to be resolved.  No time to get the
fix reviewed sufficiently for 2.6.0.

We'll get this into 2.7.0 and try to get this into 2.6.1 as well.

Will need the work done in https://github.com/ansible/ansible/pull/36218
when it does get merged.
This commit is contained in:
Toshio Kuratomi 2018-06-15 11:36:07 -07:00 committed by Matt Clay
parent 6fa2d9ac6f
commit 5c614a59a6
6 changed files with 13 additions and 13 deletions

View file

@ -49,8 +49,7 @@ options:
tmp_dest:
description:
- Absolute path of where temporary file is downloaded to.
- When run on Ansible 2.5 or greater, path defaults to ansible's remote_tmp setting
- When run on Ansible prior to 2.5, it defaults to C(TMPDIR), C(TEMP) or C(TMP) env variables or a platform specific value.
- Defaults to C(TMPDIR), C(TEMP) or C(TMP) env variables or a platform specific value.
- U(https://docs.python.org/2/library/tempfile.html#tempfile.tempdir)
version_added: '2.1'
force:
@ -341,17 +340,18 @@ def url_get(module, url, dest, use_proxy, last_mod_time, force, timeout=10, head
module.fail_json(msg="%s is a file but should be a directory." % tmp_dest)
else:
module.fail_json(msg="%s directory does not exist." % tmp_dest)
else:
tmp_dest = getattr(module, 'tmpdir', None)
fd, tempname = tempfile.mkstemp(dir=tmp_dest)
fd, tempname = tempfile.mkstemp(dir=tmp_dest)
else:
fd, tempname = tempfile.mkstemp()
f = os.fdopen(fd, 'wb')
try:
shutil.copyfileobj(rsp, f)
except Exception as e:
os.remove(tempname)
module.fail_json(msg="failed to create temporary content file: %s" % to_native(e), exception=traceback.format_exc())
module.fail_json(msg="failed to create temporary content file: %s" % to_native(e),
exception=traceback.format_exc())
f.close()
rsp.close()
return tempname, info