Hi,

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"}

On Monday, January 7, 2019 at 10:46:16 PM UTC+5:30, Kai Stian Olstad wrote:
>
> 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/a63711f1-b2df-4ae5-a254-fa0c25fe2cf0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to