Note
This module is part of the ansible.windows collection (version 2.8.0).
You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.
To install it, use: ansible-galaxy collection install ansible.windows.
To use it in a playbook, specify: ansible.windows.win_wait_for.
timeout, this is the default if nothing is specified.Parameter | Comments |
|---|---|
connect_timeout integer | The maximum number of seconds to wait for a connection to happen before closing and retrying. Default: |
delay integer | The number of seconds to wait before starting to poll. |
exclude_hosts list / elements=string | The list of hosts or IPs to ignore when looking for active TCP connections when |
host string | A resolvable hostname or IP address to wait for. If Default: |
path path | The path to a file on the filesystem to check. If If |
port integer | The port number to poll on |
regex aliases: search_regex, regexp string | Can be used to match a string in a file. If If Defaults to a multiline regex. |
sleep integer | Number of seconds to sleep between checks. Default: |
state string | When checking a port, When checking for a file or a search string Choices:
|
timeout integer | The maximum number of seconds to wait for. Default: |
See also
Waits for a condition before continuing.
Waits for a process to exist or not exist before continuing.
- name: Wait 300 seconds for port 8000 to become open on the host, don't start checking for 10 seconds
ansible.windows.win_wait_for:
port: 8000
delay: 10
- name: Wait 150 seconds for port 8000 of any IP to close active connections
ansible.windows.win_wait_for:
host: 0.0.0.0
port: 8000
state: drained
timeout: 150
- name: Wait for port 8000 of any IP to close active connection, ignoring certain hosts
ansible.windows.win_wait_for:
host: 0.0.0.0
port: 8000
state: drained
exclude_hosts: ['10.2.1.2', '10.2.1.3']
- name: Wait for file C:\temp\log.txt to exist before continuing
ansible.windows.win_wait_for:
path: C:\temp\log.txt
- name: Wait until process complete is in the file before continuing
ansible.windows.win_wait_for:
path: C:\temp\log.txt
regex: process complete
- name: Wait until file is removed
ansible.windows.win_wait_for:
path: C:\temp\log.txt
state: absent
- name: Wait until port 1234 is offline but try every 10 seconds
ansible.windows.win_wait_for:
port: 1234
state: absent
sleep: 10
Common return values are documented here, the following are the fields unique to this module:
Key | Description |
|---|---|
elapsed float | The elapsed seconds between the start of poll and the end of the module. This includes the delay if the option is set. Returned: always Sample: |
wait_attempts integer | The number of attempts to poll the file or port before module finishes. Returned: always Sample: |
© 2012–2018 Michael DeHaan
© 2018–2025 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/ansible/windows/win_wait_for_module.html