What is the operating sequence for changing a Check Point configuration through the API, and how does Ansible fit into it?
Log in (get a session) → run commands → publish or discard → log out; Ansible's connection plugin does the login and logout, the modules run the commands, and you must publish explicitly.
Whether a human uses SmartConsole, a script uses curl, or Ansible uses its modules, the management server sees the same flow:
- Login: opens a session, returns the
sid. - Commands:
add-host,set-access-rule,show-hosts, … Changes stay private to the session. - Publish (make the changes public) or Discard (throw them away).
- Logout: ends the session.
With Ansible, the httpapi connection plugin for Check Point performs step 1 when the first task needs the connection and step 4 when it closes. The cp_mgmt_* modules are step 2. Step 3 is not automatic: either add a task with check_point.mgmt.cp_mgmt_publish (or cp_mgmt_discard), or set auto_publish_session: true on a module that changes something, which publishes right after that task.
Leaving out step 3 is the most common beginner mistake: the playbook reports changed, and nobody else sees the change.
* One playbook run = one API session. Without a publish, the changes stay private and are never installed. *
Go deeper:
cp_mgmt_publish module (Ansible docs) — "all the changes done by this user will be seen by all users only after publish is called".
cp_mgmt_discard module (Ansible docs) — the other way to end a session cleanly.