On Monday, 7 January 2019 17:21:41 CET Rama wrote:
> Hi All,
>
> 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.
>
> Output:
> "msg": {
> "key": "devices",
> "value": [
> {
> "configuration": "Configured",
> "version": "PD-0.7",
> "label": "device-1",
> "location": "1",
> "serial_number": "PWH12GVF",
> "status": "OK"
> },
> {
> "configuration": "Configured",
> "version": "PD-0.7",
> "label": "device-2",
> "location": "2",
> "serial_number": "PWH12GWF",
> "status": "OK"
> },
> {
> "configuration": "Configured",
> "version": "PD-0.7",
> "label": "device-3",
> "location": "3",
> "serial_number": "PWH12GXF",
> "status": "CRITICAL"
> }
> ]
> }
You can use the Jinja selectattr
{{ msg.value | selectattr('status', 'equalto', 'CRITICAL') | list }}
--
Kai Stian Olstad
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/1654617.bM51AVdTq8%40x1.
For more options, visit https://groups.google.com/d/optout.