Developer Community

Reply
Highlighted
Frequent Contributor I

Debug output with Anisble and Aruba CX module

I have the following play to deploy config to my switche

 

---
- name: Build Core Switch Config and Upload to device
hosts: all
gather_facts: yes
roles:
- CoreSwitch

tasks:
- name: Upload Configuration
# delegate_to: all
arubaos_cx_ssh_cli:
ip: "{{ ansible_host }}"
user: admin
password: password1
# Commands as a list
commands: ["copy tftp://192.168.5.1/{{ hostname }}.cfg running-config vrf mgmt"]

- name: Output the last 10 config errors
arubaos_cx_ssh_cli:
ip: 192.168.5.10
user: admin
password: aruba123
commands: ["show events -n 20 -d hpe-config"]
register: events
- debug:
var: events

 

 

but the output from the debug is not formatted in a human-readable format, although it does have \n line breaks. Looking for advice on formatting the output?

 

 

Highlighted

Re: Debug output with Anisble and Aruba CX module

Hi @and3p!!

 

I did a bit of research and  the solution could look something like this:

- name: Output the last 10 config errors
  arubaos_cx_ssh_cli:
    ip: 192.168.5.10
    user: admin
    password: aruba123
    commands: ["show events -n 20 -d hpe-config"]
  register: events
- debug:
      msg: "{{events.cli_output.0.split('\n')}}"

It'll display each line of the output in a somewhat human readable format, try it out and let me know if this is what you were looking for!

 

OUTPUT:

        "!",
        "!",
        "ssh server vrf mgmt",
        "!",
        "!",
        "!",
        "!",
        "!",
        "vlan 1-11",
        "interface mgmt",
        "    no shutdown",
        "    ip dhcp",
        "interface lag 130",
        "    no shutdown",
        "    no routing",
        "    vlan trunk native 1",
        "    vlan trunk allowed 2-11",
        "    lacp mode active",
        "interface 1/1/7 ",
        "    no shutdown",
        "    lag 130",
        "interface 1/1/10 ",
        "    no shutdown",
        "    lag 130",
        "interface 1/1/23 ",
        "    no shutdown",
        "    no routing",
        "    vlan trunk native 1",
        "    vlan trunk allowed 2-11",
Search Airheads
cancel
Showing results for 
Search instead for 
Did you mean: