-
-
Save sgargan/04817339585b14da96c2 to your computer and use it in GitHub Desktop.
template resolution with includes issue
This file contains hidden or 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
cluster_name: dev | |
another: foo | |
testing: {} | |
This file contains hidden or 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
[localhost] | |
127.0.0.1 |
This file contains hidden or 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
# this is ok | |
- debug: var=cluster_name | |
# this should be "foo-extra" but is "foo-dev" | |
- debug: var=testing |
This file contains hidden or 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
- hosts: all | |
connection: local | |
tasks: | |
- name: variable is the one from extras here | |
debug: msg='{{cluster_name}}' | |
# used in an include it should use the 'cluster_name' passed in to make foo-extra | |
- {include: some_include.yml, testing: '{{another}}-{{cluster_name}}'} | |
# used in an include it should use the 'cluster_name' passed in to make foo-extra | |
- {include: some_include.yml, testing: { | |
somenested: '{{another}}-{{cluster_name}}' | |
}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if i call playbook with an extra variable to override the cluster name
ansible-playbook -i hosts var_precedence.yml -e cluster_name=extra
then I'd expect that 'testing' variable in the include file would be 'foo-extra' but because the templates are resolved early it ends up being 'foo-dev'