Skip to content

network-evolution/netbox-automation-course

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

40 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

NetBox Automation with Ansible & Python Masterclass

This repository contains the official code, scripts, and automation playbooks for the NetBox Automation with Ansible & Python Masterclass course.

πŸš€ Enroll in the Course on Udemy


πŸŽ“ What You Will Learn

  • Master NetBox as a Single Source of Truth (SSoT) for multi-vendor network automation (Cisco, Fortinet, Juniper, Palo Alto, Arista).
  • Full-stack NetBox Installation: Deploy using Docker on Windows (WSL), MacOS, and AWS EC2.
  • Lifecycle Management: Automate NetBox using Ansible modules and Python libraries (pynetbox & Requests).
  • Organizational Hierarchies: Build and manage Regions, Sites, Locations, and Tenants at scale.
  • Device Modeling: Orchestrate End-to-End Rack and Device modeling, including modular chassis management.
  • IPAM & VLANs: Implement advanced strategies, including auto-assignment of Management IPs and SVI creation.
  • Infrastructure Components: Manage Circuits, Providers, VPNs, and Wireless LANs.
  • REST API Mastery: Use Postman and Swagger for advanced Filtering and Pagination.
  • Next-Gen Features: Utilize NetBox Branching (Git-style) and Co-pilot for safe data staging.
  • Data Integration: Sync NetBox with external sources like GitHub and AWS S3.
  • Dynamic Inventory: Leverage the Ansible Inventory Plugin to use NetBox for real-time network deployments.
  • Custom Scripts: Develop internal NetBox scripts for bulk tasks and compliance checks.
  • Configuration Management: Render device configurations using Config Contexts and Jinja2 Templates.
  • Virtualization & Cabling: Model Virtual Machines, Server Clusters, and Physical Cabling.
  • Plugins & Extensions: Install and configure popular plugins like BGP and Topology View.
  • Network Discovery: Explore next-gen discovery with NetBox Diode and Orb Agent.
  • Administrative Automation: Automate Custom Fields, Journal Entries, and Webhook Event Rules.

πŸ“œ Comprehensive Syllabus & Topics Covered

1. Introduction & Environment Setup

  • NetBox Design Philosophy & Architecture Explained
  • Installation: Windows (Docker/WSL2), MacOS (Docker Desktop), and AWS EC2
  • VS Code Setup for Network Automation
  • Accessing NetBox Public Demo & Labs Cloud Instance

2. Building Your First Inventory

  • Adding Sites, Manufacturers, Device Roles, and Types
  • Understanding NetBox Data Relationships
  • Strategic Planning: Importing Data via CSV (Tenants, Regions, Sites)

3. NetBox Features: Co-pilot & Branching

  • Enabling Co-pilot in Community Edition
  • Git-style Branching for staging infrastructure changes

4. REST API & Programmatic Access

  • NetBox Token V1 vs V2 Security
  • API Operations: GET, POST, PUT, PATCH using Postman
  • Handling Pagination and Bulk Operations

5. Ansible & Python Automation

  • Ansible Inventory setup & URI Module examples
  • Python Integration: Using Requests and the official PyNetBox library
  • Idempotency: Implementing custom checks to prevent data noise
  • Full Organizational Data reset scripts

6. Rack & Device Orchestration

  • Rack Modeling: Manufacturers, Roles, and types at scale
  • Device Inventory: Manual vs. Programmatic onboarding
  • Modular Systems: Chassis and Module Slot assignment (Cisco/Multi-vendor)

7. Config Contexts & Templates

  • Creating Config Context Profiles and JSON Schemas
  • Rendering device configurations via Jinja2 Templates

8. Dynamic Inventory & Network Deployment

  • NetBox as a Dynamic Source for Ansible
  • Discovering devices and assigning Primary IPs via automation
  • Deploying rendered configs to live POC Lab devices

9. Circuits, Power, & Physical Connectivity

  • Cabling: Connecting interfaces, Power Panels, and PDUs
  • Circuits: Modeling Providers and Terminations via Python/Ansible

10. IPAM, VPN, & Wireless

  • Automating VLAN SVI creation and IP Prefix assignments
  • VPN Modeling: IPSec Profiles and DMVPN Tunnel Terminations
  • Wireless Groups and WLAN management

11. Virtualization & Server Modeling

  • Modeling Virtual Machines (VMs) and Server Clusters
  • Connecting Server cables to Network Switches

12. Advanced Customization & Plugins

  • Automation of Custom Fields, Export Templates, and Webhooks
  • Setting up Data Sources (AWS S3, Git, Local)
  • Plugins: BGP, Topology View, and NetBox Diode/Orb Agent discovery

πŸš€ More Courses by NetworkEvolution

Looking to expand your automation toolkit? Check out my other highly-rated courses:


⚑️ Getting Started

This project uses uv for Python dependency management. Follow these two steps to build your automation environment.

Prerequisites

Ensure you have uv installed on your machine.

# macOS / Linux
curl -LsSf [https://astral.sh/uv/install.sh](https://astral.sh/uv/install.sh) | sh

# Windows
powershell -c "irm [https://astral.sh/uv/install.ps1](https://astral.sh/uv/install.ps1) | iex"

Setup Instructions

Step 1: Install Python Libraries

First, install the Python tools (Ansible engine, pynetbox, and helper libraries) into a virtual environment.

uv sync

What this does: It reads pyproject.toml and creates an isolated Python environment so this project doesn't conflict with other work on your machine.

Step 2: Install Ansible Collections

Next, install the specific Ansible modules needed to talk to Netbox (defined in requirements.yml).

uv run ansible-galaxy collection install -r requirements.yml

What this does: It downloads the netbox.netbox collection from Ansible Galaxy.

Note: We use uv run to ensure we use the local version of Ansible installed in Step 1, not your system version.

Step 3: Verify Setup

Check that the environment is correctly using the local Ansible version.

uv run ansible --version

Maintained by NetworkEvolution