1
0
Fork 0
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:
Brian Coca 2012-11-14 02:20:39 -05:00 committed by Brian Coca
parent 0c70abfaa9
commit 68f5d69365

View file

@ -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: