Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
quistian opened this issue Dec 14, 2022 · 12 comments
Open

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

quistian opened this issue Dec 14, 2022 · 12 comments

Comments

@quistian
Copy link

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

  • hosts: aos_test
    gather_facts: True
    collections:

    • arubanetworks.aos_switch
      vars:
      ansible_network_os: arubanetworks.aos_switch.arubaoss
      ansible_connection: network_cli
      ansible_user: ***
      ansible_password: ***

    tasks:

    • name: Execute show version on the switch
      arubaoss_command:
      commands:
      - show run
      - show version
      output_file: "./config/{{ inventory_hostname }}-aos-running-config.txt"
      tags:

      • show_version

      ok: [aos_test_sw] => { "changed": false, "invocation": { "module_args": { "api_version": "None", "commands": [ "show run", "show version" ], "host": null, "interval": 1, "match": "all", "output_file": "./config/aos_test_sw-aos-running-config.txt", "password": null, "port": null, "provider": { "api_version": null, "host": "10.5.9.18", "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "port": 80, "ssh_keyfile": null, "timeout": 30, "transport": "aossapi", "use_proxy": false, "use_ssl": false, "username": "swbackup", "validate_certs": false }, "retries": 10, "ssh_keyfile": null, "timeout": null, "use_ssl": null, "username": null, "validate_certs": false, "wait_for": null } }, "stdout": [ "No existing session", "No existing session" ], "stdout_lines": [ [ "No existing session" ], [ "No existing session" ] ] }

@alagoutte
Copy link
Contributor

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
Copy link
Author

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
Copy link
Author

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
Copy link
Author

I can log into the switch manually using ssh.

@quistian
Copy link
Author

quistian commented Dec 16, 2022

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
Copy link
Contributor

@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
Copy link
Author

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
Copy link
Author

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
Copy link
Member

@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
Copy link
Author

quistian commented Feb 8, 2023

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

hosts: aos_sws
collections:
- arubanetworks.aos_switch
vars:
ansible_network_os: arubanetworks.aos_switch.arubaoss
ansible_connection: network_cli

tasks:
- name: Show running-config, show version commands output to a file
arubaoss_command:
commands:
- show run
output_file: "./config/{{ inventory_hostname }}.cfg"
tags: cmd

The error message is as follows:

aos-out.txt

@HilkopterBob
Copy link

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants