Quiz Entry - updated: 2026.11.26
How do you download firewall logs with Ansible, and how do you limit which logs come back?
Use cp_mgmt_show_logs with a new_query that sets a filter (the same syntax as the SmartConsole log search, e.g. blade:"Firewall"), a time_frame (e.g. last-30-days) and max_logs_per_request; register the result and save the logs list with copy.
- name: show-logs
check_point.mgmt.cp_mgmt_show_logs:
new_query:
filter: blade:"Firewall"
time_frame: last-30-days
max_logs_per_request: 100
register: data_show_logs
- name: copy returned values to file
ansible.builtin.copy:
content: "{{ data_show_logs | community.general.json_query(query) }}"
dest: ~/logs
vars:
query: '"show-logs".logs'
filternarrows the logs exactly like the search bar in SmartConsole's log view (blade, action, source, …).time_framesets the period:today,last-7-days,last-30-days, and so on.max_logs_per_requestcaps one response, so a busy gateway does not return millions of lines at once. To get the next page, call the module again with thequery_idthe first call returned.
Each log entry is a JSON object (time, source, destination, service, action, the rule that matched, the gateway). Saved to a file on the control node, the logs can then be converted and loaded into a search tool such as Elasticsearch.
Go deeper:
cp_mgmt_show_logs module (Ansible docs) —
new_queryoptions and continuing a query.