diff --git a/lib/ansible/modules/windows/win_service.ps1 b/lib/ansible/modules/windows/win_service.ps1 index e95964e156..b601613bf3 100644 --- a/lib/ansible/modules/windows/win_service.ps1 +++ b/lib/ansible/modules/windows/win_service.ps1 @@ -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) { diff --git a/lib/ansible/modules/windows/win_service.py b/lib/ansible/modules/windows/win_service.py index 6be0bdefec..ca928aa80a 100644 --- a/lib/ansible/modules/windows/win_service.py +++ b/lib/ansible/modules/windows/win_service.py @@ -224,57 +224,57 @@ EXAMPLES = r''' RETURN = r''' exists: - description: whether the service exists or not + description: Whether the service exists or not. returned: success type: boolean sample: true name: - description: the service name or id of the service + description: The service name or id of the service. returned: success and service exists type: string sample: CoreMessagingRegistrar display_name: - description: the display name of the installed service + description: The display name of the installed service. returned: success and service exists type: string sample: CoreMessaging -status: - description: the current running status of the service +state: + description: The current running status of the service. returned: success and service exists type: string sample: stopped start_mode: - description: the startup type of the service + description: The startup type of the service. returned: success and service exists type: string sample: manual path: - description: path to the service + description: The path to the service executable. returned: success and service exists type: string sample: C:\Windows\system32\svchost.exe -k LocalServiceNoNetwork description: - description: the path to the executable of the service + description: The description of the service. returned: success and service exists type: string sample: Manages communication between system components. username: - description: the username that runs the service + description: The username that runs the service. returned: success and service exists type: string sample: LocalSystem 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 type: boolean sample: False 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 type: list sample: False 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 type: list sample: False