In my Ansible play I am restarting database then trying to do some operations on it. Restart command returns as soon as restart is started, not when db is up. Next command t
Consider using wait_for module. It waits for a condition before continuing, for example for a port to become open or closed, for a file to exist or not, or for some content in a file.
Without seeing the rest of your playbook, consider the following example:
- name: Wait for db server to restart
local_action:
wait_for:
host=192.168.50.4
port=3306
delay=1
timeout=300
You can also adapt it as a handler and obviously change this snippet to suit your use-case.