1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Make template action respect local_tmp. Fixes #34941 (#35005)

This commit is contained in:
Matt Martz 2018-01-17 14:14:46 -06:00 committed by GitHub
parent 8edd1cf182
commit b20df1be02
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -21,6 +21,7 @@ import os
import shutil import shutil
import tempfile import tempfile
from ansible import constants as C
from ansible.errors import AnsibleError, AnsibleFileNotFound, AnsibleAction, AnsibleActionFail from ansible.errors import AnsibleError, AnsibleFileNotFound, AnsibleAction, AnsibleActionFail
from ansible.module_utils._text import to_bytes, to_text from ansible.module_utils._text import to_bytes, to_text
from ansible.module_utils.parsing.convert_bool import boolean 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('variable_end_string', None)
new_task.args.pop('trim_blocks', None) new_task.args.pop('trim_blocks', None)
try: try:
tempdir = tempfile.mkdtemp() tempdir = tempfile.mkdtemp(dir=C.DEFAULT_LOCAL_TMP)
result_file = os.path.join(tempdir, os.path.basename(source)) result_file = os.path.join(tempdir, os.path.basename(source))
with open(result_file, 'wb') as f: with open(result_file, 'wb') as f:
f.write(to_bytes(resultant, errors='surrogate_or_strict')) f.write(to_bytes(resultant, errors='surrogate_or_strict'))