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:
- PyATS β Master network device validation and testing (Cisco's enterprise test framework used internally with millions of tests monthly)
- 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:
- YAML Data Modeling β Human-readable configuration files, device inventories (Nornir, PyATS)
- JSON Data Handling β API interactions, structured logging, REST APIs
- Jinja2 Configuration Templates β Generate device configs from data, eliminate copy-paste errors
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:
- Testing Automation Scripts
- Credential Management for Network Automation
- Error Recovery and Rollback
- State Management and Idempotency
- Structured Logging for Network Automation
- Health Checks and Pre-Flight Validation
π 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):
For PyATS tutorials only:
For Nornir tutorials only:
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
@taskdecorator - 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ΒΆ
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ΒΆ
4. Project StructureΒΆ
Create a directory for your Nornir projects:
We'll build this structure in Tutorial #2.
π‘ How to Use These TutorialsΒΆ
- Start with Tutorial Series A: Data Modeling Trilogy β YAML, JSON, and Jinja2 form the foundation
- A1: YAML β Device inventories and configuration files
- A2: JSON β API interactions and structured logging
- A3: Jinja2 β Template-driven configuration generation
- Continue with Tutorial B0: Decorators β Python patterns used throughout automation
- Choose your framework path:
- PyATS focused? Continue to Tutorial #1 (PyATS Fundamentals)
- Nornir focused? Skip to Tutorial #4 (Why Nornir?)
- Want it all? Follow tutorials in order (A1-A3 β B0 β 1-7)
- Read the "Why" sections first β Understand the problem before the solution
- Review complete working code β Copy and run each script in your lab
- Study the line-by-line breakdown β Learn exactly what each line does
- Experiment and modify β Change parameters, try different devices
- 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ΒΆ
- Nornir Official Docs β Authoritative reference
- Nornir Community β GitHub repository
- Netmiko Documentation β For device connections
- Network to Code Blog β Real-world Nornir examples
π¬ Questions or Feedback?ΒΆ
Found these tutorials helpful? Have questions about Nornir?
Contact us β We'd love to hear how you're using Nornir!