The Meraki AutoVPN Hub Update Script is a Python script that allows you to update AutoVPN settings for Meraki networks using the Meraki API. It provides a convenient way to modify the hub and hub order configuration for multiple networks at once.
Before using the script, ensure you have the following:
git clone https://github.com/baadrdeen/Meraki_vpn_hub_updater.git
cd Meraki_vpn_hub_updater
pip install -r requirements.txt
export MERAKI_DASHBOARD_API_KEY='API KEY'
config.yaml
file and provide the following information:# Organization ID org_id: YOUR_ORG_ID # Hub order option: # - primary : Add the new hub as the primary hub # - secondary : Add the new hub as the secondary hub # - switch : Switch the order of the existing hubs hub_order: secondary # Old hub name (required for 'primary' or 'secondary' hub order) old_hub_name: Old Hub Name # New hub name (required for 'primary' or 'secondary' hub order) new_hub_name: New Hub Name # Target networks to update. Set to 'all' to update all networks in the organization, # or provide a list of specific network IDs : # target: # - netid1 # - netid2 # - netid3 target: all
YOUR_ORG_ID
with your actual Meraki organization ID.target
, hub_order
, old_hub_name
, and new_hub_name
parameters as needed.The script can be executed using the command-line interface. There are two modes available: simulation mode and deploy mode.
To run the script in simulation mode:
python3 MerakiVPN-HubUpdater.py -s
-s
or --simulate
flag enables simulation mode.To run the script in deploy mode:
python3 MerakiVPN-HubUpdater.py -d
-d
or --deploy
flag activates deploy mode.Note: By default, the script runs in simulation mode if no mode is specified.
The script follows the following logical workflow:
Introduction: Upon execution, the script displays an introduction and provides information about the location of logs, backup files, and the report file.
Restore Mode (Optional): If the -r
or --restore
flag is provided, the script restores VPN settings from a backup file.
Update Mode: If not in restore mode, the script loads the configuration from the config.yaml
file and validates it.
Simulation Mode (Default): If in simulation mode, the script performs a simulation of the VPN settings updates and logs the simulated API requests.
Deploy Mode: If in deploy mode, the script makes changes to the specified Meraki networks based on the configuration.
Backup: Before making any changes, the script creates a backup of the current VPN settings for each network.
Update VPN Hubs: The script updates the VPN hubs and hub order for the specified networks.
Result Report: Upon completion, the script generates a report with details of the VPN settings updates and saves it as an Excel file.
Logs
directory.Backup
directory.Report
directory.The Meraki AutoVPN Hub Update Script provides a convenient way to update AutoVPN settings for Meraki networks. This script is particularly useful in scenarios where you need to make bulk changes to the VPN hub and hub order configurations across multiple Meraki networks.
Let's consider a scenario where an organization has multiple Meraki networks deployed across different locations. The organization wants to update the primary VPN hub for a specific set of networks to a new hub and change the hub order. Manually updating each network's VPN settings through the Meraki Dashboard can be time-consuming and error-prone.
With the Meraki AutoVPN Hub Update Script, you can easily automate this process. By providing a configuration file (config.yaml) specifying the organization ID, target networks, old hub name, new hub name, and hub order, the script will update the VPN hubs and hub order for the specified networks.
The script supports both simulation mode and deploy mode. In simulation mode, the script performs simulated API requests and logs the changes that would be made without actually modifying the network configurations. This allows you to preview the changes before applying them. In deploy mode, the script makes the actual API requests to update the VPN settings of the target networks.
This script was developed using the Meraki Dashboard API and the rich library.
Contributions are welcome! If you encounter any issues or have suggestions for improvements, please create an issue or submit a pull request.
This project is licensed under the MIT License.
Code Exchange Community
Get help, share code, and collaborate with other developers in the Code Exchange community.View Community