community.network.cnos_rollback 模块 – 在运行 Lenovo CNOS 的设备上从远程服务器回滚运行或启动配置

注意

此模块是 community.network 集合 (版本 5.1.0) 的一部分。

如果您使用的是 ansible 包,您可能已经安装了此集合。它不包含在 ansible-core 中。要检查是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用:ansible-galaxy collection install community.network

要在 playbook 中使用它,请指定:community.network.cnos_rollback

注意

community.network 集合已弃用,并将从 Ansible 12 中删除。有关更多信息,请参阅讨论主题

已弃用

在以下版本中删除:

版本 6.0.0

原因:

此集合及其中的所有内容均未维护且已弃用。

替代方案:

未知。

概要

  • 此模块允许您使用交换机配置。它提供了一种从远程服务器回滚交换机配置的方法。这是通过使用目标设备的启动或运行配置来实现的,这些配置先前已使用 FTP、SFTP、TFTP 或 SCP 备份到远程服务器。第一步是创建一个可以从远程服务器访问的目录。下一步是提供备份配置位置的完整文件路径。还必须提供远程服务器所需的身份验证详细信息。默认情况下,此方法使用新下载的文件覆盖交换机的配置文件。此模块使用 SSH 来管理网络设备配置。操作的结果将放置在名为“results”的目录中,该目录必须由用户在运行 playbook 的本地目录中创建。

别名:network.cnos.cnos_rollback

参数

参数

注释

configType

字符串 / 必选

这指的是将用于回滚过程的配置类型。选项是运行配置或启动配置。没有默认值,因此如果输入不正确,将导致错误。

选项

  • "running-config"

  • "startup-config"

deviceType

字符串 / 必选

这指定了执行该方法的设备类型。自 Ansible 2.4 起添加了选项 NE1072T、NE1032、NE1032T、NE10032、NE2572。自 2.8 起添加了选项 NE0152T。

选项

  • "g8272_cnos"

  • "g8296_cnos"

  • "g8332_cnos"

  • "NE0152T"

  • "NE1072T"

  • "NE1032"

  • "NE1032T"

  • "NE10032"

  • "NE2572"

enablePassword

字符串

配置用于在交换机上进入全局配置命令模式的密码。如果交换机不请求此密码,则忽略该参数。虽然通常该值应来自清单文件,但您也可以将其指定为变量。此参数是可选的。如果未指定,则不会使用默认值。

host

字符串 / 必选

这是用于搜索 /etc/ansible/hosts 中的 hosts 文件并识别要应用模板的设备的 IP 地址的变量。通常,Ansible 关键字 {{ inventory_hostname }} 在 playbook 中指定,作为需要配置的网络元素组的抽象。

outputfile

字符串 / 必选

这指定了保存每个命令执行的输出的文件路径。在此处保存合并的模板文件中指定的每个命令以及来自设备的每个响应。通常,位置是 results 文件夹,但您可以根据您的写入权限选择另一个位置。

password

字符串 / 必选

配置用于对远程设备的连接进行身份验证的密码。password 参数的值用于对 SSH 会话进行身份验证。虽然通常该值应来自清单文件,但您也可以将其指定为变量。此参数是可选的。如果未指定,则不会使用默认值。

protocol

字符串 / 必选

这指的是网络设备用于与远程服务器交互以下载备份配置的协议。选项是 FTP、SFTP、TFTP 或 SCP。任何其他协议都将导致错误。如果未指定此参数,则没有要使用的默认值。

选项

  • "SFTP"

  • "SCP"

  • "FTP"

  • "TFTP"

rcpath

字符串 / 必选

这指定了位于远程服务器上的配置文件的完整文件路径。如果使用相对路径作为变量值,则需要指定服务器用户的根文件夹。

rcserverip

字符串 / 必选

这指定了将从中下载备份配置的远程服务器的 IP 地址。

serverpassword

字符串 / 必选

指定与所用协议相关的服务器密码。

serverusername

字符串 / 必选

指定与所用协议相关的服务器用户名。

username

字符串 / 必选

配置用于验证与远程设备连接的用户名。username 参数的值用于验证 SSH 会话。虽然通常该值应来自清单文件,但您也可以将其指定为变量。此参数是可选的。如果未指定,则不会使用默认值。

注释

注意

示例

Tasks : The following are examples of using the module cnos_rollback.
 These are written in the main.yml file of the tasks directory.
---

- name: Test Rollback of config - Running config
  cnos_rolback:
      deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}"
      outputfile: "./results/test_rollback_{{ inventory_hostname }}_output.txt"
      configType: running-config
      protocol: "sftp"
      serverip: "10.241.106.118"
      rcpath: "/root/cnos/G8272-running-config.txt"
      serverusername: "root"
      serverpassword: "root123"

- name: Test Rollback of config - Startup config
  cnos_rolback:
      deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}"
      outputfile: "./results/test_rollback_{{ inventory_hostname }}_output.txt"
      configType: startup-config
      protocol: "sftp"
      serverip: "10.241.106.118"
      rcpath: "/root/cnos/G8272-startup-config.txt"
      serverusername: "root"
      serverpassword: "root123"

- name: Test Rollback of config - Running config - TFTP
  cnos_rolback:
      deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}"
      outputfile: "./results/test_rollback_{{ inventory_hostname }}_output.txt"
      configType: running-config
      protocol: "tftp"
      serverip: "10.241.106.118"
      rcpath: "/anil/G8272-running-config.txt"
      serverusername: "root"
      serverpassword: "root123"

- name: Test Rollback of config - Startup config - TFTP
  cnos_rolback:
      deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}"
      outputfile: "./results/test_rollback_{{ inventory_hostname }}_output.txt"
      configType: startup-config
      protocol: "tftp"
      serverip: "10.241.106.118"
      rcpath: "/anil/G8272-startup-config.txt"
      serverusername: "root"
      serverpassword: "root123"

返回值

通用返回值在此处记录此处,以下是此模块特有的字段

描述

msg

字符串

成功或失败消息

返回: 总是

示例: "配置 文件 已传输到 设备"

状态

  • 此模块将在 6.0.0 版本中删除。[已弃用]

  • 有关更多信息,请参阅已弃用

作者

  • Anil Kumar Muraleedharan (@amuraleedhar)