Hello,
I am using Ansible 2.0.0 devel version and i want to create list of hashes in my playbook.
For example i have one variable jkl11 with structure:
debug msg={{ jkl11 }}] ******************************************
ok: [localhost] => {
“changed”: false,
“msg”: [
[
[
“e0c9cf47-00f2-4909-84a5-d3db7cbf61f3”,
“app”,
“2015-12-29”
]
],
[
[
“0b3d86bb-8acb-4d27-8d51-8a44995bc0e0”,
“app”,
“2015-12-29”
]
],
[
[
“71dbcb06-e807-4316-9257-722c6ccf8031”,
“web”,
“2015-12-29”
]
]
]
}
I and want to do loop and search only for “app” and create list of hashes with this structure stored in one variable (for example jkl22)
{
“created”: “2015-12-29”,
“name”: “app”,
“id”: “e0c9cf47-00f2-4909-84a5-d3db7cbf61f3”
},
{
“created”: “2015-12-29”,
“name”: “app”,
“id”: “0b3d86bb-8acb-4d27-8d51-8a44995bc0e0”
}
I tried to do this by:
- set_fact:
jkl22: “{{ jkl22|default({})|combine({‘created’: item.2, ‘name’: item.1, ‘id’: item.0}) }}”
with_items: jkl11
when: item.1 == “app”
But i got only the last one.:
debug msg={{ jkl22 }}] **********
ok: [localhost] => {
“changed”: false,
“msg”: {
“created”: “2015-12-29”,
“name”: “app”,
“id”: “0b3d86bb-8acb-4d27-8d51-8a44995bc0e0”
}
}
How can i do this?
Regards,
Gerhard