After a server is started, I would like to wait for a specific response from a web healthcheck before continuing.
wait_for is great for waiting for a port to be opened, and uri would be useful for performing the healthcheck, but there’s no obvious way to combine them or just loop e.g.
An "until" has definitely been proposed. I have some concerns about
making until be based on a python style eval based since conditionals
using only_if are already rather unpopular compared to the "when"
variants, though I can't say I know a better way to do it.
It would end up looking like so, the way you've written it.
I’ve used the shell module using a bash ‘until’ loop a few times.
I think it would be most generalized if we could check any part of the json result.
What if until assumes that any key value pairs it gets are tests,
except for a few specific ones with an until, or maybe ‘u’ for short, prefix.
(used until parameters like timeout, number of tries, or sleep time inbetween attempts)
To reuse the example:
name: await healthcheck
local_action: uri url=http://host:port/healthcheck return_content=yes
until_string: udelay=30 content==yes
Or my own example, waiting for a kvm domain to shut off: