Does anyone did some Lab on Dell iDRAC? If so, how did you get a specific info l . . .

BR:
It created a csv file , the header is there no problem but the value is a combination of Service_Tag
*{'dest': '7NABCD',* 'changed': True, 'diff': {'before': {'path': ........

I only want to see only 7NABCD as the value and nothing else …

is there a way to get the out directly? Like

  • name: Get Service Tag
    dellemc.openmanage.idrac_system_info.System[0].ServiceTag:

I know that doesn’t work but maybe there is a direct way of getting the exact output? The yaml above will always go through the whole information first before trying to get servicetag and it takes time.

Is there a way something like this? Where the output in the register is exactly what I want nothing else.

- name: Get my Public address!
ansible.builtin.shell: dig @208.67.222.222 <http://myip.opendns.com|myip.opendns.com> +short
register: br_public_address

BR:
OK for the debug example:

BR:
tasks:
- name: Get Service Tag
dellemc.openmanage.idrac_system_info:
idrac_ip: "{{ idrac_ip }}"
idrac_user: "{{ idrac_user }}"
idrac_password: "{{ idrac_password }}"
validate_certs: false
register: vs

- debug:
msg: "{{ vs.system_info.BIOS[0].VersionString }}"
register: vss

- name: Save CSV headers
ansible.builtin.lineinfile:
dest: "{{ csv_path }}/{{ csv_filename }}"
line: "{{ headers }}"
create: true
state: present
delegate_to: localhost
run_once: true

- name: Build out CSV file
ansible.builtin.lineinfile:
dest: "{{ csv_path }}/{{ csv_filename}}"
line: "{{ vss }}"
create: true
state: present
delegate_to: localhost

The csv file shows this:

Service_Tag
*{'msg': '2.6.3'*, 'failed': False, 'changed': False}

The header is OK, but the value again will have {'msg': '2.6.3'

Could you please advise how to remove those other info? I only want to see 2.6.3

BR:
from the -vvv
It shows the following. it seems that’s the reason why I am getting that output from the csv
list:
- Version_String: '{''msg'': ''2.6.3'''
'null':
- ' ''failed'': False'

Andrei Andriushin:
Try this one:

- name: Create CSV
  ansible.builtin.lineinfile:
      path: "{{ csv_path }}/{{ csv_filename }}"
      line: "{{ headers }}"
      create: true
  delegate_to: localhost
- name: Get Service Tag
  dellemc.openmanage.idrac_system_info:
    idrac_ip:  "{{ idrac_ip }}"
    idrac_user:  "{{ idrac_user }}"
    idrac_password:  "{{ idrac_password }}"
    validate_certs: false
  register: vs
- name: Build out CSV file
    ansible.builtin.lineinfile:
      path: "{{ csv_path }}/{{ csv_filename}}"
      line: "{{vs.system_info.BIOS[0].VersionString}}"
    delegate_to: localhost

Andrei Andriushin:
You can also use static data for headers. Variable will be good when you decide to save more info based on dynamic decision. Don’t forget to add commas in that case

BR:
@Andrei Andriushin OMG! Thank you so much!!! It works now …

Version_String,Service_Tag
2.6.3,7NMJDF3

BR:
By the way, is it normal that once the first task is completed, it will go through again on all the info on the system_info for the 2nd task? Looking at the -vvv it will again look the whole system_info and it takes time … Can all tasks look into the system_info one time so it doesn’t repeat and wait few min to finish?

Andrei Andriushin:
Playbook will be repeated for every host, so every time it should return different service tags. I was thinking idrac_ip is a different var for every host.
Can you share full playbook, so I can answer in a practical way?

BR:
even just this one takes few seconds … so it seems with system_info it just running through all the information, it’s a long list … compare to just doing a simple shell like grep to something in a linux box does very quick.

tasks:
- name: Get Version String
dellemc.openmanage.idrac_system_info:
idrac_ip: "{{ idrac_ip }}"
idrac_user: "{{ idrac_user }}"
idrac_password: "{{ idrac_password }}"
validate_certs: false

Here’s the playbook. I am only using a single host …

---
- name: ### Generate a report
hosts: target01
connection: local
gather_facts: true ### On by default
vars:
#random setttings
csv_path: /home
csv_filename: Report-{{date}}.csv
headers: Hostname,Version_String,Service_Tag
date: "{{ lookup('pipe', 'date +%Y%m%d-%H%M') }}"

tasks:
- name: Get Version String
dellemc.openmanage.idrac_system_info:
idrac_ip: "{{ idrac_ip }}"
idrac_user: "{{ idrac_user }}"
idrac_password: "{{ idrac_password }}"
validate_certs: false
register: vs

- name: Get Service Tag
dellemc.openmanage.idrac_system_info:
idrac_ip: "{{ idrac_ip }}"
idrac_user: "{{ idrac_user }}"
idrac_password: "{{ idrac_password }}"
validate_certs: false
register: svctag

- name: Create CSV
ansible.builtin.lineinfile:
path: "{{ csv_path }}/{{ csv_filename }}"
line: "{{ headers }}"
create: true
delegate_to: localhost

- name: Build out CSV file
ansible.builtin.lineinfile:
path: "{{ csv_path }}/{{ csv_filename}}"
line: "{{ inventory_hostname }},\
{{ vs.system_info.BIOS[0].VersionString }},\
{{ svctag.system_info.System[0].ServiceTag }}"
delegate_to: localhost

Al West:
Why run Get Service Tag after Get Version String. In Build out CSV file replace svctag with vs

BR:
Thanks @Al West it’s only for testing but will re-organize it. I think I am ok now. Will just add important details on my report. If anything unusual and need clarification again, will come back to this thread. Thank you!