# Undefined variable exception while evaluating Do-Until loop

**URL:** <https://forum.ansible.com/t/undefined-variable-exception-while-evaluating-do-until-loop/19804>\
**Category:** Ansible Project\
**Created:** [November 19, 2015, 9:43am UTC](https://forum.ansible.com/t/undefined-variable-exception-while-evaluating-do-until-loop/19804 "2015-11-19T09:43:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![graywulf0](https://avatars.discourse-cdn.com/v4/letter/g/e8c25b/32.png) [@graywulf0](https://forum.ansible.com/u/graywulf0)\
**Post date:** [November 19, 2015, 9:43am UTC](https://forum.ansible.com/t/undefined-variable-exception-while-evaluating-do-until-loop/19804/1 "2015-11-19T09:43:33Z")

</div>

My Do-Until loop errors out if the until condition checks against a value that happens to contain a string like “{{ var }}”. I stepped through the Ansible code and it attempts to evaluate “var” then throws an undefined variable exception. I have no control over what echo\_result.stdout contains. How can I ask jinja2 to skip nested variable substitution and leave “{{ var }}” as is while evaluating the until condition?

I have simplified the scenario down to the following playbook below. Thanks in advance.

#ansible version:

# Branch: devel

# Commit: 2015-10-28 bdf5f70 James Cammarata Merge pull request #12950 from chrismeyersfsu/fix-ansible\_test\_service\_checksum

`

- hosts: localhost  
gather\_facts: no  
sudo: yes  
tasks:
- name: Set facts  
set\_fact:  
lb: ‘{’  
v: ‘x’  
rbs: ‘}}’

# works

- name: Echo a variable  
command: echo “abc {{ v }}”  
register: echo\_result  
until: “echo\_result.stdout.find(‘abc’) != -1”
- debug: var=echo\_result

# breaks

- name: Echo a nested jinja2 variable  
command: echo “abc {{ lb }}{{ lb }} {{ v }} {{ rbs }}”  
register: echo\_result  
until: “echo\_result.stdout.find(‘abc’) != -1”
- debug: var=echo\_result

`
