Skip to content

Instantly share code, notes, and snippets.

@sgargan
Last active August 29, 2015 14:14
Show Gist options
  • Save sgargan/04817339585b14da96c2 to your computer and use it in GitHub Desktop.
Save sgargan/04817339585b14da96c2 to your computer and use it in GitHub Desktop.
template resolution with includes issue
cluster_name: dev
another: foo
testing: {}
[localhost]
127.0.0.1
# this is ok
- debug: var=cluster_name
# this should be "foo-extra" but is "foo-dev"
- debug: var=testing
- 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}}'
}}
@sgargan
Copy link
Author

sgargan commented Feb 3, 2015

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'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment