I get data from the community.general.xml module like this. Next, I need to make a selection with the received data in the same xml file in the loop. But how to address them, I do not know.
I get data like this:
{
"scriptVal": {
"actions": {
"xpath": "//subClientProperties[vmContent/children[@displayName=\"test-pc4\"]]/subClientEntity",
"namespaces": {},
"state": "present"
},
"changed": false,
"count": 2,
"matches": [
{
"subClientEntity": {
"appName": "Virtual Server",
"backupsetName": "backupset-test",
"clientName": "Name-vcagent",
"displayName": "Name-VCAgent",
"instanceName": "VC01",
"subclientName": "test"
}
},
{
"subClientEntity": {
"appName": "Virtual Server",
"backupsetName": "Test01",
"clientName": "Name-vcagent",
"displayName": "Name-VCAgent",
"instanceName": "VC01",
"subclientName": "start9pm"
}
}
],
"msg": 2,
"ansible_facts": {
"discovered_interpreter_python": "/usr/libexec/platform-python"
},
"failed": false
},
}
I need to access each element of the subClientEntity dictionaries
Every time my attempt fails:
- debug:
msg: "{{ item.id }} : {{ item.value] }}"
loop: "{{ scriptVal.matches.item.subClientEntity | default }}"
Result:
TASK [debug msg={{ item.id }} : {{ item.value] }}] *****************************
fatal: [localhost]: FAILED! => {"msg": "Invalid data passed to 'loop', it requires a list, got this instead: . Hint: If you passed a list/dict of just one element, try adding wantlist=True to your lookup invocation or use q/query instead of lookup."}