diff --git a/lib/ansible/modules/windows/win_nssm.ps1 b/lib/ansible/modules/windows/win_nssm.ps1 index 3f8b3436441..afb12393ed1 100644 --- a/lib/ansible/modules/windows/win_nssm.ps1 +++ b/lib/ansible/modules/windows/win_nssm.ps1 @@ -27,7 +27,7 @@ $startMode = Get-AnsibleParam -obj $params -name "start_mode" -type "str" -defau $stdoutFile = Get-AnsibleParam -obj $params -name "stdout_file" -type "str" $stderrFile = Get-AnsibleParam -obj $params -name "stderr_file" -type "str" -$dependencies = Get-AnsibleParam -obj $params -name "dependencies" -type "str" +$dependencies = Get-AnsibleParam -obj $params -name "dependencies" -type "list" $user = Get-AnsibleParam -obj $params -name "user" -type "str" $password = Get-AnsibleParam -obj $params -name "password" -type "str" @@ -431,11 +431,11 @@ Function Nssm-Update-Dependencies Throw "Error updating dependencies for service ""$name""" } - $dependencies_array = @($dependencies.split(" ") | where { $_ -ne '' }) $current_dependencies = @($nssm_result.stdout.split("`n`r") | where { $_ -ne '' }) - If (@(Compare-Object -ReferenceObject $current_dependencies -DifferenceObject $dependencies_array).Length -ne 0) { - $cmd = "set ""$name"" DependOnService $dependencies" + If (@(Compare-Object -ReferenceObject $current_dependencies -DifferenceObject $dependencies).Length -ne 0) { + $dependencies_str = Argv-ToString -arguments $dependencies + $cmd = "set ""$name"" DependOnService $dependencies_str" $nssm_result = Nssm-Invoke $cmd if ($nssm_result.rc -ne 0) diff --git a/lib/ansible/modules/windows/win_nssm.py b/lib/ansible/modules/windows/win_nssm.py index 2fb8928f0b9..f896d1e3f95 100644 --- a/lib/ansible/modules/windows/win_nssm.py +++ b/lib/ansible/modules/windows/win_nssm.py @@ -58,7 +58,7 @@ options: - Use either this or C(app_parameters), not both. dependencies: description: - - Service dependencies that has to be started to trigger startup, separated by space. + - Service dependencies that has to be started to trigger startup, separated by comma. user: description: - User to be used for service startup. @@ -140,7 +140,7 @@ EXAMPLES = r''' - win_nssm: name: foo application: C:\windows\foo.exe - dependencies: 'adf tcpip' + dependencies: 'adf,tcpip' # Install and start the foo service with dedicated user - win_nssm: diff --git a/test/integration/targets/win_nssm/tasks/tests.yml b/test/integration/targets/win_nssm/tasks/tests.yml index 0c0f739b1ab..83364e7121f 100644 --- a/test/integration/targets/win_nssm/tasks/tests.yml +++ b/test/integration/targets/win_nssm/tasks/tests.yml @@ -81,7 +81,7 @@ name: '{{ test_service_name }}' application: C:\Windows\System32\cmd.exe start_mode: manual - dependencies: 'tcpip dnscache' + dependencies: 'tcpip,dnscache' user: '{{ test_win_nssm_username }}' password: '{{ test_win_nssm_password }}' stdout_file: '{{ test_win_nssm_path }}\log.txt' @@ -114,7 +114,7 @@ application: C:\Windows\System32\cmd.exe start_mode: manual # Dependencies order should not trigger a change - dependencies: 'dnscache tcpip' + dependencies: 'dnscache,tcpip' user: '{{ test_win_nssm_username }}' password: '{{ test_win_nssm_password }}' stdout_file: '{{ test_win_nssm_path }}\log.txt'