Question: Why the "until" conditional doesn't wait until the end of a multiple commands execution so that the "results" array is built and a specific element of the results list can be evaluated in the until condition?
Example: I've got a multi-item command that I want to repeat until a certain condition is met.
#Mount /dev/mapper/image-glance --> Abort execution if cannot mount it"
- name: mount /dev/mapper/image-glance
command: "{{ item }}"
with_items:
- sh -c "mount /dev/mapper/image-glance"
- sh -c "sleep 40"
- sh -c "findmnt /dev/mapper/image-glance"
register: mount_findmnt
retries: 3
delay: 1
until: '"/var/lib/glance" in mount_findmnt.results[2].stdout'
I'm interested only in the stdout of the third command
findmnt /dev/mapper/image-glance
For this reason I specified in the "until" conditional --> results[2]
mount_findmnt.results[2].stdout
Nevertheless it seems like the "until" conditional is checked as soon as the first command
mount /dev/mapper/image-glance
is executed and not at the end of the execution of all 3 commands.
For this reason the playbook fails with the following:
FAILED! => {"failed": true, "msg": "The conditional check '\"/dev/mapper/image-glance\" in mount_findmnt.results[2].stdout' failed. The error was: error while evaluating conditional (\"/dev/mapper/image-glance\" in mount_findmnt.results[2].stdout): 'dict object' has no attribute 'results'"}
as at this point results[2] wouldnt be present.
If I comment the "until" conditional and I print "mount_findmnt" I can see the list "results" and results[2] would be present as the building of list results is not stopped by the until conditional.