In the dictionary MyDict, the second dictionary in the nested list has the name key set to an integer value (101). Hence, the lookup in the debug statement is returning false. Is there a way to make the lookup convert the values in the list to strings, so that true will be returned in this example? Thanks!
---
- hosts: localhost
vars:
MyDict:
- name: Bob
- name: 101 <-- This is a value entered by a user, which happens to be an integer
findname: "101" <-- This is a string i wish to find in the dictionary
tasks:
- debug: msg="{{ findname in MyDict | map(attribute='name') | list }}" <-- I want the lookup to return true