I have a list of dictionaries in an ansible variable. Some dictionaries have the same value in the field 'id and the field 'name' while they differ in other key value pairs (that are not important for me). I want to filter out all those dictionaries that are "duplicates" regarding the 'name' and 'id' fields.
Example:
[{
"name": "abc",
"id": "123456",
"other_key": "unimportant value"
},
{
"name": "abc",
"id": "123456",
"other_key": "another unimportant value"
},
{
"name": "bcd",
"id": "789012",
"other_key": "unimportant value"
}]
Desired result:
[{
"name": "abc",
"id": "123456"
},
{
"name": "bcd",
"id": "789012"
}]
How can I achieve this in Ansible? (the 'other_key' variable does not necessarily have to be discarded it could also be e.g. just the first occurrence, it just does not matter).
I already produced a list of unique ids with:
{{ mydictionaries | map(attribute='id') | unique | list }}
But how do I filter the list of dictionaries with this?