Developer Community

Reply
Highlighted
Occasional Contributor I

Issue with “arubaos_switch_ssh_cli” module

This module seems working with only some show commands(such as ‘show version” and “show flash” ) but not all. Here is an example that does not work.

 

Aruba-3810M-24G-PoEP-1-slot# show cdp

Global CDP information

 

  Enable CDP [Yes] : Yes

  CDP mode [rxonly] : pre-standard-voice

  CDP Hold Time [180] : 180

  CDP Transmit Interval [60] : 60

 

  Port   CDP      Admin status

  ------ -------- ------------

  1      enabled  tx_rx

  2      enabled  rxonly

  3      enabled  rxonly

  4      enabled  rxonly

…..

 

I was trying to use below task to get the same information as above:

 

    - name: show cdp

      arubaos_switch_ssh_cli:

        ip: xxxxxx

        user: xxxx

        password: xxxx

        timeout: 180

        command_list:  [ "show cdp" ]

      register: cdp_result

 

However, the result returned is cli_output": []

 


Accepted Solutions
Highlighted

Re: Issue with “arubaos_switch_ssh_cli” module

Hmm.. I've tested both commands on a 3810 running KB.16.07.0002 and both seem to work... Is it that you're receving nothing in the variable? Could you try the following and post the results?

    - name: show cdp
      arubaos_switch_ssh_cli:
        ip: XXXXX
        user: XXXXX
        password: XXXXX
        show_command: ["no page", "show cdp"]
      register: cdp_result

    - debug:
        var: cdp_result

 

Here's my solution that's working along with the output:

---
- hosts: all
  gather_facts: False
  tasks:
    - name: show cdp
      arubaos_switch_ssh_cli:
        ip: "{{ansible_host}}"
        user: "{{ansible_user}}"
        password: "{{ansible_password}}"
        show_command: ["no page", "show cdp"]
      register: cdp_result

    - debug:
        var: cdp_result.cli_output[1]

    - name: show cdp traffic
      arubaos_switch_ssh_cli:
        ip: "{{ansible_host}}"
        user: "{{ansible_user}}"
        password: "{{ansible_password}}"
        show_command: ["show cdp traffic"]
      register: cdp_traffic_result

    - debug:
        var: cdp_traffic_result.cli_output[0]

OUTPUT

PLAY [all] *********************************************************************

TASK [show cdp] ****************************************************************
[DEPRECATION WARNING]: Distribution Ubuntu 16.04 on host switch1 should use
/usr/bin/python3, but is using /usr/bin/python for backward compatibility with
prior Ansible releases. A future Ansible release will default to using the
discovered platform python for this host. See https://docs.ansible.com/ansible/
2.8/reference_appendices/interpreter_discovery.html for more information. This
feature will be removed in version 2.12. Deprecation warnings can be disabled
by setting deprecation_warnings=False in ansible.cfg.
ok: [switch1]

TASK [debug] *******************************************************************
ok: [switch1] => {
    "cdp_result.cli_output[1]": "\n Global CDP information\n\n  Enable CDP [Yes] : Yes                           \n  CDP mode [rxonly] : rxonly              \n\n\n  Port   CDP     \n  ------ --------\n  1      enabled \n  2      enabled \n  3      enabled \n  4      enabled \n  5      enabled \n  6      enabled \n  7      enabled \n  8      enabled \n  9      enabled \n  10     enabled \n  11     enabled \n  12     enabled \n  13     enabled \n  14     enabled \n  15     enabled \n  16     enabled \n  17     enabled \n  18     enabled \n  19     enabled \n  20     enabled \n  21     enabled \n  22     enabled \n  23     enabled \n  24     enabled \n  A1     enabled \n  A2     enabled \n  A3     enabled \n  A4     enabled \n \n"
}

TASK [show cdp traffic] ********************************************************
ok: [switch1]

TASK [debug] *******************************************************************
ok: [switch1] => {
    "cdp_traffic_result.cli_output[0]": "\n CDP frame Statistics:\n\n  Port     Transmitted  Received    Discarded   Error   \n  No.      Frames       Frames      Frames      Frames  \n  -------- ------------ ----------- ----------- --------\n "
}

PLAY RECAP *********************************************************************

View solution in original post

Highlighted
Occasional Contributor I

Re: Issue with “arubaos_switch_ssh_cli” module

@tiffany got it, thanks!

View solution in original post


All Replies
Highlighted
Occasional Contributor I

Re: Issue with “arubaos_switch_ssh_cli” module

I haven't seen this myself but I spotted that the output of "show cdp" contains the [ symbol. Could the code be intollerent to this special character?

 

If you have other commands that don't work, do they contain this or other escape characters?

 

Does " show cdp traffic " produce an error (no [ character on my switches although we don't use CDP).

 

Ian.

Ian Nightingale - University of York, UK
MVP Guru Elite

Re: Issue with “arubaos_switch_ssh_cli” module

Hi,

 

It is not always a good idea to try to launch a cli command

it will be better to launch API call

there is a /rest/vX/cdp for CDP configuration



PowerArubaSW: Powershell Module to use Aruba Switch API for Vlan, VlanPorts, LACP, LLDP... More info

PowerArubaCP: Powershell Module to use ClearPass API (create NAD, Guest...) More info

PowerArubaCX: Powershell Module to use ArubaCX API (get interface/vlan/ports info)

PowerArubaIAP: Powershell Module to use Aruba Instant AP

PowerArubaMC: Powershell Module to use Mobility Controller / Master


ACMP 6.4 / ACMX #107 / ACCP 6.5 / ACSP
Highlighted
Occasional Contributor I

Re: Issue with “arubaos_switch_ssh_cli” module

Thanks for your reply, Ian!

I just tried and it does not look like caused by escape character, since "show cdp traffic" does not work either. See below:

---- Aruba output ---

Aruba-3810M-24G-PoEP-1-slot# show cdp traffic

CDP frame Statistics:

Port Transmitted Received Discarded Error
No. Frames Frames Frames Frames
-------- ------------ ----------- ----------- --------
24 0 46448 0 0
24 0 46448 0 0

------- Ansible output ----

changed: [localhost] => {
"changed": true,
"cli_output": [],
"invocation": {
"module_args": {
"allow_agent": false,
"boot_image": "primary",
"command_list": [
"show cdp traffic"
],
"enable_sftp": false,
"ip": "xxxxxxxx",
"key_filename": null,
"look_for_keys": false,
"password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"path_to_swi": null,
"port": 22,
"show_command": null,
"state": "upgrade",
"timeout": 180,
"user": "admin"
}
},
"message": ""
}

 

Highlighted
Occasional Contributor I

Re: Issue with “arubaos_switch_ssh_cli” module

@alagoutte, thanks for your reply and I agree REST is better.

however using REST does require enable it on the Aruba switch.  We try not to make configuration change on the switch unless it is absolutely necessary. If CLI module works as expected, we would prefer to stick to it at this time. 

Highlighted

Re: Issue with “arubaos_switch_ssh_cli” module

Hi!!

 

The parameter should actually be "show_command_list" instead of "command_list", that should give you the result back. Could you try and let me know the result?

 

    - name: show cdp

      arubaos_switch_ssh_cli:

        ip: xxxxxx

        user: xxxx

        password: xxxx

        timeout: 180

        show_command:  [ "show cdp" ]

      register: cdp_result

Highlighted
Occasional Contributor I

Re: Issue with “arubaos_switch_ssh_cli” module

@Tiffany, thanks for you reply. 

I actually tried both and none of them are working for “show cdp”, using “show_command” would be no response until timeout, while using “command_list” would just return nothing.

I tried a few show command so far, looks like only “show version” and “show flask” work.

Highlighted

Re: Issue with “arubaos_switch_ssh_cli” module

Hmm okay so show version and show flash work but not that particular command, do you have paging enabled? It could be since that command runs over multiple pages the module isn’t matching on the prompt. Are you able to disable paging with “no page” before the command?

Highlighted

Re: Issue with “arubaos_switch_ssh_cli” module

@jxia I think this is the solution... let me know if this works or not:

 

    - name: show cdp
      arubaos_switch_ssh_cli:
        ip: xxxxx
        user: xxxxx
        password: xxxxx
        show_command: ["no page", "show cdp"]
      register: cdp_result

    - debug:
        var: cdp_result.cli_output[1]
Highlighted
Occasional Contributor I

Re: Issue with “arubaos_switch_ssh_cli” module

hmmm...I'm not sure it is caused by "paging", the output from "show cdp traffic" is pretty small and it does not work either :(

 

Aruba-3810M-24G-PoEP-1-slot# show cdp traffic

CDP frame Statistics:

Port Transmitted Received Discarded Error
No. Frames Frames Frames Frames
-------- ------------ ----------- ----------- --------
24 0 46448 0 0
24 0 46448 0 0

Search Airheads
cancel
Showing results for 
Search instead for 
Did you mean: