The Ansible nokia.sros collection provides CLI and NETCONF plugins for Nokia SR OS devices.
These plugins act as device drivers enabling the use of Ansible networking modules such as cli_config and cli_command from the ansible.netcommon collection.
The collection also provides device information and capability discovery.
This project is a Nokia-initiated open-source effort, licensed under the BSD 3-Clause License, designed to promote programmable network automation using standard IT tools. We welcome contributions from the community — including tutorials, real-world playbook examples, feature requests, bug reports, or code enhancements.
Notes
- Ansible collections are distributed via Ansible Galaxy.
- For Nokia SR Linux and data-center switches, use the
nokia.srlinuxcollection.- For OpenConfig gNMI-based automation, use the
nokia.grpccollection.
-
Python 3.11 or newer
-
Python libraries:
-
Ansible Core 2.13 or newer
Tested with SR OS 25.7. Other versions may work but have not been explicitly validated.
Use the following recipe to create a ready-to-use virtual environment for SR OS Ansible automation:
python -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install ansible-core ansible-pylibssh jxmlease ncclient
ansible-galaxy collection install ansible.netcommon nokia.sros --force-with-depsIn your Ansible inventory, specify the network OS for your SR OS hosts:
ansible_network_os: nokia.sros.<mode>Where <mode> can be md, classic, or light.
Detailed tutorials are available on the Nokia Network Developer Portal.
This repository contains sample playbooks demonstrating how to use the collection. They can also serve as regression tests.
- sros_classic_cli_command_demo.yml
- sros_classic_cli_config_demo.yml
- sros_classic_cli_backup_restore_demo.yml
The module nokia.sros.device_info retrieves information about the connected SR OS device.
It works with both CLI and NETCONF connections.
Example output:
output:
network_os: "nokia.sros.classic"
network_os_hostname: "Antwerp"
network_os_model: "7750 SR-12"
network_os_platform: "Nokia 7x50"
network_os_version: "B-19.5.R2"
sros_config_mode: "classic"None.
| Network OS | terminal | cliconf | netconf |
|---|---|---|---|
| nokia.sros.md | ✅ | ✅ | ✅ |
| nokia.sros.classic | ✅ | ✅ | – |
| nokia.sros.light | ✅ | ✅ | – |
In Classic CLI mode, the plugin leverages the SR OS built-in rollback feature. Ensure that rollback storage is properly configured, for example:
A:Antwerp# file md cf3:/rollbacks
*A:Antwerp# configure system rollback rollback-location cf3:/rollbacks/config
INFO: CLI No checkpoints currently exist at the rollback location.
*A:Antwerp# admin rollback save
Saving rollback configuration to cf3:/rollbacks/config.rb... OK
*A:Antwerp#
Note Use
nokia.sros.lightfor nodes that do not support rollback or where rollback usage is undesired.
- A temporary rollback checkpoint is created at the start of each
cli_configoperation. - If a configuration error occurs, the plugin reverts to the pre-operation checkpoint (rollback-on-error).
- If successful, the plugin compares the new configuration to the previous checkpoint to populate
changedanddiffresults. - With the
--check(dry-run) option, configuration changes are applied, validated, and then immediately rolled back — providing syntax checks and diff output. - After completion, the temporary checkpoint is deleted to keep rollback history clean.
⚠️ Warnings
- Dry-run temporarily activates configuration changes before rolling them back. Be aware that this can cause brief service impact.
rollback-on-errormay have side effects on modules such as BGP within VPRNs, which revert to default state (shutdown) before rollback is applied. Refer to the Basic System Configuration Guide for details.
- Some platforms may not support checkpoint/rollback.
- All changes are written directly to the running configuration.
- Operation type
replaceis not supported. - The oldest rollback checkpoint may be deleted after plugin execution.
The Light Mode (nokia.sros.light) is a simplified CLI implementation used when rollback is not available or not desired.
It determines configuration changes based on the prompt change indicator (appearance of * in the prompt).
- If the device already has unsaved changes before a task runs, the playbook will treat it as
changed. --diffand--checkmodes are not supported.
