Use iosxr cliconf to run command on Cisco IOS XR platform
Version added: 1.0.0
- This iosxr plugin provides low level abstraction apis for sending and receiving CLI commands from Cisco IOS XR network devices.
Note
- IOSXR commit confirmed command varies with IOSXR version releases, commit_comment and commit_label may or may not be valid together as per the device version.
# Use commit confirmed within a task with timeout, label and comment
- name: Commit confirmed with a task
vars:
ansible_iosxr_commit_confirmed: True
ansible_iosxr_commit_confirmed_timeout: 50
ansible_iosxr_commit_label: TestLabel
ansible_iosxr_commit_comment: I am a test comment
cisco.iosxr.iosxr_logging_global:
state: merged
config:
buffered:
severity: errors #alerts #informational
correlator:
buffer_size: 2024
# Commands (cliconf specific)
# ["commit confirmed 50 label TestLabel comment I am a test comment"]
# Use commit within a task with label
- name: Commit label with a task
vars:
ansible_iosxr_commit_label: lblTest
cisco.iosxr.iosxr_hostname:
state: merged
config:
hostname: R1
# Commands (cliconf specific)
# ["commit label lblt1"]
# Use commit confirm with timeout and confirm the commit
# NOTE - IOSXR waits for a `commit` when the command
# executed is `commit confirmed <timeout>` within the timeout
# period for the config to commit successfully, else a rollback
# happens.
- name: Example commit confirmed
vars:
ansible_iosxr_commit_confirmed: True
ansible_iosxr_commit_confirmed_timeout: 60
tasks:
- name: "Commit confirmed with timeout"
cisco.iosxr.iosxr_hostname:
state: merged
config:
hostname: R1
- name: "Confirm the Commit"
cisco.iosxr.iosxr_command:
commands:
- commit
# Commands (cliconf specific)
# ["commit confirmed 60"]
# Use exclusive mode with a task
- name: Configure exclusive mode with a task
vars:
ansible_iosxr_config_mode_exclusive: True
cisco.iosxr.iosxr_interfaces:
state: merged
config:
- name: GigabitEthernet0/0/0/2
description: Configured via Ansible
- name: GigabitEthernet0/0/0/3
description: Configured via Ansible
# Commands (cliconf specific)
# ["configure exclusive"]
# Use Replace option with commit confirmed
# NOTE - IOSXR waits for a `commit` when the command
# executed is `commit replace confirmed <timeout>` within the timeout
# period for the config to commit successfully, else a rollback
# happens.
# This option is supported by only iosxr_config module
- name: Example replace config with commit confirmed
vars:
ansible_iosxr_commit_confirmed: True
ansible_iosxr_commit_confirmed_timeout: 60
tasks:
- name: "Replace config with Commit confirmed"
cisco.iosxr.iosxr_config:
src: 'replace_running_cfg_iosxr.txt'
replace: config
- name: "Confirm the Commit"
cisco.iosxr.iosxr_command:
commands:
- commit
- Ansible Networking Team (@ansible-network)
Hint
Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up.