[WARNING]: conditional statements should not include jinja2 templating delimiters such as {{ }} or {% %}. Found: result.stdout.find("{{rhel_version}}") != -1

SUMMARY

We are using the conditional check in our Ansible code where we are waiting for change to take effect before comparing in next block. Code reference below:

- name: Set RHEL version to "{{rhel_version}}"
  shell: |
    subscription-manager release --set="{{rhel_version}}"
  register: release
  changed_when: "release.rc == -1"
  failed_when: "release.rc >= 1"
  when: "('confluent.package_name[:-6]') not in ansible_facts.packages"

- name: Waiting until RHEL version changes to "{{rhel_version}}"
  shell: |
    subscription-manager release
  register: result
  until: result.stdout.find("{{rhel_version}}") != -1
  retries: 60
  delay: 5
  when: "('confluent.package_name[:-6]') not in ansible_facts.packages"

until: result.stdout.find(“{{rhel_version}}”) != -1 is giving the warning. So i tried changing it to
`until: result.stdout.find"(‘rhel_version’)" != -1´ but it gave another error.
The error was: template error while templating string: expected token ‘end of statement block’, got ‘string’. String: {% if result.stdout.find “(‘rhel_version’)” != -1 %} True {% else %} False {% endif %}"}

ISSUE TYPE- Bug Report
COMPONENT NAME

It is related to warning when we use jinja2 delimiters in conditional statement. But I am referencing a variable declared in global_vars file so i have no other option to reference it. I tried few combinations but didn’t work with syntax.
Now i am looking some help to convert ``until: result.stdout.find(“{{rhel_version}}”) != -1´´ this conditional string with another way to reference (“{{rhel_version}}”)

ANSIBLE VERSION

ansible 2.8.1
config file = /home/corp.eden/e974797adm/ikep-infrastructure/ansible/ansible.cfg
configured module search path = [u’/home/corp.eden/e974797adm/.ansible/plugins/modules’, u’/usr/share/ansible/plugins/modules’]
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.5 (default, Jun 11 2019, 12:19:05) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]

You don’t need the jinja blocks if you don’t quote the value, I.e.

until: result.stdout.find(rhel_version) != -1