I have the following dictionary:
"dict": [ { "name": "a", "surname": "b" }, { "name": "c", "surname": "d" }, { "name": "e", "surname": "f" } ]
I am trying to extract just "name" values into one list like this one:
names_list: ["a","c","e"]
It should be very simple but I'm not getting the result. This is what I tried:
- set_fact:
names_list: "{{ dict | json_query('[*].name') }}"
and also:
- set_fact:
names_list: "{{ dict | map(attribute='name') | list }}"
but I'm getting either "none" or "ansible undefined".
What I'm missing here?
Thanks.