From 3781c5ccb094a0368c1d440876202a373ddf481b Mon Sep 17 00:00:00 2001 From: Phil Date: Wed, 16 Sep 2015 20:34:56 -0500 Subject: [PATCH] uses get-attr and fixes file path issues by escaping quotes around path --- lib/ansible/modules/windows/win_msi.ps1 | 32 +++++++------------------ 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/lib/ansible/modules/windows/win_msi.ps1 b/lib/ansible/modules/windows/win_msi.ps1 index 7db67546013..2feb5fc41cd 100644 --- a/lib/ansible/modules/windows/win_msi.ps1 +++ b/lib/ansible/modules/windows/win_msi.ps1 @@ -21,52 +21,38 @@ $params = Parse-Args $args; -$result = New-Object psobject; -Set-Attr $result "changed" $false; -$wait = $false +$path = Get-Attr $params "path" -failifempty $true +$state = Get-Attr $params "state" "present" +$creates = Get-Attr $params "creates" $false +$extra_args = Get-Attr $params "extra_args" "" +$wait = Get-Attr $params "wait" $false | ConvertTo-Bool If (-not $params.path.GetType) { Fail-Json $result "missing required arguments: path" } -If ($params.wait -eq "true" -Or $params.wait -eq "yes") -{ - $wait = $true -} - -$extra_args = "" -If ($params.extra_args.GetType) -{ - $extra_args = $params.extra_args; -} - -If (($creates -ne $false) -and ($state -ne "absent") -and (Test-Path $creates)) -{ - Exit-Json $result; -} - $logfile = [IO.Path]::GetTempFileName(); If ($params.state.GetType -and $params.state -eq "absent") { If ($wait) { - Start-Process -FilePath msiexec.exe -ArgumentList "/x $params.path /qb /l $logfile $extra_args" -Verb Runas -Wait; + Start-Process -FilePath msiexec.exe -ArgumentList "/x `"$path`" /qn /l $logfile $extra_args" -Verb Runas -Wait; } Else { - Start-Process -FilePath msiexec.exe -ArgumentList "/x $params.path /qb /l $logfile $extra_args" -Verb Runas; + Start-Process -FilePath msiexec.exe -ArgumentList "/x `"$path`" /qn /l $logfile $extra_args" -Verb Runas; } } Else { If ($wait) { - Start-Process -FilePath msiexec.exe -ArgumentList "/i $params.path /qb /l $logfile $extra_args" -Verb Runas -Wait; + Start-Process -FilePath msiexec.exe -ArgumentList "/i `"$path`" /qn /l $logfile $extra_args" -Verb Runas -Wait; } Else { - Start-Process -FilePath msiexec.exe -ArgumentList "/i $params.path /qb /l $logfile $extra_args" -Verb Runas; + Start-Process -FilePath msiexec.exe -ArgumentList "/i `"$path`" /qn /l $logfile $extra_args" -Verb Runas; } }