Author: | Jeroen Hoekx, John Jarvis |
---|
Waiting for a port to become available is useful for when services are not immediately available after their init scripts return - which is true of certain Java application servers. It is also useful when starting guests with the virt module and needing to pause until they are ready. This module can also be used to wait for a file to be available on the filesystem or with a regex match a string to be present in a file.
parameter | required | default | choices | comments |
---|---|---|---|---|
delay | no | number of seconds to wait before starting to poll | ||
host | no | 127.0.0.1 | hostname or IP address to wait for | |
path | no | path to a file on the filesytem that must exist before continuing (added in Ansible 1.4) | ||
port | no | port number to poll | ||
search_regex | no | with the path option can be used match a string in the file that must match before continuing. Defaults to a multiline regex. (added in Ansible 1.4) | ||
state | no | started |
|
either present , started , or stopped When checking a port started will ensure the port is open, stopped will check that it is closedWhen checking for a file or a search string present or started will ensure that the file or string is present before continuing |
timeout | no | 300 | maximum number of seconds to wait for |
# wait 300 seconds for port 8000 to become open on the host, don't start checking for 10 seconds
- wait_for: port=8000 delay=10
# wait until the file /tmp/foo is present before continuing
- wait_for: path=/tmp/foo
# wait until the string "completed" is in the file /tmp/foo before continuing
- wait_for: path=/tmp/foo search_regex=completed