我正在为网络设备运行API登录任务,有时会出现以下错误:"_ssl.c:602: The handshake operation timed out"
。有时会运行,有时会给出握手错误。我最近在使用SSH时向网络设备添加了RADIUS身份验证,但是API仍使用本地凭据。但这会引起问题吗?
我正在使用的模块是基本的URI模块,任务如下:
- name: Login to switch using API
uri:
url: "https://{{ ansible_host }}/rest/v4/login-sessions"
method: POST
headers:
Accept: "application/json"
Content-Type: "application/json"
body: {"userName": "{{ ansible_user }}", "password": "{{ ansible_password }}"}
body_format: json
validate_certs: no
status_code: 201
register: switch_session
我遇到的错误如下:
fatal: [test_switch]: FAILED! => {
"changed": false,
"content": "",
"elapsed": 30,
"invocation": {
"module_args": {
"attributes": null,
"backup": null,
"body": {
"password": "<PASSWORD>",
"userName": "<USERNAME>"
},
"body_format": "json",
"client_cert": null,
"client_key": null,
"content": null,
"creates": null,
"delimiter": null,
"dest": null,
"directory_mode": null,
"follow": false,
"follow_redirects": "safe",
"force": false,
"force_basic_auth": false,
"group": null,
"headers": {
"Accept": "application/json",
"Content-Type": "application/json"
},
"http_agent": "ansible-httpget",
"method": "POST",
"mode": null,
"owner": null,
"regexp": null,
"remote_src": null,
"removes": null,
"return_content": false,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"src": null,
"status_code": [
"201"
],
"timeout": 30,
"unix_socket": null,
"unsafe_writes": null,
"url": "https://<IP_ADDR>/rest/v4/login-sessions",
"url_password": null,
"url_username": null,
"use_proxy": true,
"validate_certs": false
}
},
"msg": "Status code was -1 and not [201]: Request failed: <urlopen error ('_ssl.c:602: The handshake operation timed out',)>",
"redirected": false,
"status": -1,
"url": "https://<IP_ADDR>/rest/v4/login-sessions"