opiproject / ansible-opi-dpu

Ansible Modules for DPUs
Apache License 2.0
6 stars 8 forks source link

fw_inventory_after.redfish_facts.firmware.entries[0].Version : use name instead of `[0]` #19

Closed glimchb closed 6 months ago

glimchb commented 6 months ago

from #2

use https://docs.ansible.com/ansible/latest/collections/community/general/json_query_filter.html

example verbose log:

ok: [10.10.10.1 -> localhost] => {
    "changed": false,
    "invocation": {
        "module_args": {
            "auth_token": null,
            "baseuri": "10.10.10.1",
            "category": [
                "Update"
            ],
            "command": [
                "GetFirmwareInventory"
            ],
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "timeout": null,
            "update_handle": null,
            "username": "root"
        }
    },
    "redfish_facts": {
        "firmware": {
            "entries": [
                {
                    "Id": "BMC_Firmware",
                    "Manufacturer": "",
                    "Name": "Software Inventory",
                    "SoftwareId": "0x0018",
                    "Status": {
                        "Conditions": [],
                        "Health": "OK",
                        "HealthRollup": "OK",
                        "State": "Enabled"
                    },
                    "Updateable": true,
                    "Version": "BF-23.10-5"
                },
                {
                    "Id": "Bluefield_FW_ERoT",
                    "Manufacturer": "NVIDIA",
                    "Name": "Software Inventory",
                    "SoftwareId": "0xFF00",
                    "Status": {
                        "Conditions": [],
                        "Health": "OK",
                        "HealthRollup": "OK",
                        "State": "Enabled"
                    },
                    "Updateable": true,
                    "Version": "00.02.0127.0000_n02"
                },
                {
                    "Id": "golden_image_arm",
                    "Name": "Software Inventory",
                    "SoftwareId": "",
                    "Status": {
                        "Conditions": [],
                        "Health": "OK",
                        "HealthRollup": "OK",
                        "State": "Enabled"
                    },
                    "Updateable": true,
                    "Version": "no valid golden_image_arm!!!!"
                },
                {
                    "Id": "golden_image_nic",
                    "Name": "Software Inventory",
                    "SoftwareId": "",
                    "Status": {
                        "Conditions": [],
                        "Health": "OK",
                        "HealthRollup": "OK",
                        "State": "Enabled"
                    },
                    "Updateable": true,
                    "Version": "no valid golden_image_nic!!!!"
                }
            ],
            "ret": true
        }
    }
}

TASK [get_bmc_facts : Extract BMC firmware version from inventory] **************************************************************************************************************************
task path: /home/user/ansible-opi-dpu/roles/get_bmc_facts/tasks/main.yml:17
ok: [10.10.10.1] => {
    "ansible_facts": {
        "bmc_firmware_version": "BF-23.10-5"
    },
    "changed": false
}