diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bbca268e1..bf59ac3c87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ Ansible Changes By Release * service module works better on Ubuntu * git module now does resets and such to work more smoothly on updates * fix to internals of hacking/test-module development script +* ansible-pull script and example playbook (extreme scaling, remediation) 0.3 "Baluchitherium" -- April 23, 2012 diff --git a/lib/ansible/playbook.py b/lib/ansible/playbook.py index 9f15784f1f..d6e7225148 100644 --- a/lib/ansible/playbook.py +++ b/lib/ansible/playbook.py @@ -165,7 +165,7 @@ class PlayBook(object): include_vars[k] = v inject_vars = play_vars.copy() inject_vars.update(include_vars) - included = utils.template_from_file(path, inject_vars, SETUP_CACHE) + included = utils.template_from_file(path, inject_vars, SETUP_CACHE, no_engine=True) included = utils.parse_yaml(included) for x in included: if len(include_vars): diff --git a/lib/ansible/utils.py b/lib/ansible/utils.py index a44f62d0e7..92c321ce46 100644 --- a/lib/ansible/utils.py +++ b/lib/ansible/utils.py @@ -230,21 +230,26 @@ def varReplace(raw, vars): return ''.join(done) -def template(text, vars, setup_cache): +def template(text, vars, setup_cache, no_engine=False): ''' run a text buffer through the templating engine ''' vars = vars.copy() text = varReplace(str(text), vars) vars['hostvars'] = setup_cache - template = jinja2.Template(text) - return template.render(vars) + if no_engine: + # used when processing include: directives so that Jinja is evaluated + # in a later context when more variables are available + return text + else: + template = jinja2.Template(text) + return template.render(vars) def double_template(text, vars, setup_cache): return template(template(text, vars, setup_cache), vars, setup_cache) -def template_from_file(path, vars, setup_cache): +def template_from_file(path, vars, setup_cache, no_engine=False): ''' run a file through the templating engine ''' data = file(path).read() - return template(data, vars, setup_cache) + return template(data, vars, setup_cache, no_engine=no_engine) def parse_yaml(data): return yaml.load(data)