mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
added ability to override jinja enviornment from first line of template Signed-off-by: Brian Coca <briancoca+ansible@gmail.com>
Signed-off-by: Brian Coca <briancoca+dev@gmail.com>
This commit is contained in:
parent
0c70abfaa9
commit
68f5d69365
1 changed files with 10 additions and 0 deletions
|
@ -275,6 +275,16 @@ def template_from_file(basedir, path, vars):
|
|||
raise errors.AnsibleError("unable to process as utf-8: %s" % realpath)
|
||||
except:
|
||||
raise errors.AnsibleError("unable to read %s" % realpath)
|
||||
|
||||
# Get jinja env overrides from template
|
||||
if data.startswith('#env:'):
|
||||
eol = data.find('\n')
|
||||
line = data[5:eol]
|
||||
data = data[eol+1:]
|
||||
for pair in line.split(','):
|
||||
(key,val) = pair.split(':')
|
||||
setattr(environment,key.strip(),val.strip())
|
||||
|
||||
t = environment.from_string(data)
|
||||
vars = vars.copy()
|
||||
try:
|
||||
|
|
Loading…
Reference in a new issue