mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 05:42:50 +00:00
Added support for user-specified log file in win_package (#51104)
* Added support for user-specified log file in win_package - feature (#38353) * added integration tests for win_package log_path support feature (#38353), and applied review feedback * win_package log_path support feature (#38353) - fixed typo in win-package.py documentation * win_package log_path support feature (#38353) - improved an integration test and better doc in win-package.py
This commit is contained in:
@@ -25,6 +25,7 @@ $validate_certs = Get-AnsibleParam -obj $params -name "validate_certs" -type "bo
|
||||
$creates_path = Get-AnsibleParam -obj $params -name "creates_path" -type "path"
|
||||
$creates_version = Get-AnsibleParam -obj $params -name "creates_version" -type "str"
|
||||
$creates_service = Get-AnsibleParam -obj $params -name "creates_service" -type "str"
|
||||
$log_path = Get-AnsibleParam -obj $params -name "log_path" -type "path"
|
||||
|
||||
$result = @{
|
||||
changed = $false
|
||||
@@ -326,10 +327,12 @@ if ($state -eq "absent") {
|
||||
|
||||
if ($program_metadata.msi -eq $true) {
|
||||
# we are uninstalling an msi
|
||||
$temp_path = [System.IO.Path]::GetTempPath()
|
||||
$log_file = [System.IO.Path]::GetRandomFileName()
|
||||
$log_path = Join-Path -Path $temp_path -ChildPath $log_file
|
||||
$cleanup_artifacts += $log_path
|
||||
if ( -Not $log_path ) {
|
||||
$temp_path = [System.IO.Path]::GetTempPath()
|
||||
$log_file = [System.IO.Path]::GetRandomFileName()
|
||||
$log_path = Join-Path -Path $temp_path -ChildPath $log_file
|
||||
$cleanup_artifacts += $log_path
|
||||
}
|
||||
|
||||
if ($program_metadata.product_id -ne $null) {
|
||||
$id = $program_metadata.product_id
|
||||
@@ -418,11 +421,13 @@ if ($state -eq "absent") {
|
||||
|
||||
if ($program_metadata.msi -eq $true) {
|
||||
# we are installing an msi
|
||||
$temp_path = [System.IO.Path]::GetTempPath()
|
||||
$log_file = [System.IO.Path]::GetRandomFileName()
|
||||
$log_path = Join-Path -Path $temp_path -ChildPath $log_file
|
||||
if ( -Not $log_path ) {
|
||||
$temp_path = [System.IO.Path]::GetTempPath()
|
||||
$log_file = [System.IO.Path]::GetRandomFileName()
|
||||
$log_path = Join-Path -Path $temp_path -ChildPath $log_file
|
||||
$cleanup_artifacts += $log_path
|
||||
}
|
||||
|
||||
$cleanup_artifacts += $log_path
|
||||
$install_arguments = @("$env:windir\system32\msiexec.exe", "/i", $local_path, "/L*V", $log_path, "/qn", "/norestart")
|
||||
} else {
|
||||
$log_path = $null
|
||||
|
||||
@@ -130,6 +130,13 @@ options:
|
||||
type: bool
|
||||
default: yes
|
||||
version_added: '2.4'
|
||||
log_path:
|
||||
description:
|
||||
- Specifies the path to a log file that is persisted after an MSI package is installed or uninstalled.
|
||||
- When omitted, a temporary log file is used for MSI packages.
|
||||
- This is only valid for MSI files, use C(arguments) for other package types.
|
||||
type: path
|
||||
version_added: '2.8'
|
||||
notes:
|
||||
- When C(state=absent) and the product is an exe, the path may be different
|
||||
from what was used to install the package originally. If path is not set then
|
||||
@@ -163,7 +170,7 @@ EXAMPLES = r'''
|
||||
product_id: '{CF2BEA3C-26EA-32F8-AA9B-331F7E34BA97}'
|
||||
arguments: /install /passive /norestart
|
||||
|
||||
- name: Install Visual C thingy with list of arguments instead of a string
|
||||
- name: Install Visual C thingy with list of arguments instead of a string, and permanent log
|
||||
win_package:
|
||||
path: http://download.microsoft.com/download/1/6/B/16B06F60-3B20-4FF2-B699-5E9B7962F9AE/VSU_4/vcredist_x64.exe
|
||||
product_id: '{CF2BEA3C-26EA-32F8-AA9B-331F7E34BA97}'
|
||||
@@ -171,6 +178,7 @@ EXAMPLES = r'''
|
||||
- /install
|
||||
- /passive
|
||||
- /norestart
|
||||
log_path: D:\logs\vcredist_x64-exe-{{lookup('pipe', 'date +%Y%m%dT%H%M%S')}}.log
|
||||
|
||||
- name: Install Remote Desktop Connection Manager from msi
|
||||
win_package:
|
||||
|
||||
Reference in New Issue
Block a user