firmware gathering - ansible prints last value

Hi Experts,

I am using below playbook to gather firmware from dell servers it works well but the problem is when same component shows twice or more with different value it just print last value.My requirement to print first value in the loop to get exact current firmware.

Playbook:

tasks:

  • name: Get default system, user and firmware information
    redfish_info:
    category: Update
    baseuri: “{{ inventory_hostname }}”
    username: “#####”
    password: “#####”
    register: drac

  • set_fact:
    test: “{{ drac | json_query(my_query) }}”
    vars:
    my_query: “redfish_facts.firmware.entries.{Name : Name, Version: Version}”

  • debug: msg=“{{ drac }}”

  • set_fact:
    firmware: “{{phonebook|default({}) | combine ( {item.Name : item.Version}) }}”
    with_items: “{{ test | json_query(‘[*]’) }}”
    vars:
    firmware:

  • name: Firmware Vaule
    debug: var=firmware

Actual Ouput:

“firmware”: {
“BIOS”: “1.4.8”, ======================>This need to be 2.4.8
“BP14G+EXP 0:1”: “2.17”,
“Dell 32 Bit uEFI Diagnostics, version 4301, 4301A13, 4301.14”: “4301A13”,
“Dell OS Driver Pack, 17.08.12, A00”: “17.08.12”,
“Disk 0 in Backplane 1 of RAID Controller in Slot 6”: “DL5C”,
“Disk 2 in Backplane 1 of RAID Controller in Slot 6”: “DL5C”,
“Integrated Dell Remote Access Controller”: “3.15.17.15”,
“Intel(R) Ethernet Converged Network Adapter X710 - F8:F2:1E:1F:3E:E0”: “19.0.12”,
“Intel(R) Ethernet Converged Network Adapter X710 - F8:F2:1E:1F:3E:E2”: “19.0.12”,
“Intel(R) Gigabit 4P X710/I350 rNDC - 24:6E:96:D1:77:58”: “19.0.12”,
“Lifecycle Controller”: “4.00.00.00”,
“OS COLLECTOR, 3.0, A00”: “3.0”,
"PERC H740P Adapter ": “50.3.0-1022”,
“Power Supply.Slot.1”: “00.23.32”,
“QLogic QLE2692 16Gb FC Adapter - 21000024FF1EFD60”: “15.00.00”,
“System CPLD”: “1.0.1”,
“iDRAC Service Module Installer 3.1.0, A00”: “3.1.0”
}

The loop output shows BIOS output three times.We would need first value if BIOS 2.4.8.

{u’Version’: u’19.0.12’, u’Name’: u’Intel(R) Ethernet Converged Network Adapter X710 - F8:F2:1E:1F:3E:E0’})
{u’Version’: u’19.0.12’, u’Name’: u’Intel(R) Ethernet Converged Network Adapter X710 - F8:F2:1E:1F:3E:E2’})
{u’Version’: u’19.0.12’, u’Name’: u’Intel(R) Gigabit 4P X710/I350 rNDC - 24:6E:96:D1:77:58’})
{u’Version’: u’2.46’, u’Name’: u’BP14G+EXP 0:1’})
{u’Version’: u’15.00.00’, u’Name’: u’QLogic QLE2692 16Gb FC Adapter - 21000024FF1EFD60’})
{u’Version’: u’50.9.3-2949’, u’Name’: u’PERC H740P Adapter ‘})
{u’Version’: u’2.4.8’, u’Name’: u’BIOS’})
{u’Version’: u’3.0’, u’Name’: u’OS COLLECTOR, 3.0, A00’})
{u’Version’: u’19.0.12’, u’Name’: u’Intel(R) Ethernet Converged Network Adapter X710 - F8:F2:1E:1F:3E:E0’})
{u’Version’: u’19.0.12’, u’Name’: u’Intel(R) Ethernet Converged Network Adapter X710 - F8:F2:1E:1F:3E:E2’})
{u’Version’: u’19.0.12’, u’Name’: u’Intel(R) Gigabit 4P X710/I350 rNDC - 24:6E:96:D1:77:58’})
{u’Version’: u’2.46’, u’Name’: u’BP14G+EXP 0:1’})
{u’Version’: u’15.00.00’, u’Name’: u’QLogic QLE2692 16Gb FC Adapter - 21000024FF1EFD60’})
{u’Version’: u’3.1.0’, u’Name’: u’iDRAC Service Module Installer 3.1.0, A00’})
{u’Version’: u’00.23.32’, u’Name’: u’Power Supply.Slot.1’})
{u’Version’: u’50.9.3-2949’, u’Name’: u’PERC H740P Adapter ‘})
{u’Version’: u’DL5C’, u’Name’: u’Disk 0 in Backplane 1 of RAID Controller in Slot 6’})
{u’Version’: u’DL5C’, u’Name’: u’Disk 2 in Backplane 1 of RAID Controller in Slot 6’})
{u’Version’: u’2.4.8’, u’Name’: u’BIOS’})
{u’Version’: u’17.08.12’, u’Name’: u’Dell OS Driver Pack, 17.08.12, A00’})
{u’Version’: u’4.00.00.00’, u’Name’: u’Integrated Dell Remote Access Controller’})
{u’Version’: u’4301A13’, u’Name’: u’Dell 32 Bit uEFI Diagnostics, version 4301, 4301A13, 4301.14’})
{u’Version’: u’1.0.1’, u’Name’: u’System CPLD’})
{u’Version’: u’4.00.00.00’, u’Name’: u’Lifecycle Controller’})
{u’Version’: u’2.17’, u’Name’: u’BP14G+EXP 0:1’})
{u’Version’: u’50.3.0-1022’, u’Name’: u’PERC H740P Adapter ‘})
{u’Version’: u’1.4.8’, u’Name’: u’BIOS’})
{u’Version’: u’3.15.17.15’, u’Name’: u’Integrated Dell Remote Access Controller’})

Regards
Kumar