Merge pull request #1109 from schwartzmx/update/win_msi
updates win_msi to allow install/uninstall to wait
This commit is contained in:
commit
4e4763be84
2 changed files with 31 additions and 3 deletions
|
@ -25,6 +25,7 @@ $path = Get-Attr $params "path" -failifempty $true
|
||||||
$state = Get-Attr $params "state" "present"
|
$state = Get-Attr $params "state" "present"
|
||||||
$creates = Get-Attr $params "creates" $false
|
$creates = Get-Attr $params "creates" $false
|
||||||
$extra_args = Get-Attr $params "extra_args" ""
|
$extra_args = Get-Attr $params "extra_args" ""
|
||||||
|
$wait = Get-Attr $params "wait" $false | ConvertTo-Bool
|
||||||
|
|
||||||
$result = New-Object psobject @{
|
$result = New-Object psobject @{
|
||||||
changed = $false
|
changed = $false
|
||||||
|
@ -38,11 +39,25 @@ If (($creates -ne $false) -and ($state -ne "absent") -and (Test-Path $creates))
|
||||||
$logfile = [IO.Path]::GetTempFileName();
|
$logfile = [IO.Path]::GetTempFileName();
|
||||||
if ($state -eq "absent")
|
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
|
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;
|
Set-Attr $result "changed" $true;
|
||||||
|
@ -52,4 +67,4 @@ Remove-Item $logfile;
|
||||||
|
|
||||||
Set-Attr $result "log" $logcontents;
|
Set-Attr $result "log" $logcontents;
|
||||||
|
|
||||||
Exit-Json $result;
|
Exit-Json $result;
|
|
@ -49,6 +49,16 @@ options:
|
||||||
description:
|
description:
|
||||||
- Path to a file created by installing the MSI to prevent from
|
- Path to a file created by installing the MSI to prevent from
|
||||||
attempting to reinstall the package on every run
|
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)"
|
author: "Matt Martz (@sivel)"
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
@ -56,6 +66,9 @@ EXAMPLES = '''
|
||||||
# Install an MSI file
|
# Install an MSI file
|
||||||
- win_msi: path=C:\\\\7z920-x64.msi
|
- 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
|
# Uninstall an MSI file
|
||||||
- win_msi: path=C:\\\\7z920-x64.msi state=absent
|
- win_msi: path=C:\\\\7z920-x64.msi state=absent
|
||||||
'''
|
'''
|
||||||
|
|
Loading…
Reference in a new issue