In your example, the loop variable is named identical to your list variable.

Try doing:

{% for interface in interfaces if interface.name == "lo0" %} 
{{ interface.unit0.ip_primary }}
{% endfor %}

On Sunday, July 5, 2015 at 4:03:08 PM UTC+2, Vishal Chainani wrote:
>
> Hmmm....
>
> so if have to select the list based on the value one of its key, is it 
> possible?
>
> I am trying something like this:
>
>
>
> *{% for interfaces in interfaces if interfaces.name 
> <http://interfaces.name> == "lo0" %}{{ interfaces.unit0.ip_primary }}{% 
> endfor %}*
>
> But throws an error {'msg': "AnsibleUndefinedVariable: One or more 
> undefined variables: 'list object' has no attribute 'lo0'", 'failed': True}
>
> Any ideas?
>
> Vishal
>
> On Sunday, July 5, 2015 at 1:47:19 PM UTC+5:30, Igor Cicimov wrote:
>>
>> I think the 'equalto' test is only available in the 2.8+ version of jinja2
>
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/712d82f3-6306-4471-8049-e20aa9cb1d84%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to