What do `wait_for` and `wait_for_connection` do?
IntermediateConceptPlaybooks, Plays, Tasks and Handlers
Answer
wait_for waits for a condition on the target or on a port: a TCP port opening or closing, a file appearing, or a regex in a file. wait_for_connection waits until Ansible itself can connect and run a module, which is the right check after a reboot.
- ansible.builtin.reboot: # built-in, handles reconnect
reboot_timeout: 600
- ansible.builtin.wait_for:
host: 10.0.1.11
port: 443
timeout: 120
delegate_to: localhost
Use delegate_to: localhost with wait_for when the port should be checked from the controller's viewpoint.