ansible - Cisco Nexus 的 Ansible 手册因提供商中的 nxapi 而失败
问题描述
我无法让这本剧本发挥作用。我正在尝试使用“nxapi”提供程序方法。我在目标设备上设置了 nxapi。我有一个包含以下设置的 group_vars 文件:
ansible_connection: local
ansible_network_os: nxos
ansible_user: user
ansible_password: password
剧本代码是:
- name: nxos_facts module
hosts: "{{ myhosts }}"
vars:
ssh:
host: "{{ myhosts }}"
username: "{{ ansible_user }}"
password: "{{ ansible_password }}"
transport: cli
nxapi:
host: "{{ myhosts }}"
username: "{{ ansible_user }}"
password: "{{ ansible_password }}"
transport: nxapi
use_ssl: yes
validate_certs: no
port: 8443
tasks:
- name: nxos_facts nxapi
nxos_facts:
provider: "{{ nxapi }}"
When I debug the failed playbook, I see this line:
ESTABLISH LOCAL CONNECTION FOR USER: < MY USER NAME >
It seems like the Playbook is not using the variables in the group_vars file , which specify a specific user to connect to the nxapi service on the switch.
解决方案
由于缺少代表,无法添加评论
确保您的 group_vars 与主机文件中的子组匹配。(不能从你的问题中看出)
主机文件:
all:
hosts:
SWITCH1:
ansible_host: 192.168.1.1
children:
group1:
hosts:
SWITCH1:
然后,您可以将 Group 变量放在 2 个文件之一中,all.yml或group1.yml
推荐阅读
- python - 在 Django 中进行硒测试后,数据库仍在使用中
- java - 同一对象上多个同步的开销
- asp.net-web-api - 有没有办法检测未记录的 REST WEB API
- r - 绘制R中各种分布曲线下的面积
- javascript - 继续发送字符串而不破坏此 NPM 库的更改
- excel - 多个条件最大值的 Excel 求和
- c - 如何使用 scanf 和打印目录(如终端)仅检测新行输入
- python - 如何使此网络配置代码适用于许多设备?
- express - 从另一个文件夹开始时,如何让 express static 工作
- encryption - Laravel 5.7:openssl_cipher_iv_length():未知密码算法