aruba / aos-switch-ansible-collection

Ansible collection for AOS-Switch switches
67 stars 19 forks source link

Timeout on sample scripts #30

Open GyVVyG opened 2 years ago

GyVVyG commented 2 years ago

Hello I'm trying to show a PoC for our config management and I'm stuck on our aruba modules (everything else seems to be working OK) Enviroment:

Ubuntu 20.04
ansible [core 2.12.2]
python version = 3.8.10 (default, Nov 26 2021, 20:14:08) [GCC 9.3.0]
jinja version = 2.10.1
libyaml = True
Aruba 2530-8G-PoEP
Aruba 2530-48G-PoEP 
Aruba 2930F-48G-4SFP+

Sample playbook from https://galaxy.ansible.com/arubanetworks/aos_switch :

- hosts: all
  collections:
    - arubanetworks.aos_switch
  tasks:
    - name: Create VLAN 300
      arubaoss_vlan:
        vlan_id: 300
        name: "vlan300"
        config: "create"
        command: config_vlan
- hosts: all
  collections:
    - arubanetworks.aos_switch
  vars:
    ansible_connection: network_cli
  tasks:
    - name: Execute show run on the switch
      arubaoss_command:
        commands: [show run]

with the sample inventory:

all:
  hosts:
    swedge:
      ansible_host: xx.xxx.xx.xxx
      ansible_user: xxxxxxx
      ansible_password: xxxxxxx
      ansible_network_os: arubanetworks.aos_switch.arubaoss
      ansible_connection: local

And my ansible.cfg

[defaults]
NETWORK_GROUP_MODULES = arubaoss
host_key_checking = False

Executing will create the VLANs (this is good) and go to the 'show run' command and will timeout. Even if my timeout is at 30, 60 or 120 seconds ( export ANSIBLE_PERSISTENT_CONNECT_TIMEOUT=60 ). I've tried multiple commands and all cli commands gives me a timeout.

The full traceback is:
  File "/tmp/ansible_arubaoss_command_payload_agpr6jsc/ansible_arubaoss_command_payload.zip/ansible_collections/arubanetworks/aos_switch/plugins/module_utils/arubaoss.py", line 432, in run_cli_commands
    return conn.run_commands(commands=commands, check_rc=check_rc)
  File "/tmp/ansible_arubaoss_command_payload_agpr6jsc/ansible_arubaoss_command_payload.zip/ansible/module_utils/connection.py", line 200, in __rpc__
    raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)
fatal: [swedge]: FAILED! => {"changed": false, "msg": "command timeout triggered, timeout value is 60 secs.\nSee the timeout setting options in the Network Debug and Troubleshooting Guide."}

The command I'd like to execute is copy running-config tftp xxx.xx.xx.xx config.txt. Crawling the internet there seems to be multiple different version of the collection, with multiple fonctions what aren't used/support anymore so I'm struggling getting the basics down with the Aruba.

Thanks for any help

tchiapuziowong commented 2 years ago

Can you put the command "show run" in quotations like so and see if that changes:

    - name: Execute show run on the switch
      arubaoss_command:
        commands: ['show run']
GyVVyG commented 2 years ago

It already is ['show run']. Didn't realise I didn't put it back, i had troubles with formatting on my first try and it was screwing up there. Sorry, Edited the master post

tchiapuziowong commented 2 years ago

The user you're using to login to execute the show run command - do they have manager privileges? Are you able to ssh into the switch directly with that user and execute the same command?

GyVVyG commented 2 years ago

The user you're using to login to execute the show run command - do they have manager privileges? Are you able to ssh into the switch directly with that user and execute the same command?

Yes I'm using the manager account.

I've found another solution. Looking at the arubaos_anycli.py ( https://github.com/aruba/aos-switch-ansible-collection/blob/master/plugins/modules/arubaoss_anycli.py ) It gives us another command which is

      - name: View the running config in the system
        arubaoss_anycli:
          command: "show running-config"

Creating a playbook like this and executing it with -v will output the show running-config in base64. Not bad.

---
    -  hosts: all
       collections:
         - arubanetworks.aos_switch
       tasks:
       - name: View the running config in the system
         arubaoss_anycli:
          command: "show running-config"

edit after thinking: this is a solution to my problem but doesn't change the fact that arubaoss_command is timing out

tchiapuziowong commented 2 years ago

Glad to see you have a workaround but also confusing as to why you're getting a timeout - if you're able to work with your SE we could have a debug session. The timeout would make sense if you're running a command that required interaction but that's not the case here. I haven't been able to reproduce the issue using multiple different show commands on both platforms - here's my env:

(py3_ansible) ansible-control-machine$ansible --version
ansible [core 2.12.1]
  config file = /ws/chiapuzi/tme/sandbox/aoss_playbooks/aoss_example_playbooks/ansible.cfg
  configured module search path = ['/users/chiapuzi/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /ws/chiapuzi/tme/sandbox/py3_ansible/lib/python3.8/site-packages/ansible
  ansible collection location = /users/chiapuzi/.ansible/collections:/usr/share/ansible/collections
  executable location = /ws/chiapuzi/tme/sandbox/py3_ansible/bin/ansible
  python version = 3.8.9 (default, Apr  3 2021, 01:02:10) [GCC 5.4.0 20160609]
  jinja version = 3.0.1
  libyaml = True
GyVVyG commented 2 years ago

That is weird if you don't have any problems but i do, that sucks. I'm having a couple of problems with another module too (arubaoss_config_bkup) so I'm wandering if i should maybe re-install everything and see if it was some kind of fluke.

 ansible --version
ansible [core 2.12.2]
  config file = /home/user/ansible.cfg
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.8.10 (default, Nov 26 2021, 20:14:08) [GCC 9.3.0]
  jinja version = 2.10.1
  libyaml = True

I've never done a debug session with ansible before, but if you're down to help I'm down to learn.