Skip to content

Repository files navigation

Python Meraki Firewall Groups and Objects

Small Python utility for bulk creation of Meraki policy objects and object groups from a text list.

What it does

  • reads IP/CIDR and FQDN entries from an input file,
  • validates entries and normalizes names,
  • creates missing Meraki policy objects,
  • reuses IDs for objects that already exist,
  • creates/updates an object group from created/found object IDs,
  • writes results to objects_created.json.

Project layout

  • meraki_object_loader.py - main entrypoint
  • meraki_utils.py - validation and API helper functions
  • meraki_api_test.py - simple API connectivity test script
  • input_examples.txt - example input file with different object types

Requirements

  • Python 3.10+
  • packages: meraki, requests

Environment variables

  • MERAKI_API_KEY (required)
  • MERAKI_ORG_ID (required)
  • MERAKI_GROUP_NAME (optional, default: G_POLICY_OBJECTS)
  • MERAKI_INPUT_FILE (optional, default: lista.txt)

Input format

Each non-empty line in the input file:

value[,custom_name]

Examples:

  • 10.10.10.10
  • 10.10.20.0/24,BranchA_Net
  • printer01.example.com,Printer01

For a full sample list (hosts, CIDR networks, FQDNs), use input_examples.txt.

Object naming rules

Names are generated in meraki_utils.py and truncated to 50 characters.

  • IPv4 host (/32) -> H_<ip_with_underscores> Example: 10.10.10.10 -> H_10_10_10_10

  • IPv4 network (/<prefix> other than /32) -> N_<network_ip_with_underscores>-<prefix> Example: 10.10.20.0/24 -> N_10_10_20_0-24

  • FQDN -> normalized FQDN value (or custom_name if provided) Example: printer01.example.com -> printer01_example_com

  • If custom_name is provided for IP/CIDR, it is appended: <base_name>_<normalized_custom_name> Example: 10.10.20.0/24,BranchA -> N_10_10_20_0-24_BranchA

Run

source .venv/bin/activate
export MERAKI_API_KEY='your_key'
export MERAKI_ORG_ID='123456'
export MERAKI_INPUT_FILE='input_examples.txt'
python meraki_object_loader.py

About

Python tool for fast mass creation of Cisco Meraki firewall policy objects and object groups from a file, with validation and duplicate detectionn and duplicate detection.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages