From b20df1be02765db46edef887d51d0896bbec2570 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Wed, 17 Jan 2018 14:14:46 -0600 Subject: [PATCH] Make template action respect local_tmp. Fixes #34941 (#35005) --- lib/ansible/plugins/action/template.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/ansible/plugins/action/template.py b/lib/ansible/plugins/action/template.py index fcbe0eae0b..2be1a61cee 100644 --- a/lib/ansible/plugins/action/template.py +++ b/lib/ansible/plugins/action/template.py @@ -21,6 +21,7 @@ import os import shutil import tempfile +from ansible import constants as C from ansible.errors import AnsibleError, AnsibleFileNotFound, AnsibleAction, AnsibleActionFail from ansible.module_utils._text import to_bytes, to_text from ansible.module_utils.parsing.convert_bool import boolean @@ -132,7 +133,7 @@ class ActionModule(ActionBase): new_task.args.pop('variable_end_string', None) new_task.args.pop('trim_blocks', None) try: - tempdir = tempfile.mkdtemp() + tempdir = tempfile.mkdtemp(dir=C.DEFAULT_LOCAL_TMP) result_file = os.path.join(tempdir, os.path.basename(source)) with open(result_file, 'wb') as f: f.write(to_bytes(resultant, errors='surrogate_or_strict'))