Hey,

This is a genuine warning and was added to the 2.3 release purposefully. 
You don't need to use any special character at all and it will get rid of 
the warning. 

Simply, use the when statement as below:
---
- hosts: localhost
  connection: local
  gather_facts: false
  vars:
    unit_number: 10
    disk_unit: 10
  tasks:
  - debug:
     msg: "Hola, it works"
    when: unit_number == disk_unit

Below is the output:
[root@oss-awx-01 AnsQuery]# ansible-playbook query.yml

PLAY [localhost] 
*********************************************************************************************************************

TASK [debug] 
*************************************************************************************************************************
ok: [localhost] => {
    "msg": "Hola, it works"
}

PLAY RECAP 
***************************************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=0 
   skipped=0    rescued=0    ignored=0

Hope it is helpful !

Thanks,
Shivharsh

On Friday, 13 September 2019 15:12:14 UTC+5:30, MKPhil wrote:
>
>
> I'm trying to compare two variables in a "when" statement - when x = y do 
> something.
>
> This code works:
>
> when: unit_number == {{ disk_unit }}
>
>
> BUT I get a warning:
>
>  [WARNING]: conditional statements should not include jinja2 templating 
> delimiters such as {{ }} or {% %}. Found: unit_number == {{ disk_unit }}
>
>
> If I remove the {{ }} the statement no longer works.  How should I write 
> the statement so it works and doesn't give the warning?  I've tried various 
> combinations of double and single quotes and round brackets.
>
>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/fe47e444-bf7a-4f73-ae4f-fa09bad89efd%40googlegroups.com.

Reply via email to