Ansible – ‘until’ loop
Contents
Introduction
In this short post I'll introduce you to lesser known type of Ansible loop: "until" loop. This loop is used for retrying task until certain condition is met.
To use this loop in task you essentially need to add 3 arguments to your task arguments:
until
- condition that must be met for loop to stop. That is Ansible will continue executing the task until expression used here evaluates to true.
retry
- specifies how many times we want to run the task before Ansible gives up.
delay
- delay, in seconds, between retries.
As an example, below task will keep sending GET request to specified URL until the "status" key in response is equal to "READY". We ask Ansible to make 10 attempts in total with delay of 1 second between each attempt. If after final attempt condition in until
is still not met task is marked as failed.
- name: Wait until web Continue reading