CNOS 平台选项
CNOS 是 community.network
专辑的一部分,支持 enable
模式(权限提升)。本页提供了如何在 Ansible 中使用 CNOS enable
模式的详细说明。
译注:Cloud Network Operating System, CNOS 平台是联想 LENOVO 交换机搭载的操作系统平台。Enterprise Networking Operating System, ENOS 是联想 LENOVO 的另一交换机操作系统平台。二者都是基于 Yotoco 项目。
-- “CNOS 提供可靠、开放和可编程的网络基础架构,可根据您的业务需求进行扩展网络基础设施。其智能的云规模性能可提供软件定义的以太网解决方案,使用通用管理工具即可轻松管理和部署。管理,使用通用管理工具即可轻松部署。CNOS 基于行业标准,可实现数据中心内更好的支持自动化和协调应用,从而在数据中心内实现更好的互操作性。与数据中心生态系统紧密集成。”
由于无法在 GNS3 中运行虚拟的 CNOS/ENOS 交换机,因此译者无法完成对这些设备的实验。
参考:
可用连接
CLI | |
---|---|
协议 | SSH |
凭据 | 在存在 SSH 密钥/ ssh-agent 时使用 SSH 密钥/ssh-agent ,在使用密码时接受 -u my_user -k 参数 |
间接访问 | 通过堡垒机(跳转主机) |
连接设置 | ansible_connection: ansible.netcommon.network_cli |
enable 模式(权限提升) | 受支持的:与 ansible_become_method: enable 及 ansible_become_password: 一起使用 ansible_become: true |
返回数据格式 | stdout[0]. |
ansible_connection: local
已被弃用。请使用 ansible_connection: ansible.netcommon.network_cli
代替。
在 Ansible 中使用 CLI
示例的 CLI
group_vars/cnos.yml
ansible_connection: ansible.netcommon.network_cli
ansible_network_os: community.network.cnos
ansible_user: myuser
ansible_password: !vault...
ansible_become: true
ansible_become_method: enable
ansible_become_password: !vault...
ansible_ssh_common_args: '-o ProxyCommand="ssh -W %h:%p -q bastion01"'
- 若咱们使用的是 SSH 密钥(包括
ssh-agent
),则可以移除ansible_password
配置项; - 若咱们直接访问的主机(不通过堡垒机/跳转主机),则可移除
ansible_ssh_common_args
配置项; - 若咱们通过堡垒机/跳转主机访问咱们的主机,则咱们不能在
ProxyCommand
指令中包含咱们的 SSH 密码。为防止秘密外泄(例如在ps
的输出中),SSH 不支持使用环境变量提供密码。
示例 CLI
任务
- name: Retrieve CNOS OS version
community.network.cnos_command:
commands: show version
when: ansible_network_os == 'community.network.cnos'
警告:
切勿以明文方式存储密码。我们建议使用 SSH 密钥验证 SSH 连接。Ansible 支持
ssh-agent
来管理 SSH 密钥。如果必须使用密码来验证 SSH 连接,建议使用 Ansible Vault 对密码进行加密。
(End)