This works for me:
---
- hosts: localhost
connection: local
gather_facts: false
vars:
interfaces:
- name: lo0
unit0:
ip_primary: 1.1.1.1
ip_secondary: 2.2.2.2
unit1:
ip_primary: 3.3.3.3
ip_secondary: 4.4.4.4
- name: xyz
unit0:
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 s
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 == "lo0" %}{{
interfaces.unit0.ip_primary }}{% endfor %}*
But throws an error {'msg': "AnsibleUndefinedVariable: One