From 9387c842a164fd64917a4cb25180f83ffd59bf48 Mon Sep 17 00:00:00 2001 From: gfrank Date: Fri, 4 Dec 2015 15:46:06 -0500 Subject: [PATCH] Use "" for AppParameters if it's null --- .../modules/extras/windows/win_nssm.ps1 | 43 +++++++++++-------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/lib/ansible/modules/extras/windows/win_nssm.ps1 b/lib/ansible/modules/extras/windows/win_nssm.ps1 index 37a8430ec7b..2c7db8dfa7d 100644 --- a/lib/ansible/modules/extras/windows/win_nssm.ps1 +++ b/lib/ansible/modules/extras/windows/win_nssm.ps1 @@ -176,35 +176,44 @@ Function Nssm-Update-AppParameters Throw "Error updating AppParameters for service ""$name""" } - $appParametersHash = ParseAppParameters -appParameters $appParameters - $appParamKeys = @() $appParamVals = @() $singleLineParams = "" - $appParametersHash.GetEnumerator() | - % { - $key = $($_.Name) - $val = $($_.Value) + + if ($appParameters) + { + $appParametersHash = ParseAppParameters -appParameters $appParameters + $appParametersHash.GetEnumerator() | + % { + $key = $($_.Name) + $val = $($_.Value) - $appParamKeys += $key - $appParamVals += $val + $appParamKeys += $key + $appParamVals += $val - if ($key -eq "_") { - $singleLineParams = "$val " + $singleLineParams - } else { - $singleLineParams = $singleLineParams + "$key ""$val""" + if ($key -eq "_") { + $singleLineParams = "$val " + $singleLineParams + } else { + $singleLineParams = $singleLineParams + "$key ""$val""" + } } - } + + Set-Attr $result "nssm_app_parameters_parsed" $appParametersHash + Set-Attr $result "nssm_app_parameters_keys" $appParamKeys + Set-Attr $result "nssm_app_parameters_vals" $appParamVals + } Set-Attr $result "nssm_app_parameters" $appParameters - Set-Attr $result "nssm_app_parameters_parsed" $appParametersHash - Set-Attr $result "nssm_app_parameters_keys" $appParamKeys - Set-Attr $result "nssm_app_parameters_vals" $appParamVals Set-Attr $result "nssm_single_line_app_parameters" $singleLineParams if ($results -ne $singleLineParams) { - $cmd = "nssm set ""$name"" AppParameters $singleLineParams" + if ($appParameters) + { + $cmd = "nssm set ""$name"" AppParameters $singleLineParams" + } else { + $cmd = "nssm set ""$name"" AppParameters '""""'" + } $results = invoke-expression $cmd if ($LastExitCode -ne 0)