我正在尝试在Ansible上运行netconf。我已经通过pip3安装了ncclient,也通过Ansible-galaxy安装了netcommon。如果我做一个Ansible-galaxy列表,netcommon就会出现在列表中。我的ansible版本说它运行的是Python3.9,pip3说它也安装在3.9上。当我运行一个示例攻略时,我一直收到"the connection plugin 'ansible_connection: ansible.netcommon.netconf‘I not found“的提示,我遗漏了什么?
root@3d99d84253c9:/app/app# cat /etc/ansible/ansible.cfg
[defaults]
host_key_checking = False
[ssh_connection]
-C -o ControlMaster=auto -o ControlPersist=60s -c aes128-cbc
root@3d99d84253c9:/app/app#
root@3d99d84253c9:/app/app# ansible --version
ansible [core 2.11.6]
config file = /etc/ansible/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python3.9/site-packages/ansible
ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/local/bin/ansible
python version = 3.9.7 (default, Oct 12 2021, 02:54:29) [GCC 8.3.0]
jinja version = 3.0.2
libyaml = True
root@3d99d84253c9:/app/app#
root@3d99d84253c9:/app/app# cat test.yaml
---
- hosts: iosxr
vars:
become: no
ignore_unreachable: true
gather_facts: false
pre_tasks:
roles:
tasks:
- name: run command with json formatted output
ansible.netcommon.cli_command:
command: show version | json
root@3d99d84253c9:/app/app#
root@3d99d84253c9:/app/app# ansible-playbook -i inventory test.yaml
PLAY [iosxr] **************************************************************************************************************************************************************************************
TASK [run command with json formatted output] *****************************************************************************************************************************************************
fatal: [ATL_isr_lab]: FAILED! => {"msg": "the connection plugin 'ansible_connection: ansible.netcommon.netconf' was not found"}
fatal: [LAX_isr_lab]: FAILED! => {"msg": "the connection plugin 'ansible_connection: ansible.netcommon.netconf' was not found"}
PLAY RECAP ****************************************************************************************************************************************************************************************
ATL_isr_lab : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
LAX_isr_lab : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
发布于 2021-11-08 23:44:30
找到我的问题了。我必须先在路由器上启用netconf。一旦我这样做了,这个剧本就开始起作用了。
https://stackoverflow.com/questions/69886195
复制相似问题