我正在尝试通过 Ansible 运行 netconf。我已经通过 pip3 安装了 ncclient 以及通过 Ansible-galaxy 安装了 netcommon。如果我做一个 Ansible-galaxy 列表,netcommon 就会出现在列表中。我的 ansible 版本说它正在运行 python 3.9,而 pip3 说它也将它安装在 3.9 上。当我运行示例剧本时,我不断收到“找不到连接插件'ansible_connection:ansible.netcommon.netconf'”我错过了什么?
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