win_service: Updated return values and use the list parameter type (#25385)
* win_service: Updated return values and use the list parameter type * minor fix to handle the list parameter return value
This commit is contained in:
parent
8e62c4d8ac
commit
2f3a1c7a28
2 changed files with 16 additions and 19 deletions
|
@ -24,7 +24,7 @@ $ErrorActionPreference = "Stop"
|
||||||
$params = Parse-Args $args -supports_check_mode $true
|
$params = Parse-Args $args -supports_check_mode $true
|
||||||
$check_mode = Get-AnsibleParam -obj $params -name '_ansible_check_mode' -type 'bool' -default $false
|
$check_mode = Get-AnsibleParam -obj $params -name '_ansible_check_mode' -type 'bool' -default $false
|
||||||
|
|
||||||
$dependencies = Get-AnsibleParam -obj $params -name 'dependencies' -default $null
|
$dependencies = Get-AnsibleParam -obj $params -name 'dependencies' -type 'list' -default $null
|
||||||
$dependency_action = Get-AnsibleParam -obj $params -name 'dependency_action' -type 'str' -default 'set' -validateset 'add','remove','set'
|
$dependency_action = Get-AnsibleParam -obj $params -name 'dependency_action' -type 'str' -default 'set' -validateset 'add','remove','set'
|
||||||
$description = Get-AnsibleParam -obj $params -name 'description' -type 'str'
|
$description = Get-AnsibleParam -obj $params -name 'description' -type 'str'
|
||||||
$desktop_interact = Get-AnsibleParam -obj $params -name 'desktop_interact' -type 'bool' -default $false
|
$desktop_interact = Get-AnsibleParam -obj $params -name 'desktop_interact' -type 'bool' -default $false
|
||||||
|
@ -42,11 +42,6 @@ $result = @{
|
||||||
warnings = @()
|
warnings = @()
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check if dependencies is a string and convert to a list
|
|
||||||
if ($dependencies -is [System.String]) {
|
|
||||||
$dependencies = @($dependencies)
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($username -ne $null -and $password -eq $null) {
|
if ($username -ne $null -and $password -eq $null) {
|
||||||
Fail-Json $result "The argument 'password' must be supplied with 'username'"
|
Fail-Json $result "The argument 'password' must be supplied with 'username'"
|
||||||
}
|
}
|
||||||
|
@ -235,7 +230,9 @@ Function Set-ServiceDependencies($wmi_svc, $dependency_action, $dependencies) {
|
||||||
[System.Collections.ArrayList]$new_dependencies = @()
|
[System.Collections.ArrayList]$new_dependencies = @()
|
||||||
|
|
||||||
if ($dependency_action -eq 'set') {
|
if ($dependency_action -eq 'set') {
|
||||||
$new_dependencies = $dependencies
|
foreach ($dependency in $dependencies) {
|
||||||
|
$new_dependencies.Add($dependency)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$new_dependencies = $existing_dependencies
|
$new_dependencies = $existing_dependencies
|
||||||
foreach ($dependency in $dependencies) {
|
foreach ($dependency in $dependencies) {
|
||||||
|
|
|
@ -224,57 +224,57 @@ EXAMPLES = r'''
|
||||||
|
|
||||||
RETURN = r'''
|
RETURN = r'''
|
||||||
exists:
|
exists:
|
||||||
description: whether the service exists or not
|
description: Whether the service exists or not.
|
||||||
returned: success
|
returned: success
|
||||||
type: boolean
|
type: boolean
|
||||||
sample: true
|
sample: true
|
||||||
name:
|
name:
|
||||||
description: the service name or id of the service
|
description: The service name or id of the service.
|
||||||
returned: success and service exists
|
returned: success and service exists
|
||||||
type: string
|
type: string
|
||||||
sample: CoreMessagingRegistrar
|
sample: CoreMessagingRegistrar
|
||||||
display_name:
|
display_name:
|
||||||
description: the display name of the installed service
|
description: The display name of the installed service.
|
||||||
returned: success and service exists
|
returned: success and service exists
|
||||||
type: string
|
type: string
|
||||||
sample: CoreMessaging
|
sample: CoreMessaging
|
||||||
status:
|
state:
|
||||||
description: the current running status of the service
|
description: The current running status of the service.
|
||||||
returned: success and service exists
|
returned: success and service exists
|
||||||
type: string
|
type: string
|
||||||
sample: stopped
|
sample: stopped
|
||||||
start_mode:
|
start_mode:
|
||||||
description: the startup type of the service
|
description: The startup type of the service.
|
||||||
returned: success and service exists
|
returned: success and service exists
|
||||||
type: string
|
type: string
|
||||||
sample: manual
|
sample: manual
|
||||||
path:
|
path:
|
||||||
description: path to the service
|
description: The path to the service executable.
|
||||||
returned: success and service exists
|
returned: success and service exists
|
||||||
type: string
|
type: string
|
||||||
sample: C:\Windows\system32\svchost.exe -k LocalServiceNoNetwork
|
sample: C:\Windows\system32\svchost.exe -k LocalServiceNoNetwork
|
||||||
description:
|
description:
|
||||||
description: the path to the executable of the service
|
description: The description of the service.
|
||||||
returned: success and service exists
|
returned: success and service exists
|
||||||
type: string
|
type: string
|
||||||
sample: Manages communication between system components.
|
sample: Manages communication between system components.
|
||||||
username:
|
username:
|
||||||
description: the username that runs the service
|
description: The username that runs the service.
|
||||||
returned: success and service exists
|
returned: success and service exists
|
||||||
type: string
|
type: string
|
||||||
sample: LocalSystem
|
sample: LocalSystem
|
||||||
desktop_interact:
|
desktop_interact:
|
||||||
description: Whether the current user is allowed to interact with the desktop
|
description: Whether the current user is allowed to interact with the desktop.
|
||||||
returned: success and service exists
|
returned: success and service exists
|
||||||
type: boolean
|
type: boolean
|
||||||
sample: False
|
sample: False
|
||||||
dependencies:
|
dependencies:
|
||||||
description: A list of dependencies the service relies on
|
description: A list of services that is depended by this service.
|
||||||
returned: success and service exists
|
returned: success and service exists
|
||||||
type: list
|
type: list
|
||||||
sample: False
|
sample: False
|
||||||
depended_by:
|
depended_by:
|
||||||
description: A list of dependencies this service relies on
|
description: A list of services that depend on this service.
|
||||||
returned: success and service exists
|
returned: success and service exists
|
||||||
type: list
|
type: list
|
||||||
sample: False
|
sample: False
|
||||||
|
|
Loading…
Reference in a new issue