failed_when to fail after retries have been used

I am looking for a way for below to cause a failure, if the health check fails to see an “UP” message after 10 attempts.

  • name: health check - wait for endpoints to become available
    action: shell curl http://endpoint/health"
    register: curl_output

until: curl_output.stdout.find(“UP”) > -1
changed_when: false
retries: 10
delay: 10

Could you add a task straight after to use the assert module to check the contents of curl_output?

Jon

I may try to check the value of “attempts”, and fail the task if we reach 10 attempts.