Here’s a minimal Ansible “project” that will:
- snapshot your Panorama config
- attempt a commit
- if the commit fails, roll back to the snapshot and re-commit
- always clean up the snapshot
1. Directory layout
panorama-commit-recovery/
├── ansible.cfg
├── requirements.yml
├── inventory/
│ └── hosts.yml
├── group_vars/
│ └── panorama.yml
└── playbook.yml
2. requirements.yml
Make sure you’ve got Palo Alto’s collection:
---
collections:
- name: paloaltonetworks.panos
version: ">=2.2.0"
Install it with:
ansible-galaxy collection install -r requirements.yml
3. ansible.cfg
[defaults]
inventory = inventory/hosts.yml
host_key_checking = False
4. inventory/hosts.yml
all:
children:
panorama:
hosts:
panorama01:
ansible_host: 192.0.2.10
5. group_vars/panorama.yml
ansible_user: admin
ansible_password: AdminPassword123
ansible_network_os: paloaltonetworks.panos.panos
provider:
ip_address: "{{ ansible_host }}"
username: "{{ ansible_user }}"
password: "{{ ansible_password }}"
timeout: 60
# snapshot/commit settings
snapshot_name: "pre_commit_{{ lookup('pipe','date +%Y%m%dT%H%M%S') }}"
commit_timeout: 120
6. playbook.yml
---
- name: Automated commit with recovery on Panorama
hosts: panorama
gather_facts: no
collections:
- paloaltonetworks.panos
tasks:
- name: Create configuration snapshot
panos_config_snapshot:
provider: "{{ provider }}"
snapshot_name: "{{ snapshot_name }}"
register: snap
- name: Commit candidate config (with rollback on failure)
block:
- name: Commit candidate config to Panorama
panos_commit:
provider: "{{ provider }}"
sync: true
timeout: "{{ commit_timeout }}"
rescue:
- name: COMMIT FAILED! Load snapshot "{{ snapshot_name }}"
panos_load_configuration:
provider: "{{ provider }}"
action: load_snapshot
snapshot_name: "{{ snapshot_name }}"
- name: Re-commit restored config
panos_commit:
provider: "{{ provider }}"
sync: true
timeout: "{{ commit_timeout }}"
always:
- name: Delete snapshot "{{ snapshot_name }}"
panos_config_snapshot:
provider: "{{ provider }}"
snapshot_name: "{{ snapshot_name }}"
state: absent
How it works
- Snapshot
We take a configuration snapshot (named with a timestamp).
- Block/Rescue
- block: try committing your candidate config
- rescue: if that commit fails, load the snapshot and re-commit
- always: clean up the snapshot file
- Provider
We define provider: in group_vars so you don’t have to repeat IP/user/pass in every task.
Running
cd panorama-commit-recovery
ansible-playbook playbook.yml
That’s it! You now have an idempotent, self-healing Panorama commit workflow. 🎉