# until loop in shell module

**URL:** <https://forum.ansible.com/t/until-loop-in-shell-module/24458>\
**Category:** Ansible Project\
**Created:** [May 11, 2017, 9:38am UTC](https://forum.ansible.com/t/until-loop-in-shell-module/24458 "2017-05-11T09:38:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mhh](https://avatars.discourse-cdn.com/v4/letter/m/34f0e0/32.png) [@mhh](https://forum.ansible.com/u/mhh)\
**Post date:** [May 11, 2017, 9:38am UTC](https://forum.ansible.com/t/until-loop-in-shell-module/24458/1 "2017-05-11T09:38:31Z")

</div>

Im thinking…, why this does not work?

**Task:**

- name: Run validation query on db localy  
shell: docker exec -i postgres bash -c ‘psql -v --username “postgres” --dbname “postgres” -c “select 1”’  
delegate\_to: “{{ item }}”  
with\_items: “{{ groups.postgres\_server}}”  
register: validation  
until: validation.results[0].stderr == “”  
retries: 10  
delay: 30  
ignore\_errors: false  
become: true  
become\_user: root  
become\_method: sudo

**Result:**  
fatal: [localhost]: FAILED! =\> {“failed”: true, “msg”: “The conditional check ‘validation.results[0].stderr == ""’ failed. The error was: error while evaluating conditional (validation.results[0].stderr == ""): ‘dict object’ has no attribute ‘results’”}

**Task:**

- debug:  
msg: “{{ validation.results[0].stdout }}”

**Result:**  
ok: [localhost] =\> {  
“msg”: “”  
}

---

<div class="post-metadata">

**Author:** ![mhh](https://avatars.discourse-cdn.com/v4/letter/m/34f0e0/32.png) [@mhh](https://forum.ansible.com/u/mhh)\
**Post date:** [May 11, 2017, 10:08am UTC](https://forum.ansible.com/t/until-loop-in-shell-module/24458/2 "2017-05-11T10:08:05Z")

</div>

I guess that i have compare it like…

- debug:  
msg: “{{ hostvars[inventory\_hostname][validation.results[0].stderr] }}”

But still not working…

Dne čtvrtek 11. května 2017 11:38:32 UTC+2 mhh napsal(a):

---

<div class="post-metadata">

**Author:** ![mhh](https://avatars.discourse-cdn.com/v4/letter/m/34f0e0/32.png) [@mhh](https://forum.ansible.com/u/mhh)\
**Post date:** [May 11, 2017, 10:11am UTC](https://forum.ansible.com/t/until-loop-in-shell-module/24458/3 "2017-05-11T10:11:26Z")

</div>

This is working…

- debug:  
msg: “{{ hostvars[inventory\_hostname].validation.results[0].stderr }}”

Dne čtvrtek 11. května 2017 12:08:05 UTC+2 mhh napsal(a):

---

<div class="post-metadata">

**Author:** ![mhh](https://avatars.discourse-cdn.com/v4/letter/m/34f0e0/32.png) [@mhh](https://forum.ansible.com/u/mhh)\
**Post date:** [May 11, 2017, 10:17am UTC](https://forum.ansible.com/t/until-loop-in-shell-module/24458/4 "2017-05-11T10:17:09Z")

</div>

But how to implement in until condition ?

Dne čtvrtek 11. května 2017 12:11:26 UTC+2 mhh napsal(a):
