win_wait_for_process - Waits for a process to exist or not exist before continuing.

New in version 2.7.

Synopsis

Parameters

Parameter Choices/Defaults Comments
owner
str
The owner of the process.
Requires PowerShell version 4.0 or newer.
pid
int
The PID of the process.
post_wait_delay
int
Default:
0
Seconds to wait after checking for processes.
pre_wait_delay
int
Default:
0
Seconds to wait before checking processes.
process_min_count
int
Default:
1
Minimum number of process matching the supplied pattern to satisfy present condition.
Only applies to present.
process_name_exact
str
The name of the process(es) for which to wait.
process_name_pattern
str
RegEx pattern matching desired process(es).
sleep
int
Default:
1
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.
state
str
    Choices:
  • absent
  • present ←
When checking for a running process present will block execution until the process exists, or until the timeout has been reached. absent will block execution untile the processs no longer exists, or until the timeout has been reached.
When waiting for present, the module will return changed only if the process was not present on the initial check but became present on subsequent checks.
If, while waiting for absent, new processes matching the supplied pattern are started, these new processes will not be included in the action.
timeout
int
Default:
300
The maximum number of seconds to wait for a for a process to start or stop before erroring out.

Examples

- name: Wait 300 seconds for all Oracle VirtualBox processes to stop. (VBoxHeadless, VirtualBox, VBoxSVC)
  win_wait_for_process:
    process_name: '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
  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 Returned Description
elapsed
float
always
The elapsed seconds between the start of poll and the end of the module.

Sample:
3.14159265
matched_processes
complex
always
List of matched processes (either stopped or started)

  owner
str
when supported by PowerShell
The owner of the matched process

Sample:
NT AUTHORITY\SYSTEM
  pid
int
always
The PID of the matched process

Sample:
7908
  name
str
always
The name of the matched process

Sample:
svchost


Status

This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.

Maintenance

This module is flagged as community which means that it is maintained by the Ansible Community. See Module Maintenance & Support for more info.

For a list of other modules that are also maintained by the Ansible Community, see here.

Author

  • Charles Crossan (@crossan007)

Hint

If you notice any issues in this documentation you can edit this document to improve it.