Last active
October 6, 2018 00:41
-
-
Save dlethin/4328c9f58e8b4f5fc180f487907dfff0 to your computer and use it in GitHub Desktop.
Weird behavior with ansible jinja2 evaluating a variable it shouldn't need and failing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; start | |
{% if False %} | |
; not rendered | |
{{ outer }} | |
{% endif %} | |
; end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: "test me" | |
hosts: localhost | |
become: no | |
gather_facts: no | |
vars: | |
outer: "{{ inner }}" | |
test_case: "working" | |
tasks: | |
- name: "duh" | |
template: | |
src: "{{playbook_dir}}/{{test_case}}.txt.j2" | |
dest: "{{playbook_dir}}/{{test_case}}.txt" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; start | |
{% if False %} | |
; not rendered | |
{{ inner }} | |
{% endif %} | |
; end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why does test_case
working
work and butfailing
does not. In the working test case the template has a reference toinner
which does not exist but it does not fail. However in the failing test case,outer
is defined, but it has a reference toinner
.Weird.