aruba / aoscx-ansible-collection

Ansible collections for AOS-CX switches 
48 stars 23 forks source link

Collection does not work with proxy setup #100

Open UglyAnimal opened 7 months ago

UglyAnimal commented 7 months ago

Hello. I have following setup: my laptop -> AWS Jumphost -> Site-to-site VPN -> Aruba 6100 (JL676A) switch.

I configured tinyproxy in AWS jumpbox and it's listening on 127.0.0.1:8888. I use SSH port forwarding to reach the proxy from my laptop: ssh -N -L 8888:127.0.0.1:8888 jumpbox_ip. I exported HTTPS_PROXY and HTTP_PROXY ENV variables in my ~/.bashrc:

export HTTPS_PROXY=http://localhost:8888
export HTTP_PROXY=http://localhost:8888

I can reach web UI of the switch from my laptop using curl: curl -k https://switch_ip:443. Also when I set proxy in my browser, I can reach webui of the switch using it's IP in the browser, so proxy works fine.

When I run an ansible task in playbook to gather facts on the switch:

- name: "Gathers facts"
  aoscx_facts:
    gather_subset:
      - host_name
  environment:
    http_proxy: "http://localhost:8888"
    https_proxy: "http://localhost:8888"

I get:

"msg": "System: \"RESPONSE ERROR: HTTPSConnectionPool(host='switch_ip', port=443): Max retries exceeded with url: /rest/v10.04/firmware (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7f43769d8970>, 'Connection to switch_ip timed out. (connect timeout=None)')): Response: GET\""
}

My inventory looks like:

[switches:children]
aruba_6100_48_switches

[aruba_6100_48_switches]
aruba-6100_48-ws-switch ansible_host=switch_ip ansible_user="{{ aruba.6100_48.username }}" ansible_password="{{ aruba.6100_48.password }}" ansible_connection=arubanetworks.aoscx.aoscx ansible_network_os=arubanetworks.aoscx.aoscx ansible_aoscx_validate_certs=False ansible_aoscx_use_proxy=True ansible_acx_no_proxy=False

I tried playing with ansible_aoscx_use_proxyand ansible_acx_no_proxy variables, setting them to Trueor False, but it did not help. Only difference was in error message: "msg": "Could not get PYAOSCX Session: LOGIN ERROR, ERROR: Error connecting to host: connection attempt timed out." Also I tried unsetting environment in ansible task.

What's the difference between ansible_aoscx_use_proxy and ansible_acx_no_proxy variables?

When I'm connected to the network where switch resides, playbook works perfectly fine, so somehow this collection does not work with proxy setup.

Please help me understanding how to use this collection with proxy.

Aruba switch firmware: PL.10.13.1000 Ansible version: 2.15.8 Ansible collections versions:

ansible.netcommon             6.0.0
ansible.utils                 3.1.0
arubanetworks.aos_switch      1.7.0
arubanetworks.aoscx           4.3.1
alagoutte commented 7 months ago

_ansible_acx_noproxy is when use _ansibleconnection with httpapi and _ansible_aoscx_useproxy with _ansibleconnection arubanetworks.aoscx.aoscx

UglyAnimal commented 7 months ago

_ansible_acx_noproxy is when use _ansibleconnection with httpapi and _ansible_aoscx_useproxy with _ansibleconnection arubanetworks.aoscx.aoscx

Thanks. I've just tried to set ansible_aoscx_use_proxy to True only and still it's failed.

UglyAnimal commented 7 months ago

BTW, these commands work fine from my laptop using proxy:

#login to switch
curl -k -X POST -c /tmp/auth_cookie -H 'Content-Type: multipart/form-data' "https://switch_ip/rest/login" -F 'username=admin' -F 'password=password'

#get system info
curl -k -X GET -b /tmp/auth_cookie -H 'Content-Type:application/json' -H 'Accept: application/json' "https://switch_ip/rest/system"

#logout from switch
curl -k -X POST -b /tmp/auth_cookie "https://switch_ip/rest/logout"
tchiapuziowong commented 7 months ago

Thank you for bringing this to our attention, I'll try to reproduce and bring this up internally! Out of curiosity, if you export http_proxy and https_proxy does that change anything?

UglyAnimal commented 7 months ago

Thank you for bringing this to our attention, I'll try to reproduce and bring this up internally! Out of curiosity, if you export http_proxy and https_proxy does that change anything?

Yeah, I tried it, it did not change anything.