Maybe it obvious but it is just to tell you that the variable exist. We use
the vars[] like this:
myvars.yml:
prefix_main_postfix: some_value
master yml:
---
- hosts: "{{ hosts }}"
vars:
os: "linux"
vars_files:
- ~/myvars.yml
task:
- template: src=mytemplate.j2 ...
with_items:
- { env: 'main' }
- { env: 'staging' }
mytemplate.j2:
{{ vars['prefix_' + item.env + '_postfix' ] | get_something }}
error:
fatal: [127.0.0.1 -> 127.0.0.1] => {'msg': "AnsibleUndefinedVariable: One
or more undefined variables: 'dict object' has no attribute
'prefix_main_postfix'", 'failed': True}
Den søndag den 22. februar 2015 kl. 19.38.36 UTC+1 skrev Serge van
Ginderachter:
>
>
> On 22 February 2015 at 19:30, Khuong Dinh Pham <[email protected]
> <javascript:>> wrote:
>
>> {{ vars['prefix_' + item.env + '_postfix' ] | get_something }}
>>
>> This is not working anymore in v1.8.4 If I switch back to v.1.7.2 it's
>> working fine.
>>
>> However if I type
>>
>> {{ prefix_main_postfix | get_something }} in v.1.8.4 it's working fine
>>
>
>
> Your latter example strike me as being obvious.
> Is the vars[]dict meant to be something special?
>
>
>
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/25a720dc-5337-4672-a38d-c07d3b954608%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.