Merge pull request #1109 from schwartzmx/update/win_msi

updates win_msi to allow install/uninstall to wait
This commit is contained in:
Matt Davis 2016-01-12 09:33:00 -08:00
commit 4e4763be84
2 changed files with 31 additions and 3 deletions

View file

@ -25,6 +25,7 @@ $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
$result = New-Object psobject @{
changed = $false
@ -38,11 +39,25 @@ If (($creates -ne $false) -and ($state -ne "absent") -and (Test-Path $creates))
$logfile = [IO.Path]::GetTempFileName();
if ($state -eq "absent")
{
msiexec.exe /x $path /qn /l $logfile $extra_args
If ($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 `"$path`" /qn /l $logfile $extra_args" -Verb Runas;
}
}
Else
{
msiexec.exe /i $path /qn /l $logfile $extra_args
If ($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 `"$path`" /qn /l $logfile $extra_args" -Verb Runas;
}
}
Set-Attr $result "changed" $true;
@ -52,4 +67,4 @@ Remove-Item $logfile;
Set-Attr $result "log" $logcontents;
Exit-Json $result;
Exit-Json $result;

View file

@ -49,6 +49,16 @@ options:
description:
- Path to a file created by installing the MSI to prevent from
attempting to reinstall the package on every run
wait:
version_added: "2.0"
description:
- Specify whether to wait for install or uninstall to complete before continuing.
choices:
- true
- yes
- false
- no
default: false
author: "Matt Martz (@sivel)"
'''
@ -56,6 +66,9 @@ EXAMPLES = '''
# Install an MSI file
- win_msi: path=C:\\\\7z920-x64.msi
# Install an MSI, and wait for it to complete before continuing
- win_msi: path=C:\\\\7z920-x64.msi wait=true
# Uninstall an MSI file
- win_msi: path=C:\\\\7z920-x64.msi state=absent
'''