Integer comparison if condition jinja2 template Ansible does not work

560 views
Skip to first unread message

Shifa Shaikh

unread,
Mar 26, 2020, 2:21:17 PM3/26/20
to Ansible Project
My jinja2 template yields correct value for the variable

{{ vars[allip.name | join("")] | default('ERR') }}

The variable has value 82.3 which gets printed by Ansible's template module.

I wish to write an if condition where I want to check if the value of the variable is more than 80 

{% if ( vars[allip.name | join("")] | int ) > 80 %}

<th>MORE THAN 80</th>

{% endif %}

However, the 'if' the condition does not meet.

I tried  

{% if ( vars[allip.name | join("")] | int  > 80 ) %}

I also tried

{% if vars[allip.name | join("")] | int  > 80 %}

But, none of them worked. Can you please let me know what needs to be done to meet the if condition?
Reply all
Reply to author
Forward
0 new messages