首页 > 解决方案 > 在 ansible 剧本中使用 netconf_get

问题描述

我正在通过 Ansible 使用 netconf 进行测试,并且在运行 playbook 时不断收到此错误:

ansible.module_utils.connection.ConnectionError: AuthenticationException('Authentication timeout.',)

我可以通过端口 830 使用 ssh 从脚本服务器连接到我的 Cisco 设备:ssh cisco@10.1.1.1 -p 830 -s netconf

这是剧本:

---
- name: My Playbook
  hosts: 'my_host'
  gather_facts: false
    
  tasks:
  - name: Execute the get_config RPC
    netconf_get:
      display: json
    register: result
  - name: Print the configuration as JSON
    debug:
      var: result.output

库存是这样的:

[my_lab:children]
my_lab_iosxr

[my_lab:vars]
look_for_keys = False
host_key_checking  = False
ansible_ssh_pass = 'cisco'
ansible_user = 'cisco'

[my_lab_iosxr]
my_host ansible_host=10.1.1.1 ansible_network_os=iosxr ansible_connection=netconf

我应该补充一点,在尝试上述播放时,我在 cisco 设备的控制台上看到了这个错误:

9 月 8 日 17:37:42.218 UTC:SSHD_[67398]:%SECURITY-SSHD-3-ERR_GENERAL:无法接收用户身份验证请求

标签: ansiblenetconf

解决方案


看起来我已经找到了自己问题的答案。

我决定只用 python 编写我自己的 netconf 模块,但我遇到了同样的错误。

所以我转而使用安装在另一台机器上的 python 并且相同的代码可以工作。

似乎该服务器上安装的python版本存在问题......


推荐阅读