cisco.iosxr.iosxr cliconf – 使用 iosxr cliconf 在 Cisco IOS XR 平台上运行命令
注意
此 cliconf 插件是 cisco.iosxr 集合 (版本 10.2.2) 的一部分。
如果您使用的是 ansible
包,则可能已安装此集合。它不包含在 ansible-core
中。要检查它是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用: ansible-galaxy collection install cisco.iosxr
。
要在剧本中使用它,请指定: cisco.iosxr.iosxr
。
cisco.iosxr 1.0.0 中的新增功能
概要
此 iosxr 插件提供用于从 Cisco IOS XR 网络设备发送和接收 CLI 命令的低级抽象 API。
参数
参数 |
注释 |
---|---|
启用或禁用已确认提交模式 选项
配置
|
|
以秒或分钟为单位指定的时间内试运行提交配置。 配置
|
|
指定可以对目标设备进行配置更改的命令列表。 启用 `ansible_network_single_user_mode` 时,如果发送到设备的命令存在于此列表中,则现有缓存将失效。 默认值: 配置
|
|
启用或禁用独占配置模式 选项
配置
|
注释
注意
IOSXR 已确认提交命令随 IOSXR 版本而变化,根据设备版本,commit_comment 和 commit_label 可能有效,也可能无效。
示例
# 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