2018-08-28 23:44:30 +00:00
|
|
|
#!/usr/bin/python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
# Copyright: (c) 2017, Ansible Project
|
|
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
|
|
|
|
# this is a windows documentation stub, actual code lives in the .ps1
|
|
|
|
# file of the same name
|
|
|
|
|
|
|
|
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
|
|
|
'status': ['preview'],
|
|
|
|
'supported_by': 'community'}
|
|
|
|
|
|
|
|
DOCUMENTATION = r'''
|
|
|
|
---
|
|
|
|
module: win_wait_for_process
|
|
|
|
version_added: '2.7'
|
|
|
|
short_description: Waits for a process to exist or not exist before continuing.
|
|
|
|
description:
|
2018-08-31 01:13:51 +00:00
|
|
|
- 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.
|
2018-08-28 23:44:30 +00:00
|
|
|
options:
|
|
|
|
process_name_exact:
|
|
|
|
description:
|
2018-08-31 01:13:51 +00:00
|
|
|
- The name of the process(es) for which to wait.
|
|
|
|
type: str
|
2018-08-28 23:44:30 +00:00
|
|
|
process_name_pattern:
|
2018-08-31 01:13:51 +00:00
|
|
|
description:
|
|
|
|
- RegEx pattern matching desired process(es).
|
|
|
|
type: str
|
2018-08-28 23:44:30 +00:00
|
|
|
sleep:
|
|
|
|
description:
|
|
|
|
- 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.
|
2018-08-31 01:13:51 +00:00
|
|
|
type: int
|
2018-08-28 23:44:30 +00:00
|
|
|
default: 1
|
|
|
|
process_min_count:
|
|
|
|
description:
|
|
|
|
- Minimum number of process matching the supplied pattern to satisfy C(present) condition.
|
|
|
|
- Only applies to C(present).
|
2018-08-31 01:13:51 +00:00
|
|
|
type: int
|
2018-08-28 23:44:30 +00:00
|
|
|
default: 1
|
2018-08-31 01:13:51 +00:00
|
|
|
pid:
|
|
|
|
description:
|
|
|
|
- The PID of the process.
|
|
|
|
type: int
|
|
|
|
owner:
|
|
|
|
description:
|
|
|
|
- The owner of the process.
|
|
|
|
- Requires PowerShell version 4.0 or newer.
|
|
|
|
type: str
|
|
|
|
pre_wait_delay:
|
|
|
|
description:
|
|
|
|
- Seconds to wait before checking processes.
|
|
|
|
type: int
|
|
|
|
default: 0
|
|
|
|
post_wait_delay:
|
|
|
|
description:
|
|
|
|
- Seconds to wait after checking for processes.
|
|
|
|
type: int
|
|
|
|
default: 0
|
2018-08-28 23:44:30 +00:00
|
|
|
state:
|
|
|
|
description:
|
|
|
|
- When checking for a running process C(present) will block execution
|
|
|
|
until the process exists, or until the timeout has been reached.
|
|
|
|
C(absent) will block execution untile the processs no longer exists,
|
|
|
|
or until the timeout has been reached.
|
|
|
|
- When waiting for C(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 C(absent), new processes matching the supplied
|
|
|
|
pattern are started, these new processes will not be included in the
|
|
|
|
action.
|
2018-08-31 01:13:51 +00:00
|
|
|
type: str
|
2018-08-28 23:44:30 +00:00
|
|
|
default: present
|
2018-08-31 01:13:51 +00:00
|
|
|
choices: [ absent, present ]
|
2018-08-28 23:44:30 +00:00
|
|
|
timeout:
|
|
|
|
description:
|
|
|
|
- The maximum number of seconds to wait for a for a process to start or stop
|
|
|
|
before erroring out.
|
2018-08-31 01:13:51 +00:00
|
|
|
type: int
|
2018-08-28 23:44:30 +00:00
|
|
|
default: 300
|
2018-12-15 02:23:59 +00:00
|
|
|
seealso:
|
|
|
|
- module: wait_for
|
|
|
|
- module: win_wait_for
|
2018-08-28 23:44:30 +00:00
|
|
|
author:
|
|
|
|
- Charles Crossan (@crossan007)
|
|
|
|
'''
|
|
|
|
|
|
|
|
EXAMPLES = r'''
|
|
|
|
- name: Wait 300 seconds for all Oracle VirtualBox processes to stop. (VBoxHeadless, VirtualBox, VBoxSVC)
|
|
|
|
win_wait_for_process:
|
2018-11-17 01:04:56 +00:00
|
|
|
process_name_pattern: 'v(irtual)?box(headless|svc)?'
|
2018-08-28 23:44:30 +00:00
|
|
|
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:
|
2018-08-31 01:13:51 +00:00
|
|
|
process_name_exact: cmd
|
2018-08-28 23:44:30 +00:00
|
|
|
state: present
|
|
|
|
timeout: 500
|
|
|
|
sleep: 5
|
|
|
|
process_min_count: 3
|
|
|
|
'''
|
|
|
|
|
|
|
|
RETURN = r'''
|
|
|
|
elapsed:
|
2018-08-31 01:13:51 +00:00
|
|
|
description: The elapsed seconds between the start of poll and the end of the module.
|
2018-08-28 23:44:30 +00:00
|
|
|
returned: always
|
|
|
|
type: float
|
|
|
|
sample: 3.14159265
|
|
|
|
matched_processes:
|
2019-01-03 16:50:44 +00:00
|
|
|
description: List of matched processes (either stopped or started).
|
2018-08-28 23:44:30 +00:00
|
|
|
returned: always
|
2018-08-31 01:13:51 +00:00
|
|
|
type: complex
|
|
|
|
contains:
|
|
|
|
name:
|
2019-01-03 16:50:44 +00:00
|
|
|
description: The name of the matched process.
|
2018-08-31 01:13:51 +00:00
|
|
|
returned: always
|
|
|
|
type: str
|
|
|
|
sample: svchost
|
|
|
|
owner:
|
2019-01-03 16:50:44 +00:00
|
|
|
description: The owner of the matched process.
|
2018-08-31 01:13:51 +00:00
|
|
|
returned: when supported by PowerShell
|
|
|
|
type: str
|
|
|
|
sample: NT AUTHORITY\SYSTEM
|
|
|
|
pid:
|
2019-01-03 16:50:44 +00:00
|
|
|
description: The PID of the matched process.
|
2018-08-31 01:13:51 +00:00
|
|
|
returned: always
|
|
|
|
type: int
|
|
|
|
sample: 7908
|
2018-08-28 23:44:30 +00:00
|
|
|
'''
|