What you need to use here is selectattr and equalto from jinja2:
results|selectattr('restart_needed', 'equalto', true)|list|length
If my memory is correct, `equalto` was not added until jinja2 v2.8
On Fri, Aug 25, 2017 at 7:42 AM, lovi <[email protected]> wrote:
> Hello,
>
> I am struggling with this kind of structure :
>
> {
> "out.results": [
> {
> "_ansible_item_result": true,
> "_ansible_no_log": false,
> "_ansible_parsed": true,
> "changed": false,
> "exitcode": "NoChangeNeeded",
> "feature_result": [],
> "item": "A",
> "restart_needed": false,
> "success": true
> },
> {
> "_ansible_item_result": true,
> "_ansible_no_log": false,
> "_ansible_parsed": true,
> "changed": false,
> "exitcode": "NoChangeNeeded",
> "feature_result": [],
> "item": "B",
> "restart_needed": false,
> "success": true
> },
> {
> "_ansible_item_result": true,
> "_ansible_no_log": false,
> "_ansible_parsed": true,
> "changed": false,
> "exitcode": "NoChangeNeeded",
> "feature_result": [],
> "item": "C",
> "restart_needed": false,
> "success": true
> },
> {
> "_ansible_item_result": true,
> "_ansible_no_log": false,
> "_ansible_parsed": true,
> "changed": false,
> "exitcode": "NoChangeNeeded",
> "feature_result": [],
> "item": "D",
> "restart_needed": true,
> "success": true
> }
> ]
> }
>
> And I want to catch if restart_needed is true ... any help is welcome.
>
> Regards
>
> --
> 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/3d322346-3ab2-4f63-89eb-fc8be3de96f2%40googlegroups.
> com
> <https://groups.google.com/d/msgid/ansible-project/3d322346-3ab2-4f63-89eb-fc8be3de96f2%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
Matt Martz
@sivel
sivel.net
--
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/CAD8N0v_m7%2BSgDrkE5sDV%2BKp5sQooDrwKBrESE-kgnJkfpCMFiw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.