Skip to main content

Python script to automate the upgrade process of PAN-OS firewalls.

Project description

Contributors Forks Stargazers Issues Apache2.0 License


Logo

PAN-OS Automation Project

Streamlining Palo Alto Networks Firewall Upgrades with Python Automation
Documentation Website ยป

View Demo Report Bug Request Feature

Table of Contents
  1. About The Project
  2. Usage
  3. Contributing
  4. License
  5. Contact
  6. Acknowledgments

About The Project

This project is a comprehensive Python-based solution for automating PAN-OS upgrades. It's designed to provide network administrators and security professionals with an efficient tool to manage upgrades, configurations, and system checks of Palo Alto Networks appliances.

Project Link: https://github.com/cdot65/pan-os-upgrade Documentation: https://cdot65.github.io/pan-os-upgrade/

Key Features

  • Three Unique Upgrade Workflows Supported:
    • firewall: targets and upgrades an individual firewall
    • panorama: targets and upgrades an individual Panorama appliance
    • batch: targets a Panorama appliance and upgrades firewalls in batch
  • Automation of Routine Tasks: Reduces manual errors and saves time by automating upgrades, configurations, and system checks.
  • Support for Direct and Proxy Connections: Connect directly to firewalls or through a Panorama appliance, with support for targeting specific devices using filters.
  • Pre/Post Diff: Network snapshots are taken before and after the upgrade process, providing a PDF report of changes within the network environment after the upgrade completes.
  • Active/Passive High Availability (HA) Workflow: Fully supports upgrading devices in active/passive HA configurations, ensuring both members are properly upgraded and synchronized.
  • Multi-threading for Efficiency: Utilizes multi-threading to parallelize upgrades, especially beneficial when upgrading multiple devices through Panorama, enhancing performance and reducing overall upgrade time.
  • Customizable and Extensible: Execution of the script can be tailored to fit diverse network environments and requirements, offering flexibility for various deployment scenarios.
  • Comprehensive PAN-OS Interactions: Facilitates extensive interactions with Palo Alto Networks appliances for operations like readiness checks, state snapshots, and report generation.

Note: While this script is optimized for standalone and active/passive HA environments, it has not been tested against active/active or clustered firewalls.

Example Execution

pan-os-upgrade batch
Panorama hostname or IP: panorama.cdot.io
Panorama username: officehours
Panorama password: 
Firewall target version (ex: 10.1.2): 10.1.3-h2
Dry Run? [Y/n]: n
===========================================================================
Welcome to the PAN-OS upgrade tool

You have selected to perform a batch upgrade of firewalls through Panorama.

No settings.yaml file was found, the script's default values will be used.
Create a settings.yaml file with 'pan-os-upgrade settings' command.

No inventory.yaml file was found, getting firewalls connected to Panorama.
Create an inventory.yaml file with 'pan-os-upgrade inventory' command.
===========================================================================
โœ… panorama.cdot.io: Connection to Panorama established. Firewall connections will be proxied!
๐Ÿ”ง panorama.cdot.io: Retrieving a list of all firewalls connected to Panorama...
๐Ÿ”ง panorama.cdot.io: Retrieving detailed information of each firewall...
โ•’โ•โ•โ•โ•โ•โ•คโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•คโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•คโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•คโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•คโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•คโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ••
โ”‚   # โ”‚ Hostname      โ”‚ IP Address      โ”‚ Model   โ”‚          Serial โ”‚ SW Version   โ”‚ App Version   โ”‚
โ•žโ•โ•โ•โ•โ•โ•ชโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ชโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ชโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ชโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ชโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ชโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ก
โ”‚   1 โ”‚ Woodlands-fw1 โ”‚ 192.168.255.43  โ”‚ PA-VM   โ”‚ 007954000123451 โ”‚ 10.1.3       โ”‚ 8729-8157     โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚   2 โ”‚ Woodlands-fw2 โ”‚ 192.168.255.44  โ”‚ PA-VM   โ”‚ 007954000123452 โ”‚ 10.1.3       โ”‚ 8729-8157     โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚   3 โ”‚ houston       โ”‚ 192.168.255.211 โ”‚ PA-VM   โ”‚ 007954000123453 โ”‚ 10.1.3       โ”‚ 8797-8498     โ”‚
โ•˜โ•โ•โ•โ•โ•โ•งโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•งโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•งโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•งโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•งโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•งโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•›
You can select devices by entering their numbers, ranges, or separated by commas.
Examples: '1', '2-4', '1,3,5-7'.
Type 'done' on a new line when finished.

