Hi,

inside 'when' all variables are automatically accessible, so you don't have
to use brackets. This should work:
when: item.acl_mask >= threshold

kind regards
Pshem


On Tue, 5 Mar 2019 at 07:39, Spiro Mitsialis <[email protected]>
wrote:

> I have a playbook that performs a command on a router and then parses the
> output.  So far no problem.
> I'm then trying to check if any of the variables back from the parser are
> >=   threshold.  The threshold is defined as a variable in the playbook.
> No problem with it.
> vars:
>   threshold: 90
>   tcam_full: False
>
> Although I do not get any error messages the following is never true, even
> when it should be.  Is there a way to make it work?
>    - name: check ACL Mask
>      set_fact:
>        tcam_full: true
>      when: item.acl_mask >= "{{ threshold }}"
>      with_items: "{{ tcam.tcam_resources }}"
>
> If I add a threshold manually like below it works fine.  I have several of
> these statements and would rather not hard code the threshold value
>    - name: check ACL Entries
>      set_fact:
>        tcam_full: true
>      when: item.acl_ent >= 90
>      with_items:  "{{ tcam.tcam_resources }}"
>
> Finally, I also get a warning message about using jinja2 templates with a
> when statement.  How should I be doing it? I've had similar messages when
> checking if a {{ variable }} == something.
>
> [WARNING]: when statements should not include jinja2 templating delimiters
> 36
> such as {{ }} or {% %}. Found: item.acl_mask >= "{{ threshold }}"
>
> --
> 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/3520d313-7ad3-4770-8584-0255f5ecc59d%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/3520d313-7ad3-4770-8584-0255f5ecc59d%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAEaZiRXjWwUew8gfLepsyiUDLizDpdfV5iwiF1ZaL52G1Tz85w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to