I have a task which uses with_subelements
but it's terrible slow for big list (especially that most of the elements has duplicates and I don't need to run it multiple times for them).
So I'm looking for a way to optimize it somehow. I wish to get all unique elements from that list - let say settings
in the example below:
inventory:
my_list:
- { name: foo, settings: ['x', 'y', 'z'] }
- { name: bar, settings: ['x', 'y', 'q', 'w'] }
tasks:
- name: get all settings
set_fact:
all_settings="{{ my_list|map(attribute='settings')|list }}"
- name: show results
debug:
var=all_settings
results:
"var": {
"all_settings": [
[
"x",
"y",
"z"
],
[
"x",
"y",
"q"
"w"
]
]
}
I stuck at this point. How can I combine those list together ?
I'm looking for a way to get ['x', 'y', 'z', 'q', 'w']