when: unit_number == {{ disk_unit }} [WARNING]: conditional statements should not include jinja2 templating delimiters such as {{ }} or {% %}. Found: unit_number == {{ disk_unit }}---
- 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[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--
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 ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/92770bd7-d206-4a8c-83a8-0c949313557d%40googlegroups.com.
I'm not sure, but it sounds a bit as if the things you are comparing do not contain the values you think they do....
when: item.unit_number|int == disk_unit|int
What does "no longer works" mean? What did you expect, what did you get?The warning is correct - you should not use the braces in a when statement.I'm not sure, but it sounds a bit as if the things you are comparing do not contain the values you think they do....Regards, K.
On Fri, Sep 13, 2019 at 7:42 PM MKPhil <phil....@gmail.com> 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 ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/92770bd7-d206-4a8c-83a8-0c949313557d%40googlegroups.com.