Enter your selection(s): 1,2
Woodlands-fw1 selected.
Woodlands-fw2 selected.
Enter your selection(s): done
๐Ÿ“ panorama.cdot.io: Upgrading 2 devices to version 10.1.3-h2...
๐Ÿ“ panorama.cdot.io: Please confirm the selected firewalls:
  - Woodlands-fw1 (192.168.255.43)
  - Woodlands-fw2 (192.168.255.44)
๐ŸŸง panorama.cdot.io: Dry run mode is disabled, upgrade workflow will be executed.
Do you want to proceed with the upgrade? [y/N]: y
๐Ÿš€ Proceeding with the upgrade...
๐Ÿš€ Proceeding with the upgrade...
๐Ÿ”ง panorama.cdot.io: Using 10 threads.
๐Ÿ“ Woodlands-fw1: 007954000123451 192.168.255.43
๐Ÿ“ Woodlands-fw2: 007954000123452 192.168.255.44
๐Ÿ“ Woodlands-fw1: HA mode: active
๐Ÿ“ Woodlands-fw2: HA mode: passive
๐Ÿ“ Woodlands-fw1: Local state: active, Local version: 10.1.3, Peer version: 10.1.3
๐Ÿ“ Woodlands-fw1: Version comparison: equal
๐Ÿ” Woodlands-fw1: Detected active target device in HA pair running the same version as its peer. Added target device to revisit list.
๐Ÿ“ Woodlands-fw2: Local state: passive, Local version: 10.1.3, Peer version: 10.1.3
๐Ÿ“ Woodlands-fw2: Version comparison: equal
๐Ÿ“ Woodlands-fw2: Target device is passive
๐Ÿ“ Woodlands-fw2: Current version: 10.1.3
๐Ÿ“ Woodlands-fw2: Target version: 10.1.3-h2
โœ… Woodlands-fw2: Upgrade required from 10.1.3 to 10.1.3-h2
๐Ÿ”ง Woodlands-fw2: Refreshing list of available software versions
โœ… Woodlands-fw2: version 10.1.3-h2 is available for download
โœ… Woodlands-fw2: Base image for 10.1.3-h2 is already downloaded
๐Ÿš€ Woodlands-fw2: Performing test to see if 10.1.3-h2 is already downloaded.
โœ… Woodlands-fw2: version 10.1.3-h2 already on target device.
โœ… Woodlands-fw2: 10.1.3-h2 has been downloaded and sync'd to HA peer.
๐Ÿš€ Woodlands-fw2: Performing snapshot of network state information.
๐Ÿš€ Woodlands-fw2: Attempting to capture network state snapshot (Attempt 1 of 3).
โœ… Woodlands-fw2: Network snapshot created successfully on attempt 1.
๐Ÿ’พ Woodlands-fw2: Network state snapshot collected and saved to assurance/snapshots/Woodlands-fw2/pre/2024-02-13_14-18-09.json
๐Ÿš€ Woodlands-fw2: Performing readiness checks of target firewall.
๐Ÿš€ Woodlands-fw2: Performing readiness checks to determine if firewall is ready for upgrade.
โœ… Woodlands-fw2: Passed Readiness Check: Check if active support is available
๐ŸŸจ Woodlands-fw2: Skipped Readiness Check: Check if a given ARP entry is available in the ARP table
โœ… Woodlands-fw2: Passed Readiness Check: Check if there are pending changes on device
๐ŸŸจ Woodlands-fw2: Skipped Readiness Check: Check if the certificates' keys meet minimum size requirements
๐ŸŸจ Woodlands-fw2: Skipped Readiness Check: Running Latest Content Version
โœ… Woodlands-fw2: Passed Readiness Check: Check if any Dynamic Update job is scheduled to run within the specified time window
โœ… Woodlands-fw2: Passed Readiness Check: No Expired Licenses
๐ŸŸจ Woodlands-fw2: Skipped Readiness Check: Check if a there is enough space on the `/opt/panrepo` volume for downloading an PanOS image.
โœ… Woodlands-fw2: Passed Readiness Check: Checks HA pair status from the perspective of the current device
๐ŸŸจ Woodlands-fw2: Skipped Readiness Check: Check if a given IPsec tunnel is in active state
๐ŸŸจ Woodlands-fw2: Skipped Readiness Check: Check for any job with status different than FIN
๐ŸŸจ Woodlands-fw2: Skipped Readiness Check: Check if NTP is synchronized
โœ… Woodlands-fw2: Passed Readiness Check: Check if the clock is synchronized between dataplane and management plane
โœ… Woodlands-fw2: Passed Readiness Check: Check connectivity with the Panorama appliance
๐ŸŸจ Woodlands-fw2: Skipped Readiness Check: Check if a critical session is present in the sessions table
โœ… Woodlands-fw2: Readiness Checks completed
๐Ÿš€ Woodlands-fw2: Checking if HA peer is in sync.
โœ… Woodlands-fw2: HA peer sync test has been completed.
๐Ÿš€ Woodlands-fw2: Performing backup of configuration to local filesystem.
๐Ÿ“ Woodlands-fw2: Not a dry run, continue with upgrade.
๐Ÿš€ Woodlands-fw2: Performing upgrade to version 10.1.3-h2.
๐Ÿ“ Woodlands-fw2: The install will take several minutes, check for status details within the GUI.
๐Ÿš€ Woodlands-fw2: Attempting upgrade to version 10.1.3-h2 (Attempt 1 of 3).
Device 007954000123452 installing version: 10.1.3-h2
โœ… Woodlands-fw2: Upgrade completed successfully
๐Ÿš€ Woodlands-fw2: Rebooting the target device.
๐Ÿ“ Woodlands-fw2: Command succeeded with no output
๐ŸŸง Woodlands-fw2: Retry attempt 1 due to error: 007954000123452 not connected
๐ŸŸง Woodlands-fw2: Retry attempt 2 due to error: 007954000123452 not connected
๐ŸŸง Woodlands-fw2: Retry attempt 3 due to error: 007954000123452 not connected
๐ŸŸง Woodlands-fw2: Retry attempt 4 due to error: 007954000123452 not connected
๐ŸŸง Woodlands-fw2: Retry attempt 5 due to error: 007954000123452 not connected
๐ŸŸง Woodlands-fw2: Retry attempt 6 due to error: 007954000123452 not connected
๐ŸŸง Woodlands-fw2: Retry attempt 7 due to error: 007954000123452 not connected
๐ŸŸง Woodlands-fw2: Retry attempt 8 due to error: 007954000123452 not connected
๐ŸŸง Woodlands-fw2: Retry attempt 9 due to error: 007954000123452 not connected
๐Ÿ“ Woodlands-fw2: Current device version: 10.1.3-h2
โœ… Woodlands-fw2: Device rebooted to the target version successfully.
๐Ÿš€ Woodlands-fw2: Performing backup of configuration to local filesystem.
๐Ÿ”ง Woodlands-fw2: Waiting for the device to become ready for the post upgrade snapshot.
๐Ÿš€ panorama.cdot.io: Revisiting firewalls that were active in an HA pair and had the same version as their peers.
๐Ÿ“ Woodlands-fw1: 007954000123451 192.168.255.43
๐Ÿ“ Woodlands-fw1: HA mode: active
๐Ÿ“ Woodlands-fw1: Local state: active, Local version: 10.1.3, Peer version: 10.1.3-h2
Waiting for HA synchronization to complete on Woodlands-fw1. Attempt 1/3
HA synchronization complete on Woodlands-fw1. Proceeding with upgrade.
๐Ÿ“ Woodlands-fw1: Version comparison: older
๐Ÿ“ Woodlands-fw1: Target device is on an older version
๐Ÿ“ Woodlands-fw1: Suspending HA state of active
๐ŸŸง Woodlands-fw1: Error received when suspending active target device HA state: argument of type 'NoneType' is not iterable
๐Ÿ“ Woodlands-fw1: Current version: 10.1.3
๐Ÿ“ Woodlands-fw1: Target version: 10.1.3-h2
โœ… Woodlands-fw1: Upgrade required from 10.1.3 to 10.1.3-h2
๐Ÿ”ง Woodlands-fw1: Refreshing list of available software versions
โœ… Woodlands-fw1: version 10.1.3-h2 is available for download
โœ… Woodlands-fw1: Base image for 10.1.3-h2 is already downloaded
๐Ÿš€ Woodlands-fw1: Performing test to see if 10.1.3-h2 is already downloaded.
โœ… Woodlands-fw1: version 10.1.3-h2 already on target device.
โœ… Woodlands-fw1: 10.1.3-h2 has been downloaded and sync'd to HA peer.
๐Ÿš€ Woodlands-fw1: Performing snapshot of network state information.
๐Ÿš€ Woodlands-fw1: Attempting to capture network state snapshot (Attempt 1 of 3).
โœ… Woodlands-fw1: Network snapshot created successfully on attempt 1.
๐Ÿ’พ Woodlands-fw1: Network state snapshot collected and saved to assurance/snapshots/Woodlands-fw1/pre/2024-02-13_14-37-49.json
๐Ÿš€ Woodlands-fw1: Performing readiness checks of target firewall.
๐Ÿš€ Woodlands-fw1: Performing readiness checks to determine if firewall is ready for upgrade.
โœ… Woodlands-fw1: Passed Readiness Check: Check if active support is available
๐ŸŸจ Woodlands-fw1: Skipped Readiness Check: Check if a given ARP entry is available in the ARP table
โœ… Woodlands-fw1: Passed Readiness Check: Check if there are pending changes on device
๐ŸŸจ Woodlands-fw1: Skipped Readiness Check: Check if the certificates' keys meet minimum size requirements
๐ŸŸจ Woodlands-fw1: Skipped Readiness Check: Running Latest Content Version
โœ… Woodlands-fw1: Passed Readiness Check: Check if any Dynamic Update job is scheduled to run within the specified time window
โœ… Woodlands-fw1: Passed Readiness Check: No Expired Licenses
๐ŸŸจ Woodlands-fw1: Skipped Readiness Check: Check if a there is enough space on the `/opt/panrepo` volume for downloading an PanOS image.
๐ŸŸจ Woodlands-fw1: Skipped Readiness Check: Checks HA pair status from the perspective of the current device
๐ŸŸจ Woodlands-fw1: Skipped Readiness Check: Check if a given IPsec tunnel is in active state
๐ŸŸจ Woodlands-fw1: Skipped Readiness Check: Check for any job with status different than FIN
๐ŸŸจ Woodlands-fw1: Skipped Readiness Check: Check if NTP is synchronized
โœ… Woodlands-fw1: Passed Readiness Check: Check if the clock is synchronized between dataplane and management plane
โœ… Woodlands-fw1: Passed Readiness Check: Check connectivity with the Panorama appliance
๐ŸŸจ Woodlands-fw1: Skipped Readiness Check: Check if a critical session is present in the sessions table
โœ… Woodlands-fw1: Readiness Checks completed
๐Ÿš€ Woodlands-fw1: Checking if HA peer is in sync.
โœ… Woodlands-fw1: HA peer sync test has been completed.
๐Ÿš€ Woodlands-fw1: Performing backup of configuration to local filesystem.
๐Ÿ“ Woodlands-fw1: Not a dry run, continue with upgrade.
๐Ÿš€ Woodlands-fw1: Performing upgrade to version 10.1.3-h2.
๐Ÿ“ Woodlands-fw1: The install will take several minutes, check for status details within the GUI.
๐Ÿš€ Woodlands-fw1: Attempting upgrade to version 10.1.3-h2 (Attempt 1 of 3).
Device 007954000123451 installing version: 10.1.3-h2
โœ… Woodlands-fw1: Upgrade completed successfully
๐Ÿš€ Woodlands-fw1: Rebooting the target device.
๐Ÿ“ Woodlands-fw1: Command succeeded with no output
๐ŸŸง Woodlands-fw1: Retry attempt 1 due to error: 007954000123451 not connected
๐ŸŸง Woodlands-fw1: Retry attempt 2 due to error: 007954000123451 not connected
๐ŸŸง Woodlands-fw1: Retry attempt 3 due to error: 007954000123451 not connected
๐ŸŸง Woodlands-fw1: Retry attempt 4 due to error: 007954000123451 not connected
๐ŸŸง Woodlands-fw1: Retry attempt 5 due to error: 007954000123451 not connected
๐ŸŸง Woodlands-fw1: Retry attempt 6 due to error: 007954000123451 not connected
๐ŸŸง Woodlands-fw1: Retry attempt 7 due to error: 007954000123451 not connected
๐ŸŸง Woodlands-fw1: Retry attempt 8 due to error: 007954000123451 not connected
๐ŸŸง Woodlands-fw1: Retry attempt 9 due to error: 007954000123451 not connected
๐Ÿ“ Woodlands-fw1: Current device version: 10.1.3-h2
โœ… Woodlands-fw1: Device rebooted to the target version successfully.
๐Ÿš€ Woodlands-fw1: Performing backup of configuration to local filesystem.
๐Ÿ”ง Woodlands-fw1: Waiting for the device to become ready for the post upgrade snapshot.
โœ… panorama.cdot.io: Completed revisiting firewalls

(back to top)

Usage

There are two primary methods to utilize the pan-os-upgrade tool: through a Python virtual environment or via a Docker container.

Please refer to the dedicated documentation website to understand how to use this tool.

Documentation Site: https://cdot65.github.io/pan-os-upgrade/

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request or open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

See Contributing Guidelines for detailed instructions.

(back to top)

License

This project is licensed under the Apache 2.0 License - see the LICENSE file for details.

(back to top)

Contact

Email Address - cremsburg.dev at gmail.com

(back to top)

Acknowledgments

This project is built upon the shoulders of two powerful Python libraries: pan-os-python and panos-upgrade-assurance. Both of these libraries are developed and maintained by Palo Alto Networks, providing an incredible amount of capabilities when automating PAN-OS and Panorama with Python.

(back to top)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pan_os_upgrade-1.2.3.tar.gz (65.9 kB view hashes)

Uploaded Source

Built Distribution

pan_os_upgrade-1.2.3-py3-none-any.whl (64.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page