mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 13:20:23 -07:00
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
|
||||
$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'
|
||||
$description = Get-AnsibleParam -obj $params -name 'description' -type 'str'
|
||||
$desktop_interact = Get-AnsibleParam -obj $params -name 'desktop_interact' -type 'bool' -default $false
|
||||
|
@ -42,11 +42,6 @@ $result = @{
|
|||
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) {
|
||||
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 = @()
|
||||
|
||||
if ($dependency_action -eq 'set') {
|
||||
$new_dependencies = $dependencies
|
||||
foreach ($dependency in $dependencies) {
|
||||
$new_dependencies.Add($dependency)
|
||||
}
|
||||
} else {
|
||||
$new_dependencies = $existing_dependencies
|
||||
foreach ($dependency in $dependencies) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue