找不到连接插件 'ansible_connection: ansible.netcommon.netconf'
the connection plugin 'ansible_connection: ansible.netcommon.netconf' was not found
我正在尝试通过 Ansible 运行 netconf。我已经通过 pip3 安装了 ncclient,通过 Ansible-galaxy 安装了 netcommon。如果我执行 Ansible-galaxy 列表,netcommon 会出现在列表中。我的 ansible 版本说它是 运行ning 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
错误信息是the connection plugin 'ansible_connection: ansible.netcommon.netconf' was not found
。这表示您在某处有 ansible_connection: "ansible_connection: ansible.netcommon.netconf"
或等效项。您应该删除无关的 ansible_connection:
.
找到我的问题。我必须先在路由器上启用 netconf。一旦我这样做了,剧本就开始工作了。
我正在尝试通过 Ansible 运行 netconf。我已经通过 pip3 安装了 ncclient,通过 Ansible-galaxy 安装了 netcommon。如果我执行 Ansible-galaxy 列表,netcommon 会出现在列表中。我的 ansible 版本说它是 运行ning 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
错误信息是the connection plugin 'ansible_connection: ansible.netcommon.netconf' was not found
。这表示您在某处有 ansible_connection: "ansible_connection: ansible.netcommon.netconf"
或等效项。您应该删除无关的 ansible_connection:
.
找到我的问题。我必须先在路由器上启用 netconf。一旦我这样做了,剧本就开始工作了。