JInja Warning using when condition

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

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

so that is not true anymore?

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

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.

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]: 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

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

TASK [resweb : debug] ********************************************************************************************************************************
task path: /home/tasks/main.yml:157
ok: [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] => {
“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] => {
“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’

  • 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] => {
“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’

TASK [resweb : debug]
********************************************************************************************************************************
task path: /home/tasks/main.yml:157
ok: [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] => {
    "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] => {
    "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

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

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

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

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

   tomcat.resweb.version~'-'~tomcat.resweb.build

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.

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, please ban this person from the list, at least but the person on permanently moderation.