How do you query the network structure (gateways, hosts, networks, groups) of a Check Point management server with Ansible?
Run one facts module per object type (cp_mgmt_simple_gateway_facts, cp_mgmt_host_facts, cp_mgmt_network_facts, cp_mgmt_group_facts), register each result, and print the fields you care about.
The same task template works for all four, only the module and the variable name change:
- name: show-simple-gateways
check_point.mgmt.cp_mgmt_simple_gateway_facts:
details_level: standard
limit: 50
offset: 0
register: simple_gateways_info
…and likewise cp_mgmt_host_facts → host_info, cp_mgmt_network_facts → network_info, cp_mgmt_group_facts → group_info.
Together these four answer "what does this firewall know about the network?": the gateways it manages, the individual hosts, the subnets, and the groups that rules refer to. Printing them raw with debug produces pages of JSON, so the next step is to extract just type, name and color from each list with json_query, and to print one combined, readable summary at the end.
Because the tasks only read, they always report ok, never changed. A playbook like this is safe to run as often as you like, for example as a nightly inventory report.
Go deeper:
cp_mgmt_simple_gateway_facts module (Ansible docs) — the gateway variant of the template.