aruba / aoscx-ansible-collection

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

AOSCX - Ansible connection via jump host doesn't work #26

Open stella-public-account opened 2 years ago

stella-public-account commented 2 years ago

Ansible version - 2.9.27 and 2.10 Python version - 3.8.10

We are writing ansible playbook to manage Aruba CX switches. However, the playbook doesn't get the output of commands when switch is connected to a jump host.

Our environment -

[Ansible Host] -> Jump Host -> Switch

The playbook times out with following error -

"msg": "socket_path does not exist or cannot be found.\nSee the socket_path issue category in Network Debug and Troubleshooting Guide"​

Traceback -

The full traceback is:
  File "/tmp/ansible_arubanetworks.aoscx.aoscx_command_payload_zt3y_wa1/ansible_arubanetworks.aoscx.aoscx_command_payload.zip/ansible_collections/arubanetworks/aoscx/plugins/module_utils/aoscx.py", line 447, in run_commands
    return conn.run_commands(commands=commands, check_rc=check_rc)
  File "/tmp/ansible_arubanetworks.aoscx.aoscx_command_payload_zt3y_wa1/ansible_arubanetworks.aoscx.aoscx_command_payload.zip/ansible/module_utils/connection.py", line 184, in __rpc__
    response = self._exec_jsonrpc(name, *args, **kwargs)
  File "/tmp/ansible_arubanetworks.aoscx.aoscx_command_payload_zt3y_wa1/ansible_arubanetworks.aoscx.aoscx_command_payload.zip/ansible/module_utils/connection.py", line 138, in _exec_jsonrpc
    raise ConnectionError('socket_path does not exist or cannot be found.'

However, same playbook works when executed on the Jump Host.

What might be the issue? We have tried all the steps mentioned here but issue still persists.

tchiapuziowong commented 2 years ago

Hello! I'm sorry to hear you're having difficulty - you can open the case with your SE if you want some internal support but if you'd like to troubleshoot here could you provide the following:

stella-public-account commented 2 years ago

Hello! I'm sorry to hear you're having difficulty - you can open the case with your SE if you want some internal support but if you'd like to troubleshoot here could you provide the following:

  • sample playbook you're using (changing any sensitive info)
  • sample inventory (excluding extra vars and changing any sensitive info)

Hello . We tried the playbook mentioned in your official guide - https://developer.arubanetworks.com/aruba-aoscx/docs/using-the-aos-cx-ansible-collection#using-both-rest-api-and-sshcli-modules-on-a-host. Just change the ip address, username and password. Rest was exactly the same.

inventory

all:
  hosts:
    aoscx_1:
      ansible_host: <ip-address>
      ansible_user:<username>
      ansible_password:<password>
      ansible_connection: network_cli
      ansible_network_os: arubanetworks.aoscx.aoscx
      ansible_ssh_common_args: "-o ProxyCommand=\"ssh -o StrictHostKeyChecking=no -W %h:%p -q 
                                 <username>@<jump-host> -p <ssh-port>\""

playbook

- hosts: all
   tasks:
    - name: Execute show vlan on the switch
      arubanetworks.aoscx.aoscx_command:
        commands: ['show vlan']
tchiapuziowong commented 2 years ago

Do you have a proxy environment variable set? Like "http_proxy" or "https_proxy"? If so is that needed to reach the switch? If not can you try running the playbook again without those variables being set?

tchiapuziowong commented 2 years ago

Also can you ensure that gather_facts: False and you include the collection like so:

- hosts: all
  gather_facts: False
  collections:
    - arubanetworks.aoscx
  tasks:
    - name: Execute show vlan on the switch
      aoscx_command:
        commands: ['show vlan']
ratneshnagori commented 2 years ago

Do you have a proxy environment variable set? Like "http_proxy" or "https_proxy"? If so is that needed to reach the switch? If not can you try running the playbook again without those variables being set?

Hi. We dont have any proxy env variable. Switches are reachable with ssh with and without the jump host.

ratneshnagori commented 2 years ago

Also can you ensure that gather_facts: False and you include the collection like so:

- hosts: all
  gather_facts: False
  collections:
    - arubanetworks.aoscx
  tasks:
    - name: Execute show vlan on the switch
      aoscx_command:
        commands: ['show vlan']

We have tested this way as well but it made no difference.

Is it possible for Aruba dev team to try running the playbook with jump host in place?

tchiapuziowong commented 2 years ago

Is the jump host a CX switch? You stated you're able to run the following playbook on the Jump Host and it's successful?

- hosts: all
  gather_facts: False
  collections:
    - arubanetworks.aoscx
  tasks:
    - name: Execute show vlan on the switch
      aoscx_command:
        commands: ['show vlan']

Can you reach out to your SE and see if they're able to assist you in troubleshooting the environment?

pmeffre commented 2 years ago

I have the same issue. I use a jump host for accessing my CX6300 (virtual) mgmt port. (configured in my .ssh/config file) When I configure the ansible_connection: ansible.netcommon.network_cli and using ansible.netcommon.cli_command: all works fine. When I configure the ansible_connection: network_cli and using arubanetworks.aoscx.aoscx_command:, I get : FAILED! => {"changed": false, "msg": "socket path /home/pierre/.ansible/pc/6ff121286b does not exist or cannot be found. See Troubleshooting socket path issues in the Network Debug and Troubleshooting Guide"}

hosts


[all:children]
video

[video]
VIDSW6300-SIMU1 ansible_host=10.100.3.210 mac_address=44:5b:ed:47:69:01 vendor_class="Aruba JL658A 6300M" mgmt_port=Vlan2905 
VIDSW6300-SIMU2 ansible_host=10.100.3.211 mac_address=bc:d7:a5:b9:58:c1 vendor_class="Aruba JL662A 6300M" mgmt_port=Vlan2905 

[video:vars]
ansible_network_os=arubanetworks.aoscx.aoscx
#ansible_connection=arubanetworks.aoscx.aoscx
ansible_aoscx_validate_certs=False
ansible_aoscx_use_proxy=False
ansible_acx_no_proxy=True
#ansible_connection=httpapi
#ansible_httpapi_validate_certs=False
#ansible_httpapi_use_ssl=True```

Playbook
```---
- hosts: video
  gather_facts: no
  collections:
    - arubanetworks.aoscx
  vars:
    ansible_network_os: arubanetworks.aoscx.aoscx
    #*ansible_connection: ansible.netcommon.network_cli
    ansible_connection: network_cli
  tasks:
    - name: Command avec aoscx plugin
      arubanetworks.aoscx.aoscx_command:
        commands:
          - show version
      register: resultat
      when: 
        - '"netcommon"  not in ansible_connection'
    - name: Commande avec netcommon plugin
      ansible.netcommon.cli_command:
        command: show version
      register: resultat
      when: 
        - '"netcommon" in ansible_connection'
    - debug:
        var: resultat```