From 2de895a07b879f652b24c6c5bceefc7376c708b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Subileau?= Date: Wed, 29 Aug 2018 13:38:52 +0200 Subject: [PATCH] win_nssm: restore comma as separator for service dependencies Revert commit ddd4b4b (cherry picked from commit ead882bb9b0bb9e576eda9e074f9150785f9512f) --- lib/ansible/modules/windows/win_nssm.ps1 | 8 ++++---- lib/ansible/modules/windows/win_nssm.py | 4 ++-- test/integration/targets/win_nssm/tasks/tests.yml | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) 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'