>
> Awesome! Thanks so much, that worked for me, but I had to tweak it just a
> little bit. I tried using 'eq' as the filter and it threw an error, but
> 'equalto' didn't give it any problems. Otherwise this was exactly what I
> needed!
On Thursday, December 20, 2018 at 8:37:13 AM UTC-5, Kai Stian Olstad wrote:
>
> On Wednesday, 19 December 2018 21:44:26 CET Eric Brewer wrote:
> > So having a dictionary in a var file, how would I find a value, if I
> don't
> > know the list position, but I do know a value of another key:value pair?
> >
> >
> > physical_interface_list:
> > - lan: 1
> > slave: no
> > route_list:
> > - ip4: 1.1.1.1
> > subnet4: 2.2.2.2
> > gateway4: 3.3.3.3
> > present: yes
> > ip4: 4.4.4.4
> > dev_name: eth1
> >
> >
> >
> > So if know that my variable lives somewhere in
> >
> > physical_interface_list[?]['ip4']
> >
> > And I know that the dev_name is eth1, how would I go about finding ip4
> at
> > the correct array position (assuming there are more than the one I am
> > showing)? The variable file I am pulling from is enormous, and I have
> > committed the 6 levels above it for brevity's sake.
> >
> > I have tried using map, but I must not understand how to use it
> correctly,
> > and the documentation I have been reading doesn't really tell me if it
> can
> > be used that way.....
>
> {{ (physical_interface_list | selectattr('dev_name', 'eq', 'eth1') |
> list).0.ip4 }}
>
>
> --
> Kai Stian Olstad
>
>
>
--
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/f272099d-eafd-47d3-a0c5-30ab524bdf6a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.