Wait for service restart

Hey guys,

Is there a way to restart a service and wait for it to finish?
I’m starting Keepalived using the service module and apparently it takes a few seconds to actually start after installation so it’s throwing me an error.

  • name: “Start Keepalived”
    service:
    name: keepalived
    state: start

You can use the 'wait_for' module, just need a condition that verifies
the service is up, sadly most 'service managers' report the success of
'startup command' and not that the service is actually up.

Alternatively you can use service_facts to check for the service
status in an until loop that wait for it's success (assuming service
manager reports correct status).