-
Notifications
You must be signed in to change notification settings - Fork 23.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: variables go out of scope inside an included template #6653
Comments
Also similar to #4391. |
I also ran into this bug using Ansible 1.7.2. Seems it never got fixed as mentioned in #4391. |
I stand corrected, I was used to the old jinja issue. It seems we specifically disallow this in ansible's templating, I'm not sure why though. https://github.com/ansible/ansible/blob/devel/lib/ansible/utils/template.py#L201 |
Any workaround available? |
Closing This TicketHi! We believe the above commit should resolve this problem for you. This will also be included in the next major release. If you continue seeing any problems related to this issue, or if you have any further questions, please let us know by stopping by one of the two mailing lists, as appropriate:
Because this project is very active, we're unlikely to see comments made on closed tickets, but the mailing list is a great way to ask questions, or post if you don't think this particular issue is resolved. Thank you! |
…g other templates to 1.9 Fixes ansible#6653
Ability to add local variables into AnsibleJ2Vars was added in 18a9eff to fix ansible#6653. Local variables are added using ``AnsibleJ2Vars.add_locals()`` method when creating a new context - typically when including/importing a template with context. For that use case local template variables created using ``set`` should override variables from higher contexts - either from the play or any parent template, or both; Jinja behaves the same way. Also removes AnsibleJ2Vars.extras instance variable which is not used. Also adds missing test for ansible#6653. Fixes ansible#72262 Fixes ansible#72615 ci_complete
Ability to add local variables into AnsibleJ2Vars was added in 18a9eff to fix ansible#6653. Local variables are added using ``AnsibleJ2Vars.add_locals()`` method when creating a new context - typically when including/importing a template with context. For that use case local template variables created using ``set`` should override variables from higher contexts - either from the play or any parent template, or both; Jinja behaves the same way. Also removes AnsibleJ2Vars.extras instance variable which is not used. Also adds missing test for ansible#6653. Fixes ansible#72262 Fixes ansible#72615 ci_complete
Ability to add local variables into AnsibleJ2Vars was added in 18a9eff to fix #6653. Local variables are added using ``AnsibleJ2Vars.add_locals()`` method when creating a new context - typically when including/importing a template with context. For that use case local template variables created using ``set`` should override variables from higher contexts - either from the play or any parent template, or both; Jinja behaves the same way. Also removes AnsibleJ2Vars.extras instance variable which is not used. Also adds missing test for #6653. Fixes #72262 Fixes #72615 ci_complete
…2830) Ability to add local variables into AnsibleJ2Vars was added in 18a9eff to fix ansible#6653. Local variables are added using ``AnsibleJ2Vars.add_locals()`` method when creating a new context - typically when including/importing a template with context. For that use case local template variables created using ``set`` should override variables from higher contexts - either from the play or any parent template, or both; Jinja behaves the same way. Also removes AnsibleJ2Vars.extras instance variable which is not used. Also adds missing test for ansible#6653. Fixes ansible#72262 Fixes ansible#72615 ci_complete (cherry picked from commit a2af843)
…2830) Ability to add local variables into AnsibleJ2Vars was added in 18a9eff to fix ansible#6653. Local variables are added using ``AnsibleJ2Vars.add_locals()`` method when creating a new context - typically when including/importing a template with context. For that use case local template variables created using ``set`` should override variables from higher contexts - either from the play or any parent template, or both; Jinja behaves the same way. Also removes AnsibleJ2Vars.extras instance variable which is not used. Also adds missing test for ansible#6653. Fixes ansible#72262 Fixes ansible#72615 ci_complete (cherry picked from commit a2af843)
…73369) Ability to add local variables into AnsibleJ2Vars was added in 18a9eff to fix #6653. Local variables are added using ``AnsibleJ2Vars.add_locals()`` method when creating a new context - typically when including/importing a template with context. For that use case local template variables created using ``set`` should override variables from higher contexts - either from the play or any parent template, or both; Jinja behaves the same way. Also removes AnsibleJ2Vars.extras instance variable which is not used. Also adds missing test for #6653. Fixes #72262 Fixes #72615 ci_complete (cherry picked from commit a2af843)
…73370) Ability to add local variables into AnsibleJ2Vars was added in 18a9eff to fix #6653. Local variables are added using ``AnsibleJ2Vars.add_locals()`` method when creating a new context - typically when including/importing a template with context. For that use case local template variables created using ``set`` should override variables from higher contexts - either from the play or any parent template, or both; Jinja behaves the same way. Also removes AnsibleJ2Vars.extras instance variable which is not used. Also adds missing test for #6653. Fixes #72262 Fixes #72615 ci_complete (cherry picked from commit a2af843)
Issue Type:
Bug Report
Ansible Version:
ansible 1.5
Environment:
debian 7
Summary:
Variables go out of scope inside an included template
Steps To Reproduce:
hosts.yml:
test.j2:
test-inc.j2:
Expected Results:
I expect x in test-inc.j2 to be properly dereferenced
Actual Results:
fatal: [myhost] => {'msg': "One or more undefined variables: 'x' is undefined", 'failed': True}
fatal: [myhost] => {'msg': "One or more undefined variables: 'x' is undefined", 'failed': True}
The text was updated successfully, but these errors were encountered: