mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 19:31:26 -07:00
Fix some subtle things that were keeping 'hostvars' from being usable in templates.
This commit is contained in:
parent
2b6d8a8be5
commit
2d06ee4c0d
2 changed files with 14 additions and 13 deletions
|
@ -211,9 +211,7 @@ def template_from_file(basedir, path, vars):
|
|||
environment = jinja2.Environment(loader=jinja2.FileSystemLoader(basedir), trim_blocks=False)
|
||||
data = codecs.open(path_dwim(basedir, path), encoding="utf8").read()
|
||||
t = environment.from_string(data)
|
||||
# FIXME: possibly a bit inefficient here, do this in runner code
|
||||
vars = vars.copy()
|
||||
vars['hostvars'] = vars.get('setup_cache',{})
|
||||
res = t.render(vars)
|
||||
if data.endswith('\n') and not res.endswith('\n'):
|
||||
res = res + '\n'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue