Developer Community

Reply
Occasional Contributor I

Re: Issue with “arubaos_switch_ssh_cli” module

@tiffany, interesting, it does work now with adding the "no page".

 

ok: [localhost] => {
"changed": false,
"cli_output": [
"",
"\n Global CDP information\n\n Enable CDP [Yes] : Yes \n CDP mode [rxonly] : pre-standard-voice \n CDP Hold Time [180] : 180\n CDP Transmit Interval [60] : 60 \n\n Port CDP Admin status\n ------ -------- ------------\n 1 enabled tx_rx \n 2 enabled rxonly \n 3 enabled rxonly \n 4 enabled rxonly \n 5 enabled rxonly \n 6 enabled rxonly \n 7 enabled rxonly \n 8 enabled rxonly \n 9 enabled rxonly \n 10 enabled rxonly \n 11 enabled rxonly \n 12 enabled rxonly \n 13 enabled rxonly \n 14 enabled rxonly \n 15 enabled rxonly \n 16 enabled rxonly \n 17 enabled rxonly \n 18 enabled rxonly \n 19 enabled rxonly \n 20 enabled rxonly \n 21 enabled rxonly \n 22 enabled rxonly \n 23 enabled rxonly \n 24 enabled rxonly \n \n"
],
"invocation": {
"module_args": {
"allow_agent": false,
"boot_image": "primary",
"command_list": null,
.........
"show_command": [
"no page",
"show cdp"
],

One thing i'm a bit confused is when to use "command_list" and when to use "show_command". In this case, I would think "command_list" would be used, however it would return [].

Aruba Employee

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 *********************************************************************
Occasional Contributor I

Re: Issue with “arubaos_switch_ssh_cli” module

@tiffany, sorry i posted earlier without trying, then tried later and found out both work now with "no page". thanks!

Aruba Employee

Re: Issue with “arubaos_switch_ssh_cli” module

Yay! I'm happy to hear!!

 

In regards to your question about using the parameters, the command_list parameter is used for commands you don't want to receive the output from, and show_command is used for commands you want the output from. The way the module works is that ALL commands in the command_list parameter will be executed first then ALL the commands in the show_command will be executed and stored in a list variable named cli_output and each entry in the list will be the output of the corresponding command.

 

And just a note to others who are using this module, you have to register the results of the module into a variable in order to access the cli_output list variable:

 

    - 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]
Highlighted
Occasional Contributor I

Re: Issue with “arubaos_switch_ssh_cli” module

@tiffany got it, thanks!

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