Skip to content

Intermediate Tutorials

Intermediate TutorialsΒΆ

"From Guessing to Proving β€” Validate Your Automation at Enterprise Scale"ΒΆ

In the Beginner Tutorials, you built single-device and multi-device automation using loops. That works for small changes, but how do you know your automation actually worked? How do you prove ROI? How do you scale to hundreds or thousands of devices?

The answer is a two-part approach:

  1. PyATS β€” Master network device validation and testing (Cisco's enterprise test framework used internally with millions of tests monthly)
  2. Nornir β€” Master parallel execution and orchestration at scale

In these intermediate tutorials, we'll evolve your automation from sequential scripts to validated, parallel, production-grade systems that complete in minutes instead of hours, with built-in confidence.


🎯 Two Paths to Enterprise Automation¢

Path 1: PyATS Mastery (Network Validation)ΒΆ

Learn Cisco's production test framework used internally to validate infrastructure changes before they reach production.

Why it matters:

  • βœ… Prove automation works β€” Don't guess if your change succeeded; validate with structured device parsing
  • βœ… Detect configuration drift β€” Automated compliance checking across hundreds of devices
  • βœ… Production safety β€” Pre-flight validation before changes, post-flight verification after
  • βœ… Built on Genie parsers β€” Cisco's structured parsing library (same as DNAC uses internally)

Path 2: Nornir Mastery (Enterprise Scale)ΒΆ

Learn the framework designed from the ground up for parallel network operations.

Why it matters:

  • βœ… Performance at scale β€” Execute tasks in parallel across 100s/1000s of devices (not sequential loops)
  • βœ… Enterprise patterns β€” Device grouping, credential management, result aggregation
  • βœ… Real-world architecture β€” Multi-step workflows, database integration, change detection
  • βœ… Proven in production β€” Used by network teams managing thousands of devices globally

Together: PyATS + Nornir (The Complete System)ΒΆ

The final tutorial shows how to combine both:

  • Deploy with Nornir (parallel execution)
  • Validate with PyATS (structured testing)
  • Use PRIME Framework integration for repeatable, safe deployments

Foundation Patterns: Core Skills for Modern AutomationΒΆ

Before diving into specific frameworks, master the foundational patterns used throughout production automation.

Data Modeling Essentials (New)ΒΆ

Master the data formats that power network automation:

Why these matter:

  • βœ… YAML β€” Nornir inventories, PyATS testbeds, readable by network engineers
  • βœ… JSON β€” Every modern network API (DNA Center, Meraki, RESTCONF)
  • βœ… Jinja2 β€” Template-driven configuration generation at scale
  • βœ… Separation of concerns β€” Data separate from code, version control friendly

These three skills form the foundation for all subsequent tutorials. Master them first.

Python Patterns for Network AutomationΒΆ

Decorator patternsβ€”the Python technique used throughout production automation:

  • βœ… Retry Logic β€” Handle transient failures automatically without rewriting code
  • βœ… Audit Logging β€” Compliance tracking for every operation
  • βœ… Error Handling β€” Unified error handling and alerts across all functions
  • βœ… Rate Limiting β€” Prevent API throttling and device overload
  • βœ… Performance Monitoring β€” Identify bottlenecks data-driven optimization
  • βœ… Composable Infrastructure β€” Stack multiple concerns without code duplication

Decorators are the "secret weapon" of production network automation. You'll see them used throughout PyATS and Nornir tutorials.

Production Reliability Series (New)ΒΆ

These intermediate tutorials extend the core PyATS/Nornir path with production operational patterns:


πŸ“š What You'll LearnΒΆ

By completing these intermediate tutorials, you'll understand:

PyATS Path:

  • βœ… How Cisco tests network devices internally
  • βœ… Device parsing and structured data extraction
  • βœ… Building validation tests (compliance, configuration, health checks)
  • βœ… Pre-flight and post-flight validation patterns
  • βœ… Integrating PyATS into deployment workflows
  • βœ… Handling failures and automatic rollback

Decorator Foundations (Applies to All Paths):

  • βœ… How decorators solve cross-cutting concerns
  • βœ… Retry patterns for resilience
  • βœ… Logging and audit trails for compliance
  • βœ… Error handling and recovery
  • βœ… Rate limiting for safe scaling
  • βœ… Performance monitoring and optimization
  • βœ… Composing multiple decorators together

Nornir Path:

  • βœ… Why parallelization matters and how Nornir delivers it
  • βœ… Task-based architecture and reusable automation components
  • βœ… Nornir's inventory system and device grouping
  • βœ… Multi-device result aggregation and processing
  • βœ… Error handling and resilience at enterprise scale
  • βœ… Performance optimisation and benchmarking
  • βœ… Credential management and security best practices
  • βœ… How to architect systems for production deployment

Combined:

  • βœ… Deploy β†’ Validate β†’ Measure workflows
  • βœ… Automatic rollback on validation failure
  • βœ… PRIME Framework integration for sustainable automation

πŸ“‹ PrerequisitesΒΆ

Required KnowledgeΒΆ

  • βœ… Completed all Beginner Tutorials β€” You should understand Netmiko, multi-device loops, and Python functions
  • βœ… Comfortable with Python classes and object-oriented programming
  • βœ… Familiar with Python dictionaries and list comprehensions
  • βœ… Understanding of YAML file format (basic)
  • βœ… Familiar with structured data (dictionaries, nested structures)

Required SoftwareΒΆ

For the full series (PyATS + Nornir):

pip install pyats genie netmiko nornir nornir-netmiko nornir-utils pandas openpyxl pyyaml

For PyATS tutorials only:

pip install pyats genie netmiko pandas openpyxl

For Nornir tutorials only:

pip install nornir nornir-netmiko nornir-utils netmiko pandas openpyxl pyyaml

Required AccessΒΆ

  • Multiple Cisco devices (5+) with:
    • SSH enabled
    • Same credentials
    • Reachable from your workstation
    • Privilege level 15 (to read running configs)

Optional: Choose Your PathΒΆ

  • PyATS focused? Start with Tutorial #1 (PyATS Fundamentals)
  • Nornir focused? Start with Tutorial #4 (Why Nornir?)
  • Want the complete system? Follow tutorials 1-7 in order

πŸ“š Tutorial SeriesΒΆ

Foundation: Data Modeling for Network AutomationΒΆ

Master the three essential data formats before building complex automation systems.

Tutorial Series A: Data Modeling TrilogyΒΆ

A1. YAML Data Modeling β€” Human-Readable ConfigurationΒΆ

Learn the foundation of network automation data structures.

Learn:

  • YAML syntax fundamentals
  • Nornir inventory structure (hosts, groups, defaults)
  • PyATS testbed structure (devices, connections)
  • Configuration data modeling patterns
  • Common pitfalls and validation
  • Version control best practices

What You'll Build: Complete device inventory system with YAML files that work with Nornir and PyATS.

Why First: YAML is used by Nornir inventories, PyATS testbeds, and Ansible playbooksβ€”you need this for all subsequent tutorials.

Prerequisite: Completed Beginner tutorials and comfortable with Python dictionaries


A2. JSON Data Handling β€” API Interactions and Structured LoggingΒΆ

Master the data format for APIs, logging, and machine-to-machine communication.

Learn:

  • JSON syntax and differences from YAML
  • Consuming REST APIs with JSON responses
  • Generating JSON for API requests
  • Structured logging with JSON output
  • JSON Schema validation
  • Performance optimization for large datasets

What You'll Build: REST API client with structured logging and complete error handling.

Why Now: Modern network devices and controllers expose REST APIs that speak JSONβ€”essential for API-driven automation.

Prerequisite: Complete Tutorial A1 (YAML)


A3. Jinja2 Configuration Templates β€” Generate Configs from DataΒΆ

Transform structured data into device configurations automatically.

Learn:

  • Jinja2 template syntax (variables, conditionals, loops, filters)
  • Rendering templates with Python
  • Template inheritance and reusability
  • Advanced filters for network automation
  • Whitespace control for clean configs
  • Multi-device configuration generation

What You'll Build: Complete configuration generation system that produces device configs from YAML data and Jinja2 templates.

Why Now: Combines YAML/JSON data with templates to eliminate manual configuration errorsβ€”the core pattern of scalable automation.

Prerequisite: Complete Tutorials A1 and A2


Foundation: Python Patterns for Network AutomationΒΆ

B0. Decorators in Network Automation β€” Build Resilient, Observable SystemsΒΆ

Master the decorator pattern used throughout production automation.

Learn:

  • Why decorators matter in network automation
  • Automatic retry with exponential backoff
  • Audit logging for compliance
  • Unified error handling
  • Rate limiting for safe scaling
  • Performance monitoring and optimization
  • Composing multiple decorators
  • Integration with Nornir and PyATS

What You'll Build: Reusable decorators you'll use in every subsequent tutorialβ€”retry logic, audit logging, error handling, rate limiting, and performance monitoring.

Why Now: These patterns are foundational and used throughout the remaining tutorials. Understanding decorators first makes the PyATS and Nornir tutorials much clearer.

Prerequisite: Comfortable with Python functions and basic OOP


PyATS: Master Network ValidationΒΆ

1. PyATS Fundamentals β€” Why Cisco Trusts ItΒΆ

Understand PyATS and why Cisco runs millions of tests monthly with it.

Learn:

  • Why PyATS matters (Cisco's internal test framework)
  • Device connections and testbed configuration
  • Structured parsing with Genie
  • Writing simple validation tests
  • Integrating with the PRIME Framework

What You'll Build: A first validation test that parses device state and confirms changes succeeded.

Prerequisite: Complete Beginner tutorials and Tutorial #0 (Decorators)


2. PyATS Network Validation β€” Real-World Testing PatternsΒΆ

Master production validation patterns that catch real problems.

Learn:

  • Real device parsing (VLAN, interfaces, routing, BGP)
  • Compliance checking (required configurations, health checks)
  • Handling failures gracefully
  • Multi-device validation at scale
  • Timeout handling and error strategies

What You'll Build: A complete validation suite for VLAN compliance, interface health, and BGP neighbor checks.

Prerequisite: Complete Tutorial #1 above


3. Building Reliable Automation with PyATS β€” Deploy, Validate, RollbackΒΆ

Integrate PyATS into real deployment workflows.

Learn:

  • Netmiko + PyATS (configuration + validation)
  • Nornir + PyATS (parallel deployment + parallel validation)
  • Automatic rollback on validation failure
  • Pre-flight and post-flight patterns
  • PRIME Framework integration
  • Production deployment strategies

What You'll Build: A complete deployment workflow that safely rolls back if validation fails.

Prerequisite: Complete Tutorial #2 above


Nornir: Master Enterprise ScaleΒΆ

4. Why Nornir? β€” Understanding the Problem and SolutionΒΆ

Before we build, understand WHY Nornir matters.

Learn:

  • Why loops are a bottleneck (theoretical and practical)
  • Performance comparison: Sequential vs. Parallel
  • The limitations of Beginner Tutorial #3 approach
  • Nornir's architecture and core concepts
  • When to use Nornir vs. simpler scripts

What You'll Build: None yetβ€”pure understanding. But you'll benchmark your existing Beginner Tutorial #3 script and see concrete speedup numbers.

Prerequisite: Complete Beginner Tutorial #3 (Config Backup)


5. Nornir Fundamentals β€” Write Your First Production TaskΒΆ

Master the core concepts before tackling complex scenarios.

Learn:

  • Nornir installation and project structure
  • Inventory management (YAML format)
  • Task creation and the @task decorator
  • Running tasks against devices
  • Result processing and filtering
  • Logging at enterprise scale

What You'll Build: A parallel config backup script in ~60 lines of code that's 20x faster than Beginner Tutorial #3.

Prerequisite: Complete Tutorial #4 above


6. Enterprise Config Backup Deep Dive β€” Building a Real SystemΒΆ

Apply Nornir to the problem you already know: config backups.

Learn:

  • Advanced task composition
  • Multi-step workflows (backup β†’ validate β†’ report)
  • Database integration for backup metadata
  • Change detection and compliance checking
  • Complete production architecture
  • Performance optimisation

What You'll Build: A complete enterprise backup system with timestamped backups, change detection, database logging, and compliance scoring.

Prerequisite: Complete Tutorial #5 above


7. Advanced Nornir Patterns β€” Production-Grade ArchitectureΒΆ

Master the patterns used in real enterprise deployments.

Learn:

  • Custom inventory plugins
  • Middleware and execution pipelines
  • Advanced error handling and retry strategies
  • State management across tasks
  • Memory optimisation for large networks (10k+ devices)
  • Multi-vendor support and platform abstraction
  • Integrating with external systems (APIs, databases, message queues)
  • Testing and debugging Nornir tasks

What You'll Build: Reusable patterns and architectures you can apply to any enterprise automation problem.

Prerequisite: Complete Tutorial #6 above


πŸ”§ Setup RequirementsΒΆ

Before starting these tutorials:

1. Python EnvironmentΒΆ

1
2
3
4
5
6
7
8
# Create a virtual environment
python -m venv intermediate_env
source intermediate_env/bin/activate
# Windows PowerShell: .\intermediate_env\Scripts\Activate.ps1
# Windows CMD: intermediate_env\Scripts\activate.bat

# Install all required packages (PyATS + Nornir)
pip install pyats genie netmiko nornir nornir-netmiko nornir-utils pandas openpyxl pyyaml

2. Test DevicesΒΆ

You'll need at least 5 Cisco devices accessible via SSH. If you don't have a lab:

  • Use Cisco Devnet Always-On sandboxes (free)
  • Use Cisco modeling labs (CSR1000v virtual routers)
  • Use GNS3 or EVE-NG for local simulation

3. Verify InstallationΒΆ

1
2
3
python -c "from pyats.topology import loader; print('PyATS OK')"
python -c "from nornir import InitNornir; print('Nornir OK')"
python -c "import netmiko; print('Netmiko OK')"

4. Project StructureΒΆ

Create a directory for your Nornir projects:

1
2
3
4
5
6
7
8
9
my-nornir-project/
β”œβ”€β”€ inventory/
β”‚   β”œβ”€β”€ hosts.yaml      # Device inventory
β”‚   β”œβ”€β”€ groups.yaml     # Device groupings
β”‚   └── defaults.yaml   # Default settings
β”œβ”€β”€ tasks/
β”‚   └── my_tasks.py     # Your automation tasks
β”œβ”€β”€ configs/            # Where backups will be stored
└── nornir_config.yaml  # Nornir configuration

We'll build this structure in Tutorial #2.

πŸ’‘ How to Use These TutorialsΒΆ

  1. Start with Tutorial Series A: Data Modeling Trilogy β€” YAML, JSON, and Jinja2 form the foundation
  2. A1: YAML β†’ Device inventories and configuration files
  3. A2: JSON β†’ API interactions and structured logging
  4. A3: Jinja2 β†’ Template-driven configuration generation
  5. Continue with Tutorial B0: Decorators β€” Python patterns used throughout automation
  6. Choose your framework path:
  7. PyATS focused? Continue to Tutorial #1 (PyATS Fundamentals)
  8. Nornir focused? Skip to Tutorial #4 (Why Nornir?)
  9. Want it all? Follow tutorials in order (A1-A3 β†’ B0 β†’ 1-7)
  10. Read the "Why" sections first β€” Understand the problem before the solution
  11. Review complete working code β€” Copy and run each script in your lab
  12. Study the line-by-line breakdown β€” Learn exactly what each line does
  13. Experiment and modify β€” Change parameters, try different devices
  14. Build on the patterns β€” Use data modeling and framework patterns in your own automation

πŸŽ“ Learning PathΒΆ

graph LR
    A["Beginner Tutorials
(Fundamentals)"] --> B["Series A: Data Modeling
(YAML→JSON→Jinja2)"] B --> C["Tutorial B0: Decorators
(Python Patterns)"] C --> D["Series 1-3: PyATS
(Validation)"] C --> E["Series 4-7: Nornir
(Scale)"] D --> F["Tutorial 8: PyATS + Nornir
(Combined)"] E --> F F --> G["Ready for
Expert + Production"] style A fill:#90EE90 style B fill:#FFD700 style C fill:#DAA520 style D fill:#87CEEB style E fill:#87CEEB style F fill:#FFB6C1 style G fill:#FFD700

🎯 Connection to PRIME Framework¢

These tutorials align with the Implement stage of the PRIME Framework:

Philosophy Principles:

  • 🎯 Pragmatic: Nornir solves real problems (scale) with minimal overhead
  • πŸ” Transparent: Extensive logging and result processing for complete visibility
  • πŸ›‘οΈ Reliable: Built-in error handling, result aggregation, and validation patterns

Framework Application: When we move from tutorials to consulting engagements, Nornir becomes the foundation of the Implement stageβ€”delivering production automation at enterprise scale.


πŸ“Š What You'll AchieveΒΆ

After completing all 4 intermediate tutorials, you'll be able to:

Capability Before After
Max devices per script 50 (before slowness) 5,000+ (easily)
Config backup time 30+ minutes 3-5 minutes
Error visibility Per-device try/catch Unified result aggregation
Code reusability One-off scripts Composable tasks
Extensibility Hard to modify Plugins and middleware
Enterprise readiness Partial (manual scaling) Full (handles production issues)

Next Steps

Ready? Start with Tutorial A1: YAML Data Modeling to master the foundation of structured network automation data. Then continue with: - Tutorial A2: JSON Data Handling β€” APIs and structured logging - Tutorial A3: Jinja2 Templates β€” Configuration generation - Tutorial B0: Decorators β€” Python patterns After mastering data modeling and Python patterns, choose your framework path: - PyATS track? Continue to Tutorial #1: PyATS Fundamentals - Nornir track? Skip to Tutorial #4: Why Nornir?


πŸ†˜ TroubleshootingΒΆ

"I'm not sure if I'm ready for these tutorials" - Complete all Beginner Tutorials first - These tutorials assume you're comfortable with Python functions, loops, and basic OOP

"I don't have 5+ devices to practice with" - Use Cisco Devnet Always-On labs (free, no lab equipment needed) - Use GNS3 or EVE-NG with CSR1000v images - Virtual labs work perfectly for learning

"Nornir seems complex" - Yes, it's more complex than Beginner scriptsβ€”but the complexity is worth it - Tutorial #1 explains WHY complexity is justified - Each tutorial builds gradually; don't skip ahead


πŸ“– Additional ResourcesΒΆ


πŸ’¬ Questions or Feedback?ΒΆ

Found these tutorials helpful? Have questions about Nornir?

Contact us β€” We'd love to hear how you're using Nornir!


← Back to Tutorials | Continue to Tutorial 1 β†’