ansible-collections / community.network

Ansible Community Network Collection
http://galaxy.ansible.com/community/network
Other
124 stars 89 forks source link

EXOS: httpapi request results in a 308 PERMANENT REDIRECT #612

Open misch42 opened 2 months ago

misch42 commented 2 months ago
SUMMARY

We are testing the network.community.exos module against a X440G2 with exos 32.6.3.127 patch 1-8.

a connection with network_cli does not work at all.

a connection with httpapi works (http and https) but always results in a 308 PARMANENT REDIRECT reply from the switch.

ISSUE TYPE

We cannot configure the switch or send a command to the switch via the httpapi.

COMPONENT NAME

network.community.exos

ANSIBLE VERSION
core 2.16.8
COLLECTION VERSION
community.network 5.0.3
CONFIGURATION
OS / ENVIRONMENT

ubuntu 22.04

STEPS TO REPRODUCE
ansible-playbook ....
EXPECTED RESULTS

Get config, able to configure device

ACTUAL RESULTS

reuturns a 308 PERMANET REDIRECT error form the switch.

We did a tcpdump to trace the communication with the switch.

1) ansible got the auth token correctly by sending username and password to the /auth/token API entry point.

2) ansible sends a request to the "/" URI of the switch with the auth token.

3) The switch sends a 308 PERMANENT REDIR answer to ansible. Perhaps ansible does not use the correct URI for the switch?

4) We tried with curl to send a request to the switch. According to the documentation of exos the API Entry point is "/rest/restconf/"

So perhaps the ansible module uses the incorrect API entry point.

Any help welcome.

Andersson007 commented 2 months ago

@misch42 hello, thanks for opening an issue!

@LindsayHill @ujwalkomarla you folks are listed in the .github/BOTMETA.yml file as module maintainers, would you like to take a look?

If there are any other volunteers to fix this, we have a quick-start dev guide for newcomers. Thanks

ujwalkomarla commented 2 months ago

The URI Path for JSONRPC must be updated from /jsonrpc to /jsonrpc/

The edit needs to happen at https://github.com/ansible-collections/community.network/blob/main/plugins/httpapi/exos.py#L94 to

            response, response_data = self.connection.send('/jsonrpc/', data, cookies=self._auth_token, headers=headers, method='POST')
Marco-MP commented 2 months ago

As one of the persons that experienced this issue together with @misch42, I can confirm after a quick test, that the adding of that trailing / fixes the HTTPAPI communication with our X440G2.

Thanks for the quick fix and lets hope it finds its way into the package.