From 8180a7c39b2936426e6def0fa06edd974845d36b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Subileau?= Date: Mon, 27 Aug 2018 10:40:56 +0200 Subject: [PATCH] win_nssm: fix service not started when state=started Nssm status returns a multiline output that doesn't match any of the strict patterns in the switch statement. --- lib/ansible/modules/windows/win_nssm.ps1 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/ansible/modules/windows/win_nssm.ps1 b/lib/ansible/modules/windows/win_nssm.ps1 index 483fe78c7df..cad414f0487 100644 --- a/lib/ansible/modules/windows/win_nssm.ps1 +++ b/lib/ansible/modules/windows/win_nssm.ps1 @@ -525,16 +525,16 @@ Function Nssm-Start Throw "Error starting service ""$name""" } - switch ($currentStatus.stdout) + switch -wildcard ($currentStatus.stdout) { - "SERVICE_RUNNING" { <# Nothing to do #> } - "SERVICE_STOPPED" { Nssm-Start-Service-Command -name $name } - - "SERVICE_CONTINUE_PENDING" { Nssm-Stop-Service-Command -name $name; Nssm-Start-Service-Command -name $name } - "SERVICE_PAUSE_PENDING" { Nssm-Stop-Service-Command -name $name; Nssm-Start-Service-Command -name $name } - "SERVICE_PAUSED" { Nssm-Stop-Service-Command -name $name; Nssm-Start-Service-Command -name $name } - "SERVICE_START_PENDING" { Nssm-Stop-Service-Command -name $name; Nssm-Start-Service-Command -name $name } - "SERVICE_STOP_PENDING" { Nssm-Stop-Service-Command -name $name; Nssm-Start-Service-Command -name $name } + "*SERVICE_RUNNING*" { <# Nothing to do #> } + "*SERVICE_STOPPED*" { Nssm-Start-Service-Command -name $name } + + "*SERVICE_CONTINUE_PENDING*" { Nssm-Stop-Service-Command -name $name; Nssm-Start-Service-Command -name $name } + "*SERVICE_PAUSE_PENDING*" { Nssm-Stop-Service-Command -name $name; Nssm-Start-Service-Command -name $name } + "*SERVICE_PAUSED*" { Nssm-Stop-Service-Command -name $name; Nssm-Start-Service-Command -name $name } + "*SERVICE_START_PENDING*" { Nssm-Stop-Service-Command -name $name; Nssm-Start-Service-Command -name $name } + "*SERVICE_STOP_PENDING*" { Nssm-Stop-Service-Command -name $name; Nssm-Start-Service-Command -name $name } } }