[ansible-project] Re: selectattr with ansible

2015-07-05 Thread Igor Cicimov
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:

[ansible-project] Re: selectattr with ansible

2015-07-05 Thread Nico K.
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

[ansible-project] Re: selectattr with ansible

2015-07-05 Thread Vishal Chainani
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