# JInja Warning using when condition

**URL:** <https://forum.ansible.com/t/jinja-warning-using-when-condition/28087>\
**Category:** Ansible Project\
**Created:** [July 19, 2018, 6:29am UTC](https://forum.ansible.com/t/jinja-warning-using-when-condition/28087 "2018-07-19T06:29:13Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sreejith\_Sreejayan](https://avatars.discourse-cdn.com/v4/letter/s/278dde/32.png) [@Sreejith\_Sreejayan](https://forum.ansible.com/u/Sreejith_Sreejayan)\
**Post date:** [July 19, 2018, 6:29am UTC](https://forum.ansible.com/t/jinja-warning-using-when-condition/28087/1 "2018-07-19T06:29:13Z")

</div>

any way to avoid jinja warning in when condition [WARNING]: when statements should not include jinja2 templating delimiters such as {{ }} or {% %}. Found: ‘{{ tomcat.resweb.version }}-{{ tomcat.resweb.build }}’ not in webpage.content

#used the alternative solution tomcat.resweb.version ~ ‘-’ ~ tomcat.resweb.build not in webpage.content but its not taking the value from the variable file

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [July 19, 2018, 7:42am UTC](https://forum.ansible.com/t/jinja-warning-using-when-condition/28087/2 "2018-07-19T07:42:13Z")

</div>

Just a few days ago you said that it work with parenthesis ref  
[https://groups.google.com/forum/#!msg/ansible-project/Zd-q59A3DQY/wd5rIeVYCQAJ](https://groups.google.com/forum/#!msg/ansible-project/Zd-q59A3DQY/wd5rIeVYCQAJ)

so that is not true anymore?

---

<div class="post-metadata">

**Author:** ![Sreejith\_Sreejayan](https://avatars.discourse-cdn.com/v4/letter/s/278dde/32.png) [@Sreejith\_Sreejayan](https://forum.ansible.com/u/Sreejith_Sreejayan)\
**Post date:** [July 19, 2018, 9:35am UTC](https://forum.ansible.com/t/jinja-warning-using-when-condition/28087/3 "2018-07-19T09:35:45Z")

</div>

nope is not not taking the value from the variable file task getting failed

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [July 20, 2018, 7:54am UTC](https://forum.ansible.com/t/jinja-warning-using-when-condition/28087/4 "2018-07-20T07:54:32Z")

</div>

Then you must have some errors in your code, because this is something that people use every day.  
But since you haven't shared any code it is impossible to help.

---

<div class="post-metadata">

**Author:** ![Sreejith\_Sreejayan](https://avatars.discourse-cdn.com/v4/letter/s/278dde/32.png) [@Sreejith\_Sreejayan](https://forum.ansible.com/u/Sreejith_Sreejayan)\
**Post date:** [July 20, 2018, 10:36am UTC](https://forum.ansible.com/t/jinja-warning-using-when-condition/28087/5 "2018-07-20T10:36:42Z")

</div>

this is task code

- name: Fail when the version does not match  
action: fail  
when: tomcat.resweb.version~ ‘-’ ~tomcat.resweb.build not in webpage.content  
register: version\_check

Debug log  
TASK [resweb : Fail when the version does not match] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
task path: /home/vj7h/allegiant\_git/sdlc\_deploy/roles/resweb/tasks/main.yml:158  
fatal: [[lhqqa1rwbws01.qa1.allegiantair.com](http://lhqqa1rwbws01.qa1.allegiantair.com)]: FAILED! =\> {  
“changed”: false,  
“msg”: “Failed as requested from task”  
}  
…ignoring  
META: ran handlers  
META: ran handlers  
Read vars\_file ‘vars/versions.yml’  
skipping vars\_file ‘vars/{{ ansible\_domain }}/jboss\_properties\_vars\_commercial.yml’ due to an undefined variable

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [July 20, 2018, 11:01am UTC](https://forum.ansible.com/t/jinja-warning-using-when-condition/28087/6 "2018-07-20T11:01:43Z")

</div>

And if you set these three task before this fail task, what is the output of them.

- debug: var=tomcat.resweb.version  
- debug: var=tomcat.resweb.build  
- debug: var=webpage.content

---

<div class="post-metadata">

**Author:** ![Sreejith\_Sreejayan](https://avatars.discourse-cdn.com/v4/letter/s/278dde/32.png) [@Sreejith\_Sreejayan](https://forum.ansible.com/u/Sreejith_Sreejayan)\
**Post date:** [July 20, 2018, 11:29am UTC](https://forum.ansible.com/t/jinja-warning-using-when-condition/28087/7 "2018-07-20T11:29:32Z")

</div>

TASK [resweb : debug] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
task path: /home/tasks/main.yml:157  
ok: [[lhqqa1rwbws01.qa1.allegiantair.com](http://lhqqa1rwbws01.qa1.allegiantair.com)] =\> {  
“tomcat.resweb.version”: “2.61.1”  
}

TASK [resweb : debug] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
task path: /home/tasks/main.yml:158  
ok: [[lhqqa1rwbws01.qa1.allegiantair.com](http://lhqqa1rwbws01.qa1.allegiantair.com)] =\> {  
“tomcat.resweb.build”: “d478a03”  
}  
Read vars\_file ‘vars/versions.yml’  
Read vars\_file ‘vars/yum\_logic.yml’

TASK [resweb : debug] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
task path: /home/tasks/main.yml:159  
ok: [[lhqqa1rwbws01.qa1.allegiantair.com](http://lhqqa1rwbws01.qa1.allegiantair.com)] =\> {  
“webpage.content”: "\n\n\n\n\n\n \n \<script type="text/javascript" src="js/jquery-1.7.1.min.js"\>\n \<script type="text/javascript"\>\n\n var resWebVersion = "2.62.4-7ca3135 (Build DateTime: 2018-07-03T05:53:23)  
Read vars\_file ‘vars/versions.yml’  
Read vars\_file ‘vars/yum\_logic.yml’

---

<div class="post-metadata">

**Author:** ![Sreejith\_Sreejayan](https://avatars.discourse-cdn.com/v4/letter/s/278dde/32.png) [@Sreejith\_Sreejayan](https://forum.ansible.com/u/Sreejith_Sreejayan)\
**Post date:** [July 20, 2018, 11:49am UTC](https://forum.ansible.com/t/jinja-warning-using-when-condition/28087/8 "2018-07-20T11:49:12Z")

</div>

- debug: var=“{{ tomcat.resweb.version~ ‘-’ ~tomcat.resweb.build }}”

TASK [resweb : debug] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
task path: /home/vj7h/allegiant\_git/sdlc\_deploy/roles/resweb/tasks/main.yml:157  
ok: [[lhqqa1rwbws01.qa1.allegiantair.com](http://lhqqa1rwbws01.qa1.allegiantair.com)] =\> {  
“2.61.1-d478a03”: “VARIABLE IS NOT DEFINED!: float object has no element 1”  
}  
Read vars\_file ‘vars/versions.yml’  
Read vars\_file ‘vars/yum\_logic.yml’

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [July 20, 2018, 11:54am UTC](https://forum.ansible.com/t/jinja-warning-using-when-condition/28087/9 "2018-07-20T11:54:52Z")

</div>

> TASK [resweb : debug]  
> \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
> task path: /home/tasks/main.yml:157  
> ok: [lhqqa1rwbws01.qa1.allegiantair.com] =\> {  
> &nbsp;&nbsp;&nbsp;&nbsp;"tomcat.resweb.version": "2.61.1"  
> }
> 
> TASK [resweb : debug]  
> \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
> task path: /home/tasks/main.yml:158  
> ok: [lhqqa1rwbws01.qa1.allegiantair.com] =\> {  
> &nbsp;&nbsp;&nbsp;&nbsp;"tomcat.resweb.build": "d478a03"  
> }  
> Read vars\_file 'vars/versions.yml'  
> Read vars\_file 'vars/yum\_logic.yml'

So tomcat.resweb.version~ '-' ~tomcat.resweb.build would become 2.61.1-d478a03

> TASK [resweb : debug]  
> \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
> task path: /home/tasks/main.yml:159  
> ok: [lhqqa1rwbws01.qa1.allegiantair.com] =\> {  
> &nbsp;&nbsp;&nbsp;&nbsp;"webpage.content": "\<!doctype html\>\n\n\n\n\<html\>\n\<head\>\n \n  
> \<script type=\"text/javascript\"  
> src=\"js/jquery-1.7.1.min.js\"\>\</script\>\n \<script  
> type=\"text/javascript\"\>\n\n var resWebVersion = \"2.62.4-7ca3135  
> (Build DateTime: 2018-07-03T05:53:23)\  
> Read vars\_file 'vars/versions.yml'  
> Read vars\_file 'vars/yum\_logic.yml'

And 2.61.1-d478a03 is not in webpage.content

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [July 20, 2018, 11:57am UTC](https://forum.ansible.com/t/jinja-warning-using-when-condition/28087/10 "2018-07-20T11:57:02Z")

</div>

var takes a variable name not the content, you must use msg for that.

- debug: msg="{{ tomcat.resweb.version~ '-' ~tomcat.resweb.build }}"

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [July 20, 2018, 1:11pm UTC](https://forum.ansible.com/t/jinja-warning-using-when-condition/28087/11 "2018-07-20T13:11:14Z")

</div>

Looks like you are not leaving a space between the vars and operators,  
~ should not be attached to the var name.  
tomcat.resweb.version ~ '-' ~ tomcat.resweb.build

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [July 20, 2018, 1:57pm UTC](https://forum.ansible.com/t/jinja-warning-using-when-condition/28087/12 "2018-07-20T13:57:18Z")

</div>

Actually, the spaces isn't needed at all, this will also work

&nbsp;&nbsp;&nbsp;tomcat.resweb.version~'-'~tomcat.resweb.build

---

<div class="post-metadata">

**Author:** ![Badraj\_Angirekula](https://avatars.discourse-cdn.com/v4/letter/b/a4c791/32.png) [@Badraj\_Angirekula](https://forum.ansible.com/u/Badraj_Angirekula)\
**Post date:** [August 27, 2018, 9:29am UTC](https://forum.ansible.com/t/jinja-warning-using-when-condition/28087/13 "2018-08-27T09:29:15Z")

</div>

Hi all,

please help me.

Build ec2 instances with attaching multiple tags names :-  
For example- I have launched one ec2 instance with tag name “websever1” the next builds of ec2 instances should start with tag name webserver2 , webserver3 … automatically.

Note: No two ec2 instances have same tag name.

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [August 27, 2018, 9:42am UTC](https://forum.ansible.com/t/jinja-warning-using-when-condition/28087/14 "2018-08-27T09:42:36Z")

</div>

Can you stop spamming the list?

This is the second time you hijack 5-10 threads that has nothing to do with your problem.

[@admins](https://forum.ansible.com/groups/admins), please ban this person from the list, at least but the person on permanently moderation.
