python-3.x - connect() 得到了一个意外的关键字参数 'sock'
问题描述
尝试连接到路由器时出现以下错误,并且我正在运行最新版本的 Paramiko。什么可能导致此错误,是否有任何解决方法?
更新:它的简单脚本使用 ansible 来收集“显示系统正常运行时间”命令输出。
我有清单文件,其中包含路由器的 IP 地址
$ cat uptime.yaml
---
- name: Get device uptime
hosts:
- all
connection: local
gather_facts: no
vars_prompt:
- name: username
prompt: UsernName
private: no
- name: password
prompt: Password
private: yes
tasks:
- name: get uptime using ansible moduel
junos_command:
commands:
- show system uptime
provider:
host: "{{ansible_host}}"
port: 22
username: "{{ username }}"
password: "{{ password }}"
>>> print(paramiko.__version__)
2.7.2
[DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the controller starting with Ansible 2.12. Current version: 3.6.9 (default, Jan 26 2021, 15:33:00) [GCC 8.4.0]. This feature
will be removed from ansible-core in version 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
UsernName: regress
Password:
PLAY [Get device uptime] ************************************************************************************************************************************************************************
TASK [get uptime using ansible moduel] **********************************************************************************************************************************************************
[WARNING]: ['connection local support for this module is deprecated and will be removed in version 2.14, use connection ansible.netcommon.netconf']
fatal: [R1_re0]: FAILED! => {"changed": false, "msg": "connect() got an unexpected keyword argument 'sock'"}
fatal: [R2_re0]: FAILED! => {"changed": false, "msg": "connect() got an unexpected keyword argument 'sock'"}
PLAY RECAP **************************************************************************************************************************************************************************************
R1_re0 : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
R2_re0 : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
解决方案
推荐阅读
- c# - 使用 TPL 数据流对持续时间或阈值进行批处理
- html - css height 100% 并不总是等于直接父级
- javascript - Javascript 对象和类
- android - 创建查询以获取等于当前用户 ID 的值
- sql-server - 尝试使用 XML 节点从 XML 中提取 IP
- amazon-web-services - AWS CodeBuild golang 构建失败
- javascript - 拉拉维尔。将 Js 函数从刀片移动到资源/js
- sql - SQL 返回值出错(缺少参数)
- python - 子命令问题:ctx.invoked_subcommands 始终为 None
- python - 遍历列表直到满足 2 个条件