Introduction to Network Automation with Ansible
Why Use Ansible for Network Automation?
For network engineers looking to start with automation, Ansible provides a low barrier to entry while offering powerful capabilities for managing and configuring network infrastructure. It can help automate routine tasks, improve operational efficiency, and free up time for more strategic work. Ansible is easy to install and learn and whilst it’s written in Python only requires some basic understanding of YAML to write your first playbook.
What is NETCONF and How does it fit into Network Automation?
NETCONF, or Network Configuration Protocol, is a network management protocol designed to automate the configuration and management of network devices. It fits into network automation by providing a standardized method for delivering, modifying, and deleting configurations on network devices, which is essential for efficient network operations in modern environments.
Key Features of NETCONF
- Client-Server Architecture: NETCONF operates using a client-server model where the client (often a network management system) sends requests to the server (network devices) to perform configuration tasks.
- XML-Based Encoding: It uses XML for encoding configuration data and protocol messages, facilitating interoperability between devices from different vendors.
- Remote Procedure Calls (RPCs): NETCONF utilizes RPCs to communicate between clients and servers, allowing for precise control over configuration changes.
- Data Stores: NETCONF defines multiple configuration data stores, such as ‘running’, ‘startup’, and ‘candidate’, which help in managing configurations without impacting the current operational state.
- Transactional Capabilities: It supports transactional operations for configuration changes, ensuring that updates are applied consistently across devices.
- Security Features: NETCONF includes security mechanisms like authentication and authorization to ensure secure message transmission.
Advantages of NETCONF in Network Automation
- Automated Configuration Management: NETCONF allows for automated delivery and modification of device configurations, reducing manual errors and improving efficiency.
- Vendor Neutrality: Its use of XML and standardized APIs makes it suitable for multi-vendor environments, enhancing flexibility in diverse network setups.
- Enhanced Reliability: The transactional nature of NETCONF ensures reliable configuration changes, minimizing the risk of network outages due to misconfigurations.
- Support for Complex Networks: By enabling programmable control over network devices, NETCONF supports the automation needs of complex networks like data centers and service provider networks.
Overall, NETCONF plays a crucial role in modern network automation by providing a robust framework for managing network configurations efficiently and reliably.
Understanding NETCONF and YANG Models
The Role of YANG in Model-Driven Automation
YANG plays a crucial role in model-driven network automation by providing a standardized way to define and structure network device configurations and operational data. Here are the key aspects of YANG’s role in model-driven automation:
Data Modeling Language
YANG serves as a data modeling language specifically designed for network devices and protocols. It allows for the creation of structured, hierarchical models that describe:
- Configuration data
- Operational state data
- Remote procedure calls (RPCs)
- Notifications
These models provide a clear and consistent representation of network device capabilities and data.
Enabling Programmatic Interfaces
YANG models enable the use of programmatic interfaces for network management, such as:
- NETCONF (Network Configuration Protocol)
- RESTCONF
- gRPC/gNMI (gRPC Network Management Interface)
These protocols use YANG models to define the structure and semantics of the data exchanged between network devices and management systems.
Standardization and Interoperability
YANG promotes standardization across different vendors and network devices:
- Vendors can create YANG models for their specific devices
- Standard YANG models (e.g., IETF, OpenConfig) provide a common language for network automation
- This standardization facilitates interoperability and consistency in multi-vendor environments12
Automation Benefits
The use of YANG in model-driven automation offers several advantages:
- Improved reliability: Structured data models reduce errors in configuration and data retrieval.
- Increased scalability: Standardized models allow for more efficient automation across large networks.
- Enhanced programmability: YANG models provide a clear interface for developers to interact with network devices.
- Real-time data collection: YANG-based telemetry enables streaming of operational data for analytics and monitoring.
Supporting Network Programmability
YANG models support various aspects of network programmability:
- Configuration management: Defining and applying network configurations consistently.
- State retrieval: Gathering operational data from devices in a structured format.
- Telemetry: Enabling real-time streaming of network statistics and state information.
- Service modeling: Describing network services at a higher level of abstraction.
Facilitating DevOps and NetOps
YANG models play a crucial role in enabling DevOps and NetOps practices in networking:
- They allow for version control of network configurations
- Support infrastructure-as-code practices
- Enable automated testing and validation of network changes2
In conclusion, YANG is fundamental to model-driven network automation, providing a standardized, vendor-neutral approach to describing network device capabilities and data. This standardization enables more efficient, reliable, and scalable network automation practices across diverse network environments.
How NETCONF and YANG Work Together for Configuration Management
NETCONF and YANG work together to provide a powerful framework for network configuration management. Here’s an overview of how they complement each other:
NETCONF: The Protocol
NETCONF serves as the communication protocol for network device configuration:
- Client-Server Model: NETCONF operates using a client-server architecture, where the client (typically a management system) communicates with the server (network device).
- XML-Based Communication: It uses XML for encoding configuration data and protocol messages, facilitating standardized communication.
- RPC Mechanism: NETCONF employs Remote Procedure Calls (RPCs) for interaction between clients and servers1.
- Configuration Operations: It provides operations like <get>, <get-config>, <edit-config>, <copy-config>, and <delete-config> for managing device configurations.
- Data Stores: NETCONF defines multiple configuration datastores (running, candidate, startup) for managing configurations.
YANG: The Data Modeling Language
YANG complements NETCONF by providing a standardized way to model network device data:
- Data Modeling: YANG is used to create structured, hierarchical models that describe configuration and operational data of network devices.
- Standardization: It offers a consistent way to represent device capabilities and data across different vendors.
- Validation: YANG models provide rules for data validation, ensuring that only valid configurations are applied to devices.
How They Work Together
- Model-Driven Approach: NETCONF uses YANG models to understand the structure and semantics of the data being exchanged.
- Configuration Validation: When a NETCONF client sends a configuration request, the server uses YANG models to validate the request before applying it.
- Structured Data Exchange: YANG models provide a clear structure for the data exchanged via NETCONF, making it easier to automate configuration tasks.
- Capability Negotiation: During the initial NETCONF connection, devices exchange capabilities, including supported YANG models, ensuring compatibility.
- Extensibility: Vendors can define custom YANG models for proprietary features while still using the standard NETCONF protocol for communication.
Benefits of the NETCONF/YANG Combination
- Improved Reliability: The structured nature of YANG models and NETCONF’s transactional capabilities reduce configuration errors.
- Vendor Neutrality: Standardized models allow for consistent configuration across multi-vendor networks.
- Automation: The programmatic interface provided by NETCONF and the clear structure of YANG models facilitate network automation.
- Scalability: The model-driven approach allows for efficient management of large-scale networks.
By leveraging NETCONF as the transport protocol and YANG for data modeling, network operators can achieve more reliable, efficient, and automated configuration management across their network infrastructure.
Setting Up a Lab Environment for Nokia Routers
Using Real Hardware vs. Virtualized Environments
Setting Up Nokia Routers in a Virtual Lab Using Containerlab
ContainerLab is an open source container orchestration tool for easily spinning up network automation labs, developed by Roman Dodin from Nokia
Configuring NETCONF on Nokia Routers
Ansible Basics for Network Automation
What is Ansible?
Key Concepts in Ansible for Network Automation
Using Ansible Collections for Network Devices
Getting Started with NETCONF on Nokia Routers Using Ansible
Automating Network Configurations with Ansible and NETCONF on Nokia Routers is a process which is not highly documented, compared to performing NETCONF tasks on Cisco routers for example. Hopefully this post will provide a reference point with all my knowledge on one page which should help someone!
Installing Ansible and Required Collections
Configuring Ansible to Connect to Nokia Routers Over NETCONF
A Simple Playbook to Retrieve Configuration via NETCONF
Working with YANG Models for Nokia Routers
Understanding YANG Models and Their Role in Device Configuration
Retrieving and Interpreting YANG Models for Nokia Routers
Writing Configuration Using YANG Models in Ansible Playbooks
Writing Ansible Playbooks for Nokia Routers
Automating Basic Configuration Tasks (e.g., Interface Configuration)
Example Playbook: Configuring Interfaces on Nokia Routers
Using Templates for Reusable and Scalable Playbooks
Leveraging the Nokia.sros Ansible Collection
What is the Nokia.sros Collection?
Installing and Using the Nokia.sros Collection
Automating Advanced Configurations with Pre-built Roles
Troubleshooting and Best Practices
Debugging NETCONF Connections with Ansible
Handling Errors in Playbooks
Best Practices for Network Automation with Ansible and NETCONF
Additional Resources
Recommended Documentation and Guides
network.developer.nokia.com/sr/learn/sr-os-ansible
docs.ansible.com/ansible/latest/collections/community/network/sros_config_module.html
Leave a Reply