Our required in-built module gives huge output of different keys that have multiple values with objects. I used ‘with_dict’ and when to narrow and get desired output as below. Here also am facing a road block that how can I get the element where any value doesn’t meet. How can get output of the block when “status”: “CRITICAL” instead of all.
Thank you for your reply. I added another ‘debug’, var with given jinja variable. But unfortunately, it gives error with below. Can you please assist.
fatal: [localhost]: FAILED! => {“msg”: “The task includes an option with an undefined variable. The error was: ‘msg’ is undefined\n\nThe error appears to have been in ‘/root/devices…yml’: line 20, column 6, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - debug:\n ^ here\n”}
You don't have any variable in here called msg, so when you use msg in the debug task it will fail with undefined variable.
In you first mail you did have an output that was called msg.
ah, again the same error with msg rather than var
TASK [debug] **************************************************************************************************************************************
fatal: [localhost]: FAILED! => {“msg”: “Unexpected failure during module execution.”}
I am facing another issue. In the first scenario we used {{hw_health.storage[‘Controller on System Board’][‘logical_drives’][0][‘physical_drives’] | selectattr(‘status’, ‘match’, ‘Failed’) | list}} where only one physical_drives. Some servers having two “physical_drives” sections. The status: Failed may happen either sections. Can you please help me here how can we get the Failed list from either.
It's not pretty and it's probably a better way to this, but this should work
"{{ hw_health.storage['Controller on System Board'].logical_drives | map(attribute='physical_drives') | list | flatten | selectattr('status', 'match', 'OK') | list }}"