I am trying to work out how to iterate over some JSON that has repeated structures but have not used a list.
I am using the ansible.posix.firewalld_info
module and it returns a dictionary for each zone:
{
"active_zones": true,
"changed": false,
"collected_zones": [
"public",
"work"
],
"firewalld_info": {
"default_zone": "public",
"version": "0.9.3",
"zones": {
"public": {
"forward": false,
"forward_ports": [],
"icmp_block_inversion": false,
"icmp_blocks": [],
"interfaces": [
"ens22",
"ens20",
"ens19",
"ens18"
],
"masquerade": true,
"ports": [
[
"9090",
"tcp"
]
],
"protocols": [],
"rich_rules": [],
"services": [
"ssh",
"cockpit",
"MyCustomService"
],
"source_ports": [],
"sources": [],
"target": "DROP"
},
"work": {
"forward": false,
"forward_ports": [],
"icmp_block_inversion": false,
"icmp_blocks": [],
"interfaces": [
"ens21"
],
"masquerade": false,
"ports": [],
"protocols": [],
"rich_rules": [],
"services": [
"ssh",
"dhcpv6-client",
"cockpit"
],
"source_ports": [],
"sources": [],
"target": "default"
}
}
},
"invocation": {
"module_args": {
"active_zones": true,
"zones": null
}
},
"undefined_zones": []
}
public
and work
are dictionaries. How can I iterate over each zone under firewalld_info
in this JSON?