Hey all, I have a task that I’m really struggling to convert into Ansible from Python.
I’m uring the uri module to query an API and it returns the JSON output like the following:
`
[
{
“Name”: “Linux File System”,
“Task”: “Succeeded”,
“Date”: “epochdate”
},
{
“Name”: “DB System”,
“Task”: “Succeeded”,
“Date”: “epochdate”
},
{
“Name”: “Linux File System”,
“Task”: “Succeeded”,
“Date”: “epochdate”
},
{
“Name”: “DB System”,
“Task”: “Succeeded”,
“Date”: “epochdate”
}
]
`
So a simple list of dicts…
However, the list will have two different types of Name
in them, and these aren’t in order.
I can currently print out the JSON with the following:
`
- debug:
msg: “{{ data.json[‘items’] }}”
`
The outcome I am looking for is something like this:
`
Linux File System Succeeded Date
Linux File System Succeeded Date
Linux File System Succeeded Date
DB System Succeeded Date
DB System Succeeded Date
DB System Succeeded Date
`
So effectively split them into two separate groups.
I can do this with python just fine, however, I don’t seem to be able to grasp how to convert this into Ansible.
Can anyone put me on the right track here?
Thanks in advance!