community.windows.win_wait_for_process module – Waits for a process to exist or not exist before continuing.
Note
This module is part of the community.windows collection (version 1.10.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 community.windows
.
To use it in a playbook, specify: community.windows.win_wait_for_process
.
Synopsis
Waiting for a process to start or stop.
This is useful when Windows services behave poorly and do not enumerate external dependencies in their manifest.
Parameters
Parameter |
Comments |
---|---|
The owner of the process. Requires PowerShell version 4.0 or newer. |
|
The PID of the process. |
|
Seconds to wait after checking for processes. Default: 0 |
|
Seconds to wait before checking processes. Default: 0 |
|
Minimum number of process matching the supplied pattern to satisfy Only applies to Default: 1 |
|
The name of the process(es) for which to wait. The name of the process(es) should not include the file extension suffix. |
|
RegEx pattern matching desired process(es). |
|
Number of seconds to sleep between checks. Only applies when waiting for a process to start. Waiting for a process to start does not have a native non-polling mechanism. Waiting for a stop uses native PowerShell and does not require polling. Default: 1 |
|
When checking for a running process When waiting for If, while waiting for Choices:
|
|
The maximum number of seconds to wait for a for a process to start or stop before erroring out. Default: 300 |
See Also
See also
- ansible.builtin.wait_for
The official documentation on the ansible.builtin.wait_for module.
- ansible.windows.win_wait_for
The official documentation on the ansible.windows.win_wait_for module.
Examples
- name: Wait 300 seconds for all Oracle VirtualBox processes to stop. (VBoxHeadless, VirtualBox, VBoxSVC)
community.windows.win_wait_for_process:
process_name_pattern: 'v(irtual)?box(headless|svc)?'
state: absent
timeout: 500
- name: Wait 300 seconds for 3 instances of cmd to start, waiting 5 seconds between each check
community.windows.win_wait_for_process:
process_name_exact: cmd
state: present
timeout: 500
sleep: 5
process_min_count: 3
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
The elapsed seconds between the start of poll and the end of the module. Returned: always Sample: 3.14159265 |
|
List of matched processes (either stopped or started). Returned: always |
|
The name of the matched process. Returned: always Sample: “svchost” |
|
The owner of the matched process. Returned: when supported by PowerShell Sample: “NT AUTHORITY\\SYSTEM” |
|
The PID of the matched process. Returned: always Sample: 7908 |
Authors
Charles Crossan (@crossan007)