# using when something \> variable

**URL:** <https://forum.ansible.com/t/using-when-something-variable/29822>\
**Category:** Ansible Project\
**Created:** [March 4, 2019, 6:39pm UTC](https://forum.ansible.com/t/using-when-something-variable/29822 "2019-03-04T18:39:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Spiro\_Mitsialis](https://avatars.discourse-cdn.com/v4/letter/s/c57346/32.png) [@Spiro\_Mitsialis](https://forum.ansible.com/u/Spiro_Mitsialis)\
**Post date:** [March 4, 2019, 6:39pm UTC](https://forum.ansible.com/t/using-when-something-variable/29822/1 "2019-03-04T18:39:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Pshem\_Kowalczyk](https://avatars.discourse-cdn.com/v4/letter/p/e480ec/32.png) [@Pshem\_Kowalczyk](https://forum.ansible.com/u/Pshem_Kowalczyk)\
**Post date:** [March 4, 2019, 7:12pm UTC](https://forum.ansible.com/t/using-when-something-variable/29822/2 "2019-03-04T19:12:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Spiro\_Mitsialis](https://avatars.discourse-cdn.com/v4/letter/s/c57346/32.png) [@Spiro\_Mitsialis](https://forum.ansible.com/u/Spiro_Mitsialis)\
**Post date:** [March 4, 2019, 8:14pm UTC](https://forum.ansible.com/t/using-when-something-variable/29822/3 "2019-03-04T20:14:58Z")

</div>

Thanks, it worked.
