aruba / aos-switch-ansible-collection

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

I can not seem to access any of my switches using this collection #55

Open quistian opened 1 year ago

quistian commented 1 year ago

When I try to do a simple "show run" "show version" I get the error:

No existing session. I have the connection set to network_cli

alagoutte commented 1 year ago

Hi,

What switch firmware and model ?

Do you have check the log of the switch and also this part of doc ? https://github.com/aruba/aos-switch-ansible-collection#setting-environment-variables

quistian commented 1 year ago

show version

Image stamp: /ws/swbuildm/rel_beluru_qaoff/code/build/lvm(swbuildm_rel_beluru_qaoff_rel_beluru) Dec 9 2021 22:37:35 WC.16.11.0003 591 Boot Image: Primary

Boot ROM Version: WC.16.01.0010 Active Boot ROM: Primary

It's a 2930F

quistian commented 1 year ago

And I am setting the environment variable:

ANSIBLE_NETWORK_GROUP_MODULES=arubaoss ansible-playbook \ --inventory inventory.yml \ -vvvv \ aos-gen-temp.yml

$ grep NETWORK /etc/ansible/ansible.cfg NETWORK_GROUP_MODULES=arubaoss

quistian commented 1 year ago

I can log into the switch manually using ssh.

quistian commented 1 year ago

I find I can use the arubaoss_vlan module as documented using both: ansible_connection: local and network_cli. I can also use the arubaoss_ntp module as documented.

I can't use the arubaoss_config or arubaoss_command modules as per the documentation. My goal is to use the ansible collection and module(s) to save the running configuration to a local file for my 2930 and 2450 switches.

When I use the arubaoss_command module, with any set of commands e.g. show version the error message is: No existing sessions.

When I use the arubaoss_config module as follows to save the running configuration:

- name: snarf running configuration
   arubaoss_config:
     backup: True
     backup_options:
       filename: "{{ inventory_hostname }}.cfg"
     save_when: always

I receive the error:

"msg": "unable to retrieve current config",
"stderr": "Unable to decode JSON from response to exec_command('show running-config'). Received 'None'.",

The test switch is as follows:

2930F-test(config)# show system

 Status and Counters - General System Information

  System Name        : 2930F-RestAPI-test
  System Contact     : NOC (416) 978-4621
  System Location    : none

  MAC Age Time (sec) : 300

  Time Zone          : -300
  Daylight Time Rule : Continental-US-and-Canada

  Software revision  : WC.16.11.0003        Base MAC Addr      : 64e881-057100
  ROM Version        : WC.16.01.0010        Serial Number      : TW07HKW2S2

  Up Time            : 109 days             Memory   - Total   : 337,437,184
  CPU Util (%)       : 39                              Free    : 215,594,996

  IP Mgmt  - Pkts Rx : 3,110,401            Packet   - Total   : 6600
             Pkts Tx : 3,095,281            Buffers    Free    : 4347
                                                       Lowest  : 3948
                                                       Missed  : 0

Any ideas what I can do to get the running configuration file for a AOS switch?

alagoutte commented 1 year ago

@quistian

ansible run on linux ? windows ? on the ansible runner, you can make ssh connection to the switch ? do you have try to make a capture to see if there is ssh connection to the switch ?

do you have check switch log ?

quistian commented 1 year ago

There is definitely an ssh connection to the switch as I can perform the vlan and ntp commands fine. I can definitely log in manually via ssh using the credentials given to ansibile. I am currently using OpenBSD and ansible version 2.13.4

$ ansible --version
ansible [core 2.13.4]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/russ/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.9/site-packages/ansible
  ansible collection location = /home/russ/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.9.15 (main, Oct 21 2022, 14:01:40) [Clang 13.0.0 ]
  jinja version = 3.1.2
  libyaml = True
quistian commented 1 year ago

I've now tried to use the config and command modules with ansible on an Ubuntu 20.04 machine. The same problem exists. The modules fail in a slightly different manner, but they still fail. The other modules e.g. the NTP ones work find in network_cli mode.

tchiapuziowong commented 1 year ago

@quistian you should be using ansible_connection: network_cli for arubaoss_command and arubaoss_config modules, all other modules (arubaoss_vlan, arubaoss_ntp) use ansible_connection: local

quistian commented 1 year ago

That's what I am doing i.e. using network_cli and using arubaoss_command as follows:

hosts: aos_sws collections:

The error message is as follows:

aos-out.txt

HilkopterBob commented 1 year ago

Boot ROM Version: WC.16.01.0010 Active Boot ROM: Primary

Update to 16.11 or 16.10 Helped me in my case with my 2530 to from 16.01 to 16.11 in small update steps

uoe-ahewittbell commented 6 months ago

Do you have password configuration-control configured on the switch?

The reason I ask Is I've been having issues with running command / config ansible playbooks and got the same error above: "stderr": "Unable to decode JSON from response to exec_command('show running-config'). Received 'None'.",

From my testing (using a radius auth user) I was able to get it working by disabling the password config-control.

This is on both 16.10 & 16.11