summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToshio Kuratomi <a.badger@gmail.com>2018-06-15 11:36:07 -0700
committerMatt Clay <matt@mystile.com>2018-06-15 14:27:20 -0700
commit1a5ba963b67000b2e2c3f52858f852ab43e98162 (patch)
tree247f96bcaea5ce15f4cfe50909229e52275b619b
parentbf1cc2f1f4743929b7ef9f4f5c2ac169fbfbc108 (diff)
downloadansible-1a5ba963b67000b2e2c3f52858f852ab43e98162.tar.gz
[stable-2.6] 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. (cherry picked from commit 5c614a59a66fc75b6e258053d3d17d151141e7f9) Co-authored-by: Toshio Kuratomi <a.badger@gmail.com>
-rw-r--r--lib/ansible/modules/files/assemble.py6
-rw-r--r--lib/ansible/modules/files/blockinfile.py2
-rw-r--r--lib/ansible/modules/files/replace.py2
-rw-r--r--lib/ansible/modules/net_tools/basics/get_url.py12
-rw-r--r--lib/ansible/modules/net_tools/basics/uri.py2
-rw-r--r--lib/ansible/modules/packaging/os/yum.py2
6 files changed, 13 insertions, 13 deletions
diff --git a/lib/ansible/modules/files/assemble.py b/lib/ansible/modules/files/assemble.py
index 2d751b500f..4969675381 100644
--- a/lib/ansible/modules/files/assemble.py
+++ b/lib/ansible/modules/files/assemble.py
@@ -107,9 +107,9 @@ from ansible.module_utils.six import b
from ansible.module_utils._text import to_native
-def assemble_from_fragments(src_path, delimiter=None, compiled_regexp=None, ignore_hidden=False, tmpdir=None):
+def assemble_from_fragments(src_path, delimiter=None, compiled_regexp=None, ignore_hidden=False):
''' assemble a file from a directory of fragments '''
- tmpfd, temp_path = tempfile.mkstemp(dir=tmpdir)
+ tmpfd, temp_path = tempfile.mkstemp()
tmp = os.fdopen(tmpfd, 'wb')
delimit_me = False
add_newline = False
@@ -204,7 +204,7 @@ def main():
if validate and "%s" not in validate:
module.fail_json(msg="validate must contain %%s: %s" % validate)
- path = assemble_from_fragments(src, delimiter, compiled_regexp, ignore_hidden, getattr(module, 'tmpdir', None))
+ path = assemble_from_fragments(src, delimiter, compiled_regexp, ignore_hidden)
path_hash = module.sha1(path)
result['checksum'] = path_hash
diff --git a/lib/ansible/modules/files/blockinfile.py b/lib/ansible/modules/files/blockinfile.py
index 4022a8df49..27dfa2ef2b 100644
--- a/lib/ansible/modules/files/blockinfile.py
+++ b/lib/ansible/modules/files/blockinfile.py
@@ -160,7 +160,7 @@ from ansible.module_utils._text import to_bytes
def write_changes(module, contents, path):
- tmpfd, tmpfile = tempfile.mkstemp(dir=getattr(module, 'tmpdir', None))
+ tmpfd, tmpfile = tempfile.mkstemp()
f = os.fdopen(tmpfd, 'wb')
f.write(contents)
f.close()
diff --git a/lib/ansible/modules/files/replace.py b/lib/ansible/modules/files/replace.py
index c5f6026a3f..1a652b6b45 100644
--- a/lib/ansible/modules/files/replace.py
+++ b/lib/ansible/modules/files/replace.py
@@ -154,7 +154,7 @@ from ansible.module_utils.basic import AnsibleModule
def write_changes(module, contents, path):
- tmpfd, tmpfile = tempfile.mkstemp(dir=getattr(module, 'tmpdir', None))
+ tmpfd, tmpfile = tempfile.mkstemp()
f = os.fdopen(tmpfd, 'wb')
f.write(contents)
f.close()
diff --git a/lib/ansible/modules/net_tools/basics/get_url.py b/lib/ansible/modules/net_tools/basics/get_url.py
index 4ead3f11eb..89c69994ed 100644
--- a/lib/ansible/modules/net_tools/basics/get_url.py
+++ b/lib/ansible/modules/net_tools/basics/get_url.py
@@ -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
diff --git a/lib/ansible/modules/net_tools/basics/uri.py b/lib/ansible/modules/net_tools/basics/uri.py
index e7ccdefaf5..a7d8760757 100644
--- a/lib/ansible/modules/net_tools/basics/uri.py
+++ b/lib/ansible/modules/net_tools/basics/uri.py
@@ -252,7 +252,7 @@ JSON_CANDIDATES = ('text', 'json', 'javascript')
def write_file(module, url, dest, content):
# create a tempfile with some test content
- fd, tmpsrc = tempfile.mkstemp(dir=getattr(module, 'tmpdir', None))
+ fd, tmpsrc = tempfile.mkstemp()
f = open(tmpsrc, 'wb')
try:
f.write(content)
diff --git a/lib/ansible/modules/packaging/os/yum.py b/lib/ansible/modules/packaging/os/yum.py
index c5a6173b1e..e0577ee8fa 100644
--- a/lib/ansible/modules/packaging/os/yum.py
+++ b/lib/ansible/modules/packaging/os/yum.py
@@ -333,7 +333,7 @@ def ensure_yum_utils(module):
def fetch_rpm_from_url(spec, module=None):
# download package so that we can query it
package_name, _ = os.path.splitext(str(spec.rsplit('/', 1)[1]))
- package_file = tempfile.NamedTemporaryFile(dir=getattr(module, 'tmpdir', None), prefix=package_name, suffix='.rpm', delete=False)
+ package_file = tempfile.NamedTemporaryFile(prefix=package_name, suffix='.rpm', delete=False)
module.add_cleanup_file(package_file.name)
try:
rsp, info = fetch_url(module, spec)