Reputation: 5441
I have a variable like that :
"files": {
"results": [
{
"files": [
{
"path": "/etc/file1.xml",
},
{
"path": "/etc/file2.xml",
}
]
},
{
"files": [
{
"path": "/etc/file2.xml",
}
]
},
{
"files": []
}
}
}
How can iterate through all paths ?
Upvotes: 1
Views: 1219
Reputation: 68339
You don't need to iterate two dimensions to get all paths.
Use map filter to reduce your original list.
To get plain list of paths from your example:
- debug: msg="{{ files.results | map(attribute='files') | sum(start=[]) | map(attribute='path') | list }}"
Upvotes: 1