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
`