Wait for service restart

28 views
Skip to first unread message

Mehdi Khlifi

unread,
Feb 10, 2021, 10:51:05 AM2/10/21
to Ansible Project
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

Brian Coca

unread,
Feb 10, 2021, 10:54:51 AM2/10/21
to Ansible Project
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).


--
----------
Brian Coca

Reply all
Reply to author
Forward
0 new messages