mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
updates win_msi to allow install to wait - adds additional wait param - updates to use Start-Process to allow -Wait - this will wait for install/uninstall to complete before continue
This commit is contained in:
parent
9c6db69827
commit
5ff4d219e0
2 changed files with 49 additions and 11 deletions
|
@ -21,14 +21,25 @@
|
||||||
|
|
||||||
$params = Parse-Args $args;
|
$params = Parse-Args $args;
|
||||||
|
|
||||||
$path = Get-Attr $params "path" -failifempty $true
|
$result = New-Object psobject;
|
||||||
$state = Get-Attr $params "state" "present"
|
Set-Attr $result "changed" $false;
|
||||||
$creates = Get-Attr $params "creates" $false
|
$wait = $false
|
||||||
$extra_args = Get-Attr $params "extra_args" ""
|
|
||||||
|
|
||||||
$result = New-Object psobject @{
|
If (-not $params.path.GetType)
|
||||||
changed = $false
|
{
|
||||||
};
|
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))
|
If (($creates -ne $false) -and ($state -ne "absent") -and (Test-Path $creates))
|
||||||
{
|
{
|
||||||
|
@ -36,13 +47,27 @@ 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 ($params.state.GetType -and $params.state -eq "absent")
|
||||||
{
|
{
|
||||||
msiexec.exe /x $path /qn /l $logfile $extra_args
|
If ($wait)
|
||||||
|
{
|
||||||
|
Start-Process -FilePath msiexec.exe -ArgumentList "/x $params.path /qb /l $logfile $extra_args" -Verb Runas -Wait;
|
||||||
|
}
|
||||||
|
Else
|
||||||
|
{
|
||||||
|
Start-Process -FilePath msiexec.exe -ArgumentList "/x $params.path /qb /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 $params.path /qb /l $logfile $extra_args" -Verb Runas -Wait;
|
||||||
|
}
|
||||||
|
Else
|
||||||
|
{
|
||||||
|
Start-Process -FilePath msiexec.exe -ArgumentList "/i $params.path /qb /l $logfile $extra_args" -Verb Runas;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Set-Attr $result "changed" $true;
|
Set-Attr $result "changed" $true;
|
||||||
|
|
|
@ -49,13 +49,26 @@ 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
|
||||||
author: "Matt Martz (@sivel)"
|
wait:
|
||||||
|
version_added: ""
|
||||||
|
description:
|
||||||
|
- Specify whether to wait for install or uninstall to complete before continuing.
|
||||||
|
choices:
|
||||||
|
- true
|
||||||
|
- yes
|
||||||
|
- false
|
||||||
|
- no
|
||||||
|
default: false
|
||||||
|
author: Matt Martz
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = '''
|
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