Added prefix to tempfile for template

__clean_tmp() only cleans files that have salt.utils.files.TEMPFILE_PREFIX as a prefix, which the jinja rendering didn't set. This causes the /tmp directory to fill up more with each salt run.
This commit is contained in:
Yoram Hekma 2016-11-08 10:48:26 +01:00
parent 96b8b9a849
commit 93a59f8034

View file

@ -189,7 +189,7 @@ def wrap_tmpl_func(render_str):
else:
if to_str: # then render as string
return dict(result=True, data=output)
with tempfile.NamedTemporaryFile('wb', delete=False) as outf:
with tempfile.NamedTemporaryFile('wb', delete=False, prefix=salt.utils.files.TEMPFILE_PREFIX) as outf:
outf.write(SLS_ENCODER(output)[0])
# Note: If nothing is replaced or added by the rendering
# function, then the contents of the output file will