Запрос ниже выполняет работу
- set_fact:
pkgl: "{{ pkgs|
dict2items|
json_query('[].{name: key,
package_description: value.package_description,
owner: value.owner}') }}"
- debug:
var: pkgl
дает
"pkgl": [
{
"name": "pkg2",
"owner": "node2",
"package_description": "desc2"
},
{
"name": "pkg1",
"owner": "node1",
"package_description": "xzy"
}
]
Тот же результат дает задачу без json_query
- set_fact:
pkgl: "{{ pkgl|default([]) +
[{'name': item.key,
'package_description': item.value.package_description,
'owner': item.value.owner}] }}"
loop: "{{ pkgs|dict2items }}"