NTP configuration [config_ntp_ipv4addr] : Unable to load response from device
Opened this issue · 0 comments
I'm opening this issue following a problem I published here : #72 (comment)
Version
Switch Aruba JL261A (firmware #WC.16.11.0016)
Ansible 2.14.9
Aruba aos_switch 1.7
Configuration
Following this ansible configuration :
- name: Configuration timesync to be NTP
arubaoss_ntp:
command: "config_timesync"
timesyncType: "{{ ntp_type }}"
api_version: "{{ ansible_api_version }}"
use_ssl: "{{ ansible_use_ssl }}"
port: "{{ ansible_port }}"
host: "{{ ansible_host }}"
username: "{{ ansible_user }}"
password: "{{ ansible_password }}"
delegate_to: "{{ passthrough }}"
remote_user: "{{ hostvars[passthrough].ansible_user }}"
vars:
ansible_ssh_private_key_file: "{{ hostvars[passthrough].ansible_ssh_private_key_file }}"
tags:
- system
- ntp
- name: Enable NTP
arubaoss_ntp:
command: "config_ntp"
config: create
operate: "{{ ntp_operate }}"
api_version: "{{ ansible_api_version }}"
use_ssl: "{{ ansible_use_ssl }}"
port: "{{ ansible_port }}"
host: "{{ ansible_host }}"
username: "{{ ansible_user }}"
password: "{{ ansible_password }}"
delegate_to: "{{ passthrough }}"
remote_user: "{{ hostvars[passthrough].ansible_user }}"
vars:
ansible_ssh_private_key_file: "{{ hostvars[passthrough].ansible_ssh_private_key_file }}"
tags:
- system
- ntp
- name: Set NTP server
arubaoss_ntp:
command: "config_ntp_ipv4addr"
config: create
ntp_ip4addr: "10.0.0.13"
mode: "iburst"
api_version: "{{ ansible_api_version }}"
use_ssl: "{{ ansible_use_ssl }}"
port: "{{ ansible_port }}"
host: "{{ ansible_host }}"
username: "{{ ansible_user }}"
password: "{{ ansible_password }}"
delegate_to: "{{ passthrough }}"
remote_user: "{{ hostvars[passthrough].ansible_user }}"
vars:
ansible_ssh_private_key_file: "{{ hostvars[passthrough].ansible_ssh_private_key_file }}"
tags:
- system
- ntp
And without any ntp configured on switch :
SWITCH(config)# show ntp servers
NTP Server Information
No NTP server configuration details found!
The command "config_ntp_ipv4addr" fail and return :
unable to load response from device
Debug
To debug I used packet analyzer like Wireshark/tcpdump tool and trace values of variable in .ansible/collections/ansible_collections/arubanetworks/aos_switch/plugins/module_utils/arubaoss.py
For idempotent, the module try to delete config before send new config. But when config not exist, switch return (legitimately) a 404 error.
Network analyzer extraction :
DELETE /rest/v8.0/config/ntp/server/ip4addr/10.150.17.10 HTTP/1.1
Accept-Encoding: identity
Content-Length: 156
Host: 172.25.0.201:443
User-Agent: ansible-httpget
Content-Type: application/json
Cookie: sessionId=KZxPVyULSRfvMRqlbh4FUKnBZsMCMzokbN9bqO5Ihxhso127nfp3g5lhAOAnP1o
Connection: close
{"ip4addr": {"ip4addr_reference": {"max-poll": {"max-poll_value": 10}, "min-poll": {"min-poll_value": 6}, "iburst": true}, "ip4addr_value": "10.150.17.10"}}HTTP/1.1 404 Not Found
Server: eHTTP v2.0
Content-Length: 38
Date: Thu, 01 Jan 1970 04:51:15 GMT
RequestId: (null)
Connection: close
{
"message": "Error 404: Not Found."
}
And module fail.
Of course, if have already set the switch with the good configuration and run ansible module success.
In this case module return ok without change configuration, (that is normal)
Another trace of module variable confirm this behavior :
data={"ip4addr": {"ip4addr_reference": {"max-poll": {"max-poll_value": 10}, "min-poll": {"min-poll_value": 6}, "iburst": true}, "ip4addr_value": "10.150.17.10"}}
url=https://172.25.0.201:443/rest/v8.0/config/ntp/server/ip4addr/10.150.17.10
method=DELETE
header={'url': 'https://172.25.0.201:443/rest/v8.0/config/ntp/server/ip4addr/10.150.17.10', 'status': 404, 'server': 'eHTTP v2.0', 'content-length': '38', 'date': 'Tue, 06 Jan 1970 16:48:36 GMT', 'requestid': '(null)', 'connection': 'close', 'msg': 'HTTP Error 404: Not Found', 'body': b'{\n"message": "Error 404: Not Found."\n}'}
___response=HTTP Error 404: Not Found___HTTP Error 404: Not Found
An (ugly) workaround consist to consider an 404 error to return a success.
I edited "run_commands" function in ".ansible/collections/ansible_collections/arubanetworks/aos_switch/plugins/module_utils/arubaoss.py" file and edit code like :
Before
if headers['status'] == 204:
return {'msg': 'Successful', 'changed': True}
After
if headers['status'] == 204 or headers['status'] == 404:
return {'msg': 'Successful', 'changed': True}
And script work like expected behavior.