I'm currently testing to retrieve firmware version lists on HP/Aruba switches using arubanetworks.aos_switch collection. Basically i'm just doing :
collections:
- arubanetworks.aos_switch
tasks:
- name: Launching "show flash" CLI
arubaoss_command:
commands:
- "show flash"
register: output_version
- name: Firmware Display
debug:
msg: "{{ output_version.stdout_lines }}"
Here's what i retrieve when i launch my playbook with -vvv option from stdout & stdout_lines perspective :
"stdout": [
"show flashImage Size (bytes) Date Version \n----------------- ------------ -------- --------------\nPrimary Image : 14184498 04/14/17 YA.16.03.0004 \nSecondary Image : 14184498 04/14/17 YA.16.03.0004 \n\nBoot ROM Version \n----------------\nPrimary Boot ROM Version : YA.15.19\b\nDefault Boot Image : Primary"
],
"stdout_lines": [
[
"show flashImage Size (bytes) Date Version ",
"----------------- ------------ -------- --------------",
"Primary Image : 14184498 04/14/17 YA.16.03.0004 ",
"Secondary Image : 14184498 04/14/17 YA.16.03.0004 ",
"",
"Boot ROM Version ",
"----------------",
"Primary Boot ROM Version : YA.15.19",
"",
"Default Boot Image : Primary"
]
]
}
If i use the following regex msg: "{{ output_version.stdout | regex_findall('(Primary Image[^\\\\n]*)')}}"
on stdout, i succeed to retrieve a one liner result like : "Primary Image : 14184498 04/14/17 YA.16.03.0004 "
My main question is, as it's not a JSON format output, what should be the best and simplest way to retrieve those data correctly ? In the future, i'd like to store it in a file basically something like hostname;flash image;Size;Date;Version
Thanks a lot for your advice. Gael