mirror of https://github.com/ansible/ansible.git
win_package - Refactor with msp, appx support (#66931)
* win_package - Refactor with msp, appx support * Added msi test for ALLUSERS * Added some msix tests, refactored tests * Added remaining msix tests * Enable msix sideloading for tests * Added remaining exe path tests * Added basic msp tests * Remove url options now the util no longer has them * Fix file version check for older Windows hosts * Remove no_proxy ansible-test setting * Use same mechanism of become to copy the file with explicit credspull/67374/head
parent
2d9328cb0f
commit
446a0c1b08
@ -0,0 +1,10 @@
|
||||
bugfixes:
|
||||
- win_package - Handle quoted and unquoted strings in the registry ``UninstallString`` value - https://github.com/ansible/ansible/issues/40973
|
||||
|
||||
minor_changes:
|
||||
- win_package - Added support for ``.msp`` packages - https://github.com/ansible/ansible/issues/22789
|
||||
- win_package - Added support for specifying the HTTP method when getting files from a URL - https://github.com/ansible/ansible/issues/35377
|
||||
- win_package - Added proxy support for retrieving packages from a URL - https://github.com/ansible/ansible/issues/43818
|
||||
- win_package - Scan packages in the current user's registry hive - https://github.com/ansible/ansible/issues/45950
|
||||
- win_package - Added support for ``.appx``, ``.msix``, ``.appxbundle``, and ``.msixbundle`` package - https://github.com/ansible/ansible/issues/50765
|
||||
- win_package - Read uninstall strings from the ``QuietUninstallString`` if present to better support argumentless uninstalls of registry based packages.
|
File diff suppressed because it is too large
Load Diff
@ -1,21 +1,35 @@
|
||||
---
|
||||
# spaces are tricky, let's have one by default
|
||||
test_win_package_path_safe: C:\ansible\win_package
|
||||
test_win_package_path: C:\ansible\win package
|
||||
test_win_package_log_path_install: C:\ansible\win package\test-install.log
|
||||
test_win_package_log_path_uninstall: C:\ansible\win package\test-uninstall.log
|
||||
test_win_package_good_url: https://ansible-ci-files.s3.amazonaws.com/test/integration/roles/test_win_package/good.msi
|
||||
test_win_package_reboot_url: https://ansible-ci-files.s3.amazonaws.com/test/integration/roles/test_win_package/reboot.msi
|
||||
test_win_package_bad_url: https://ansible-ci-files.s3.amazonaws.com/test/integration/roles/test_win_package/bad.msi
|
||||
test_win_package_exe_url: https://ansible-ci-files.s3.amazonaws.com/test/integration/roles/test_win_package/7z.exe # TODO: change to it's own executable
|
||||
test_path: '{{ remote_tmp_dir }}\win_package .ÅÑŚÌβŁÈ [$!@^&test(;)]'
|
||||
|
||||
test_win_package_good_id: '{223D9A13-653B-4231-A365-EDDC30B4F226}'
|
||||
test_win_package_reboot_id: '{223D9A13-653B-4231-A365-EDDC30B4F227}'
|
||||
test_win_package_exe_id: 7-Zip
|
||||
# MSI packages
|
||||
good_url: https://ansible-ci-files.s3.amazonaws.com/test/integration/roles/test_win_package/good.msi
|
||||
reboot_url: https://ansible-ci-files.s3.amazonaws.com/test/integration/roles/test_win_package/reboot.msi
|
||||
bad_url: https://ansible-ci-files.s3.amazonaws.com/test/integration/roles/test_win_package/bad.msi
|
||||
|
||||
# define the below to run the network tests, all 3 msi's should exist in this path
|
||||
# test_win_package_network_path: \\ANSIBLE\network
|
||||
# MSIX tools
|
||||
makeappx_url: https://ansible-ci-files.s3.amazonaws.com/test/integration/targets/win_package/makeappx.zip
|
||||
|
||||
# set the below to test a network path without credential delegation like Basic or NTLM
|
||||
# test_win_package_network_username: ANSIBLE\User
|
||||
# test_win_package_network_password: Password
|
||||
# MSP packages - https://wixtoolset.org/documentation/manual/v3/patching/patch_building.html
|
||||
patch_msi_url: https://ansible-ci-files.s3.amazonaws.com/test/integration/targets/win_package/patch.msi
|
||||
patch_msp_url: https://ansible-ci-files.s3.amazonaws.com/test/integration/targets/win_package/patch.msp
|
||||
patch_install_file: C:\Program Files (x86)\Patch Sample Directory\Sample.txt
|
||||
|
||||
good_id: '{223D9A13-653B-4231-A365-EDDC30B4F226}'
|
||||
reboot_id: '{223D9A13-653B-4231-A365-EDDC30B4F227}'
|
||||
patch_product_id: '{48C49ACE-90CF-4161-9C6E-9162115A54DD}'
|
||||
patch_patch_id: '{224C316C-5894-4771-BABF-21A3AC1F75FF}'
|
||||
msix_id: WinPackageMsix
|
||||
msixbundle_id: WinPackageBundleMsix
|
||||
appx_id: WinPackageAppx
|
||||
appxbundle_id: WinPackageBundleAppx
|
||||
registry_id: WinPackageRegistry
|
||||
|
||||
all_ids:
|
||||
- '{{ good_id }}'
|
||||
- '{{ reboot_id }}'
|
||||
- '{{ patch_product_id }}'
|
||||
- '{{ msix_id }}'
|
||||
- '{{ msixbundle_id }}'
|
||||
- '{{ appx_id }}'
|
||||
- '{{ appxbundle_id }}'
|
||||
- '{{ registry_id }}'
|
||||
|
@ -0,0 +1,15 @@
|
||||
---
|
||||
- name: remove trusted root cert
|
||||
win_certificate_store:
|
||||
thumbprint: '{{ test_win_package_msix_packages.thumbprint }}'
|
||||
store_location: LocalMachine
|
||||
store_name: Root
|
||||
state: absent
|
||||
|
||||
- name: remove sideloading mode for msix
|
||||
win_regedit:
|
||||
path: HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock
|
||||
name: AllowAllTrustedApps
|
||||
data: 0
|
||||
type: dword
|
||||
state: present
|
@ -0,0 +1,194 @@
|
||||
#!powershell
|
||||
|
||||
# Copyright: (c) 2020, Ansible Project
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
#AnsibleRequires -CSharpUtil Ansible.Basic
|
||||
#Requires -Module Ansible.ModuleUtils.ArgvParser
|
||||
#Requires -Module Ansible.ModuleUtils.CommandUtil
|
||||
|
||||
$spec = @{
|
||||
options = @{
|
||||
packages = @{
|
||||
type = "list"
|
||||
elements = "dict"
|
||||
options = @{
|
||||
identity = @{ type = "str"; required = $true }
|
||||
version = @{ type = "str"; required = $true }
|
||||
architecture = @{ type = "str" }
|
||||
resource_id = @{ type = "str" }
|
||||
min_version = @{ type = "str"; default = "10.0.17763.0" }
|
||||
max_version = @{ type = "str"; default = "10.0.18362.0" }
|
||||
filename = @{ type = "str"; required = $true }
|
||||
}
|
||||
}
|
||||
bundles = @{
|
||||
type = "list"
|
||||
elements = "dict"
|
||||
options = @{
|
||||
files = @{ type = "list"; elements = "str"; required = $true }
|
||||
filename = @{ type = "str"; required = $true }
|
||||
}
|
||||
}
|
||||
publisher = @{ type = "str"; required = $true }
|
||||
path = @{ type = "str"; required = $true }
|
||||
makeappx_path = @{ type = "str"; required = $true }
|
||||
signtool_path = @{ type = "str"; required = $true }
|
||||
}
|
||||
}
|
||||
|
||||
$module = [Ansible.Basic.AnsibleModule]::Create($args, $spec)
|
||||
|
||||
$packages = $module.Params.packages
|
||||
$bundles = $module.Params.bundles
|
||||
$publisher = $module.Params.publisher
|
||||
$path = $module.Params.path
|
||||
$makeappxPath = $module.Params.makeappx_path
|
||||
$signtoolPath = $module.Params.signtool_path
|
||||
|
||||
if (-not (Test-Path -LiteralPath $path)) {
|
||||
$module.FailJson("The path at '$path' does not exist")
|
||||
}
|
||||
|
||||
$manifest = @'
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities">
|
||||
<Identity Name="{0}" Version="{1}" Publisher="{2}"{3}{4} />
|
||||
<Properties>
|
||||
<DisplayName>{0}DisplayName</DisplayName>
|
||||
<PublisherDisplayName>PublisherDisplayName</PublisherDisplayName>
|
||||
<Description>Test MSIX Package for win_package</Description>
|
||||
<Logo>icon.png</Logo>
|
||||
</Properties>
|
||||
<Resources>
|
||||
<Resource Language="en-us" />
|
||||
</Resources>
|
||||
<Dependencies>
|
||||
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="{5}" MaxVersionTested="{6}" />
|
||||
</Dependencies>
|
||||
<Capabilities>
|
||||
<rescap:Capability Name="runFullTrust"/>
|
||||
</Capabilities>
|
||||
<Applications>
|
||||
<Application Id="MsixPackage" Executable="test.exe" EntryPoint="Windows.FullTrustApplication">
|
||||
<uap:VisualElements DisplayName="{0}AppDisplayName" Description="Description" Square150x150Logo="icon.png" Square44x44Logo="icon.png" BackgroundColor="#464646"/>
|
||||
</Application>
|
||||
</Applications>
|
||||
</Package>
|
||||
'@
|
||||
|
||||
# bytes of http://1x1px.me/000000-0.png
|
||||
$iconBytes = [System.Convert]::FromBase64String('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR4nGNiYAAAAAkAAxkR2eQAAAAASUVORK5CYII=')
|
||||
|
||||
$certParams = @{
|
||||
# Can only create in the My store, so store it there temporarily.
|
||||
CertStoreLocation = 'Cert:\CurrentUser\My'
|
||||
FriendlyName = 'win_package test'
|
||||
KeyUsage = 'DigitalSignature'
|
||||
Subject = $publisher
|
||||
TextExtension = @("2.5.29.37={text}1.3.6.1.5.5.7.3.3", "2.5.29.19={text}")
|
||||
Type = 'Custom'
|
||||
}
|
||||
$cert = New-SelfSignedCertificate @certParams
|
||||
|
||||
try {
|
||||
# Need to create a temporary pfx for signtool.exe and we need to import the cert to the Trusted Root store.
|
||||
$module.Result.thumbprint = $cert.Thumbprint
|
||||
$certPath = Join-Path -Path $module.Tmpdir -ChildPath 'cert.pfx'
|
||||
$certPassword = ([char[]]([char]33..[char]126) | Sort-Object {Get-Random})[0..16] -join ''
|
||||
$certPasswordSS = ConvertTo-SecureString -String $certPassword -AsPlainText -Force
|
||||
$null = $cert | Export-PfxCertificate -FilePath $certPath -Password $certPasswordSS
|
||||
|
||||
$importParams = @{
|
||||
FilePath = $certPath
|
||||
CertStoreLocation = 'Cert:\LocalMachine\Root'
|
||||
Password = $certPasswordSS
|
||||
}
|
||||
$null = Import-PfxCertificate @importParams
|
||||
} finally {
|
||||
$cert | Remove-Item -Force
|
||||
}
|
||||
|
||||
$module.Result.changed = $true
|
||||
|
||||
foreach ($info in $packages) {
|
||||
$architectureAttribute = ""
|
||||
if ($info.architecture) {
|
||||
$architectureAttribute = " ProcessorArchitecture=`"$($info.architecture)`""
|
||||
}
|
||||
|
||||
$resourceIdAttribute = ""
|
||||
if ($info.resource_id) {
|
||||
$resourceIdAttribute = " ResourceId=`"$($info.resource_id)`""
|
||||
}
|
||||
|
||||
$xml = $manifest -f @(
|
||||
$info.identity, $info.version, $publisher, $architectureAttribute, $resourceIdAttribute, $info.min_version,
|
||||
$info.max_version
|
||||
)
|
||||
|
||||
$tempDir = Join-Path -Path $module.Tmpdir -ChildPath ([System.IO.Path]::GetRandomFileName())
|
||||
New-Item -Path $tempDir -ItemType Directory > $null
|
||||
Set-Content -LiteralPath (Join-Path -Path $tempDir -ChildPath 'AppxManifest.xml') -Value $xml
|
||||
Set-Content -LiteralPath (Join-Path -Path $tempDir -ChildPath 'icon.png') -Value $iconBytes
|
||||
Set-Content -LiteralPath (Join-Path -Path $tempDir -ChildPath 'test.exe') -Value ''
|
||||
|
||||
$outPath = Join-Path -Path $path -ChildPath $info.filename
|
||||
$makeArguments = @($makeappxPath, 'pack', '/d', $tempDir, '/p', $outPath, '/o')
|
||||
$res = Run-Command -command (Argv-ToString -arguments $makeArguments)
|
||||
|
||||
if ($res.rc -ne 0) {
|
||||
$module.Result.rc = $res.rc
|
||||
$module.Result.stdout = $res.stdout
|
||||
$module.Result.stderr = $res.stderr
|
||||
$module.FailJson("Failed to make package for $($info.filename): see stdout and stderr for more info")
|
||||
}
|
||||
|
||||
Remove-Item -Literalpath $tempDir -Force -Recurse
|
||||
|
||||
$signArguments = @($signtoolPath, 'sign', '/a', '/v', '/fd', 'SHA256', '/f', $certPath, '/p', $certPassword,
|
||||
$outPath)
|
||||
$res = Run-Command -command (Argv-ToString -arguments $signArguments)
|
||||
|
||||
if ($res.rc -ne 0) {
|
||||
$module.Result.rc = $res.rc
|
||||
$module.Result.stdout = $res.stdout
|
||||
$module.Result.stderr = $res.stderr
|
||||
$module.FailJson("Failed to sign package for $($info.filename): see stdout and stderr for more info")
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($info in $bundles) {
|
||||
$tempDir = Join-Path -Path $module.Tmpdir -ChildPath ([System.IO.Path]::GetRandomFileName())
|
||||
New-Item -Path $tempDir -ItemType Directory > $null
|
||||
foreach ($name in $info.files) {
|
||||
$sourcePath = Join-Path -Path $path -ChildPath $name
|
||||
$targetPath = Join-Path -Path $tempDir -ChildPath $name
|
||||
Move-Item -LiteralPath $sourcePath -Destination $targetPath
|
||||
}
|
||||
$outPath = Join-Path -Path $path -ChildPath $info.filename
|
||||
$makeArguments = @($makeappxPath, 'bundle', '/d', $tempDir, '/p', $outPath, '/o')
|
||||
$res = Run-Command -command (Argv-ToString -arguments $makeArguments)
|
||||
|
||||
if ($res.rc -ne 0) {
|
||||
$module.Result.rc = $res.rc
|
||||
$module.Result.stdout = $res.stdout
|
||||
$module.Result.stderr = $res.stderr
|
||||
$module.FailJson("Failed to make bundle for $($info.filename): see stdout and stderr for more info")
|
||||
}
|
||||
|
||||
Remove-Item -LiteralPath $tempDir -Force -Recurse
|
||||
|
||||
$signArguments = @($signtoolPath, 'sign', '/a', '/v', '/fd', 'SHA256', '/f', $certPath, '/p', $certPassword,
|
||||
$outPath)
|
||||
$res = Run-Command -command (Argv-ToString -arguments $signArguments)
|
||||
|
||||
if ($res.rc -ne 0) {
|
||||
$module.Result.rc = $res.rc
|
||||
$module.Result.stdout = $res.stdout
|
||||
$module.Result.stderr = $res.stderr
|
||||
$module.FailJson("Failed to sign bundle for $($info.filename): see stdout and stderr for more info")
|
||||
}
|
||||
}
|
||||
|
||||
$module.ExitJson()
|
@ -0,0 +1,2 @@
|
||||
dependencies:
|
||||
- setup_remote_tmp_dir
|
@ -1,303 +0,0 @@
|
||||
---
|
||||
- name: install local exe (check mode)
|
||||
win_package:
|
||||
path: '{{test_win_package_path}}\7z.exe'
|
||||
product_id: '{{test_win_package_exe_id}}'
|
||||
arguments: /S
|
||||
state: present
|
||||
register: install_local_exe_check
|
||||
check_mode: yes
|
||||
|
||||
- name: get result of install local exe (check mode)
|
||||
win_reg_stat:
|
||||
path: HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{{test_win_package_exe_id}}
|
||||
register: install_local_exe_actual_check
|
||||
|
||||
- name: assert install local exe (check mode)
|
||||
assert:
|
||||
that:
|
||||
- install_local_exe_check is changed
|
||||
- install_local_exe_check.reboot_required == False
|
||||
- install_local_exe_actual_check.exists == False
|
||||
|
||||
- name: install local exe
|
||||
win_package:
|
||||
path: '{{test_win_package_path}}\7z.exe'
|
||||
product_id: '{{test_win_package_exe_id}}'
|
||||
arguments: /S
|
||||
state: present
|
||||
register: install_local_exe
|
||||
|
||||
- name: get result of install local exe
|
||||
win_reg_stat:
|
||||
path: HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{{test_win_package_exe_id}}
|
||||
register: install_local_exe_actual
|
||||
|
||||
- name: assert install local exe
|
||||
assert:
|
||||
that:
|
||||
- install_local_exe is changed
|
||||
- install_local_exe.reboot_required == False
|
||||
- install_local_exe.rc == 0
|
||||
- install_local_exe_actual.exists == True
|
||||
|
||||
- name: install local exe (idempotent)
|
||||
win_package:
|
||||
path: '{{test_win_package_path}}\7z.exe'
|
||||
product_id: '{{test_win_package_exe_id}}'
|
||||
arguments: /S
|
||||
state: present
|
||||
register: install_local_exe_idempotent
|
||||
|
||||
- name: assert install local exe (idempotent)
|
||||
assert:
|
||||
that:
|
||||
- install_local_exe_idempotent is not changed
|
||||
|
||||
- name: uninstall local exe with path (check mode)
|
||||
win_package:
|
||||
path: C:\Program Files\7-Zip\Uninstall.exe
|
||||
product_id: '{{test_win_package_exe_id}}'
|
||||
arguments: /S
|
||||
state: absent
|
||||
register: uninstall_path_local_exe_check
|
||||
check_mode: yes
|
||||
|
||||
- name: get result of uninstall local exe with path (check mode)
|
||||
win_reg_stat:
|
||||
path: HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{{test_win_package_exe_id}}
|
||||
register: uninstall_path_local_exe_actual_check
|
||||
|
||||
- name: assert uninstall local exe with path (check mode)
|
||||
assert:
|
||||
that:
|
||||
- uninstall_path_local_exe_check is changed
|
||||
- uninstall_path_local_exe_check.reboot_required == False
|
||||
- uninstall_path_local_exe_actual_check.exists == True
|
||||
|
||||
- name: uninstall local exe with path
|
||||
win_package:
|
||||
path: C:\Program Files\7-Zip\Uninstall.exe
|
||||
product_id: '{{test_win_package_exe_id}}'
|
||||
arguments: /S
|
||||
state: absent
|
||||
register: uninstall_path_local_exe
|
||||
|
||||
- name: get result of uninstall local exe with path
|
||||
win_reg_stat:
|
||||
path: HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{{test_win_package_exe_id}}
|
||||
register: uninstall_path_local_exe_actual
|
||||
|
||||
- name: assert uninstall local exe with path
|
||||
assert:
|
||||
that:
|
||||
- uninstall_path_local_exe is changed
|
||||
- uninstall_path_local_exe.reboot_required == False
|
||||
- uninstall_path_local_exe.rc == 0
|
||||
- uninstall_path_local_exe_actual.exists == False
|
||||
|
||||
- name: uninstall local exe with path (idempotent)
|
||||
win_package:
|
||||
path: C:\Program Files\7-Zip\Uninstall.exe
|
||||
product_id: '{{test_win_package_exe_id}}'
|
||||
arguments: /S
|
||||
state: absent
|
||||
register: uninstall_path_local_exe_idempotent
|
||||
|
||||
- name: assert uninstall local exe with path (idempotent)
|
||||
assert:
|
||||
that:
|
||||
- uninstall_path_local_exe_idempotent is not changed
|
||||
|
||||
- name: install url exe (check mode)
|
||||
win_package:
|
||||
path: '{{test_win_package_exe_url}}'
|
||||
product_id: '{{test_win_package_exe_id}}'
|
||||
arguments: /S
|
||||
state: present
|
||||
register: install_url_exe_check
|
||||
check_mode: yes
|
||||
|
||||
- name: get result of install url exe (check mode)
|
||||
win_reg_stat:
|
||||
path: HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{{test_win_package_exe_id}}
|
||||
register: install_url_exe_actual_check
|
||||
|
||||
- name: assert install url exe (check mode)
|
||||
assert:
|
||||
that:
|
||||
- install_url_exe_check is changed
|
||||
- install_url_exe_check.reboot_required == False
|
||||
- install_url_exe_actual_check.exists == False
|
||||
|
||||
- name: install url exe
|
||||
win_package:
|
||||
path: '{{test_win_package_exe_url}}'
|
||||
product_id: '{{test_win_package_exe_id}}'
|
||||
arguments: /S
|
||||
state: present
|
||||
register: install_url_exe
|
||||
|
||||
- name: get result of install url exe
|
||||
win_reg_stat:
|
||||
path: HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{{test_win_package_exe_id}}
|
||||
register: install_url_exe_actual
|
||||
|
||||
- name: assert install url exe
|
||||
assert:
|
||||
that:
|
||||
- install_url_exe is changed
|
||||
- install_url_exe.reboot_required == False
|
||||
- install_url_exe.rc == 0
|
||||
- install_url_exe_actual.exists == True
|
||||
|
||||
- name: install url exe (idempotent)
|
||||
win_package:
|
||||
path: '{{test_win_package_exe_url}}'
|
||||
product_id: '{{test_win_package_exe_id}}'
|
||||
arguments: /S
|
||||
state: present
|
||||
register: install_url_exe_again
|
||||
|
||||
- name: assert install url exe (idempotent)
|
||||
assert:
|
||||
that:
|
||||
- install_url_exe_again is not changed
|
||||
|
||||
- name: uninstall local exe with product_id (check mode)
|
||||
win_package:
|
||||
product_id: '{{test_win_package_exe_id}}'
|
||||
arguments: /S
|
||||
state: absent
|
||||
register: uninstall_id_local_exe_check
|
||||
check_mode: yes
|
||||
|
||||
- name: get result of uninstall local exe with product_id (check mode)
|
||||
win_reg_stat:
|
||||
path: HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{{test_win_package_exe_id}}
|
||||
register: uninstall_id_local_exe_actual_check
|
||||
|
||||
- name: assert uninstall local exe with product_id (check mode)
|
||||
assert:
|
||||
that:
|
||||
- uninstall_id_local_exe_check is changed
|
||||
- uninstall_id_local_exe_check.reboot_required == False
|
||||
- uninstall_id_local_exe_actual_check.exists == True
|
||||
|
||||
- name: uninstall local exe with product_id
|
||||
win_package:
|
||||
product_id: '{{test_win_package_exe_id}}'
|
||||
arguments: /S
|
||||
state: absent
|
||||
register: uninstall_id_local_exe
|
||||
|
||||
- name: get result of uninstall local exe with product_id
|
||||
win_reg_stat:
|
||||
path: HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{{test_win_package_exe_id}}
|
||||
register: uninstall_id_local_exe_actual
|
||||
|
||||
- name: assert uninstall local exe with product_id
|
||||
assert:
|
||||
that:
|
||||
- uninstall_id_local_exe is changed
|
||||
- uninstall_id_local_exe.reboot_required == False
|
||||
- uninstall_id_local_exe.rc == 0
|
||||
- uninstall_id_local_exe_actual.exists == False
|
||||
|
||||
- name: uninstall local exe with product_id (idempotent)
|
||||
win_package:
|
||||
product_id: '{{test_win_package_exe_id}}'
|
||||
arguments: /S
|
||||
state: absent
|
||||
register: uninstall_id_local_exe_idempotent
|
||||
|
||||
- name: assert uninstall local exe with product_id (idempotent)
|
||||
assert:
|
||||
that:
|
||||
- uninstall_id_local_exe_idempotent is not changed
|
||||
|
||||
- name: install exe checking path
|
||||
win_package:
|
||||
path: '{{test_win_package_path}}\7z.exe'
|
||||
arguments: /S
|
||||
creates_path: C:\Program Files\7-Zip\7z.exe
|
||||
register: install_exe_create_path
|
||||
|
||||
- name: get result of install exe checking path
|
||||
win_reg_stat:
|
||||
path: HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{{test_win_package_exe_id}}
|
||||
register: install_exe_create_path_actual
|
||||
|
||||
- name: assert install exe checking path
|
||||
assert:
|
||||
that:
|
||||
- install_exe_create_path.changed == True
|
||||
- install_exe_create_path_actual.exists == True
|
||||
|
||||
- name: install exe checking path (idempotent)
|
||||
win_package:
|
||||
path: '{{test_win_package_path}}\7z.exe'
|
||||
arguments: /S
|
||||
creates_path: C:\Program Files\7-Zip\7z.exe
|
||||
register: install_exe_create_path_again
|
||||
|
||||
- name: assert install exe checking path (idempotent)
|
||||
assert:
|
||||
that:
|
||||
- not install_exe_create_path_again.changed == True
|
||||
|
||||
- name: install exe checking path and version
|
||||
win_package:
|
||||
path: '{{test_win_package_path}}\7z.exe'
|
||||
arguments: /S
|
||||
creates_path: C:\Program Files\7-Zip\7z.exe
|
||||
creates_version: '16.04'
|
||||
register: install_exe_create_version_match
|
||||
|
||||
- name: assert install exe checking path and version
|
||||
assert:
|
||||
that:
|
||||
- install_exe_create_version_match is not changed
|
||||
|
||||
- name: install exe checking path and version mismatch
|
||||
win_package:
|
||||
path: '{{test_win_package_path}}\7z.exe'
|
||||
arguments: /S
|
||||
creates_path: C:\Program Files\7-Zip\7z.exe
|
||||
creates_version: fail-version
|
||||
register: install_exe_create_version_mismatch
|
||||
|
||||
- name: assert install exe checking path and version mistmatch
|
||||
assert:
|
||||
that:
|
||||
- install_exe_create_version_mismatch is changed
|
||||
|
||||
- name: install exe checking service
|
||||
win_package:
|
||||
path: '{{test_win_package_path}}\7z.exe'
|
||||
arguments: /S
|
||||
creates_service: Netlogon
|
||||
register: install_exe_create_service_match
|
||||
|
||||
- name: assert install exe checking service
|
||||
assert:
|
||||
that:
|
||||
- install_exe_create_service_match is not changed
|
||||
|
||||
- name: install exe checking service mismatch
|
||||
win_package:
|
||||
path: '{{test_win_package_path}}\7z.exe'
|
||||
arguments: /S
|
||||
creates_service: fake-service
|
||||
register: install_exe_create_service_mismatch
|
||||
|
||||
- name: assert install exe checking service mismatch
|
||||
assert:
|
||||
that:
|
||||
- install_exe_create_service_mismatch is changed
|
||||
|
||||
- name: uninstall exe post tests
|
||||
win_package:
|
||||
arguments: /S
|
||||
product_id: '{{test_win_package_exe_id}}'
|
||||
state: absent
|
@ -1,63 +1,71 @@
|
||||
---
|
||||
- name: ensure testing folders exists
|
||||
- name: ensure testing folder exists
|
||||
win_file:
|
||||
path: '{{item}}'
|
||||
path: '{{ test_path }}'
|
||||
state: directory
|
||||
with_items:
|
||||
- '{{test_win_package_path}}'
|
||||
- '{{test_win_package_path_safe}}'
|
||||
|
||||
- name: download msi files from S3 bucket
|
||||
# Some of the registry_tests.yml create a badly formed unisntall string so remove the reg entry in case the test
|
||||
# didn't get to cleaning itself up
|
||||
- name: remove registry package path
|
||||
win_regedit:
|
||||
path: HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{{ registry_id }}
|
||||
state: absent
|
||||
|
||||
- name: download packages from S3 bucket
|
||||
win_get_url:
|
||||
url: '{{ item.url }}'
|
||||
dest: '{{test_win_package_path}}\{{item.name}}'
|
||||
dest: '{{ test_path }}\{{ item.name }}'
|
||||
with_items:
|
||||
- { url: '{{test_win_package_good_url}}', name: 'good.msi' }
|
||||
- { url: '{{test_win_package_reboot_url}}', name: 'reboot.msi' }
|
||||
- { url: '{{test_win_package_bad_url}}', name: 'bad.msi' }
|
||||
# - { url: '{{test_win_package_exe_url}}', name: '7z.exe' }
|
||||
- url: '{{ good_url }}'
|
||||
name: good.msi
|
||||
- url: '{{ reboot_url }}'
|
||||
name: reboot.msi
|
||||
- url: '{{ bad_url }}'
|
||||
name: bad.msi
|
||||
- url: '{{ patch_msi_url }}'
|
||||
name: patch.msi
|
||||
- url: '{{ patch_msp_url }}'
|
||||
name: patch.msp
|
||||
|
||||
- name: make sure all test msi's are uninstalled before test
|
||||
- name: make sure all test packages are uninstalled before test
|
||||
win_package:
|
||||
product_id: '{{item.id}}'
|
||||
arguments: '{{item.args|default(omit)}}'
|
||||
product_id: '{{ item }}'
|
||||
state: absent
|
||||
with_items:
|
||||
- { id: '{{test_win_package_good_id}}' }
|
||||
- { id: '{{test_win_package_reboot_id}}' }
|
||||
# - { id: '{{test_win_package_exe_id}}', args: '/S' }
|
||||
with_items: '{{ all_ids }}'
|
||||
|
||||
- block:
|
||||
- name: run tests for expected failures
|
||||
include_tasks: failure_tests.yml
|
||||
|
||||
- name: run tests for local and URL msi files
|
||||
- name: run tests for msi files and URL paths
|
||||
include_tasks: msi_tests.yml
|
||||
|
||||
# doesn't work 100% on AWS hosts, disabling for now until we get a better exe example
|
||||
# - name: run tests for local and URL exe files
|
||||
# include_tasks: exe_tests.yml
|
||||
# The msix test setup will only work on Server 2019 or newer so conditionally run this
|
||||
- name: check if we can run the msix tests
|
||||
win_shell: |
|
||||
$osVersion = [Version](Get-Item -LiteralPath "$env:SystemRoot\System32\kernel32.dll").VersionInfo.ProductVersion
|
||||
$osVersion -ge [Version]"10.0.17763"
|
||||
register: can_run_msix
|
||||
changed_when: False
|
||||
|
||||
- name: run tests for msix packages
|
||||
include_tasks: msix_tests.yml
|
||||
when: can_run_msix.stdout | trim | bool
|
||||
|
||||
- name: run tests for msp packages
|
||||
include_tasks: msp_tests.yml
|
||||
|
||||
# these tests can be run manually by defining test_win_package_network_path
|
||||
- name: run tests for network msi files (manual)
|
||||
include_tasks: network_tests.yml
|
||||
when: test_win_package_network_path is defined
|
||||
- name: run tests for registry packages
|
||||
include_tasks: registry_tests.yml
|
||||
|
||||
always:
|
||||
- name: make sure all test msi's are uninstalled after test
|
||||
win_package:
|
||||
product_id: '{{item.id}}'
|
||||
arguments: '{{item.args|default(omit)}}'
|
||||
- name: remove registry package path
|
||||
win_regedit:
|
||||
path: HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{{ registry_id }}
|
||||
state: absent
|
||||
with_items:
|
||||
- { id: '{{test_win_package_good_id}}' }
|
||||
- { id: '{{test_win_package_reboot_id}}' }
|
||||
# - { id: '{{test_win_package_exe_id}}', args: '/S' }
|
||||
|
||||
- name: cleanup test artifacts
|
||||
win_file:
|
||||
path: '{{item}}'
|
||||
- name: make sure all test packages are uninstalled after test
|
||||
win_package:
|
||||
product_id: '{{ item }}'
|
||||
state: absent
|
||||
with_items:
|
||||
- '{{test_win_package_path}}'
|
||||
- '{{test_win_package_path_safe}}'
|
||||
with_items: '{{ all_ids }}'
|
||||
|
@ -0,0 +1,450 @@
|
||||
---
|
||||
- name: enable sideloading of apps for test
|
||||
win_regedit:
|
||||
path: HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock
|
||||
name: AllowAllTrustedApps
|
||||
data: 1
|
||||
type: dword
|
||||
state: present
|
||||
notify: remove sideloading mode for msix
|
||||
|
||||
- name: download makeappx binaries
|
||||
win_get_url:
|
||||
url: '{{ makeappx_url }}'
|
||||
dest: '{{ test_path }}\makeappx.zip'
|
||||
|
||||
- name: extract makeappx binaries
|
||||
win_unzip:
|
||||
src: '{{ test_path }}\makeappx.zip'
|
||||
dest: '{{ test_path }}\makeappx'
|
||||
|
||||
- name: setup MSIX packages
|
||||
win_make_appx:
|
||||
packages:
|
||||
- identity: '{{ msix_id }}'
|
||||
version: 1.0.0.0
|
||||
filename: WinPackage-1.0.0.0.msix
|
||||
- identity: '{{ msix_id }}'
|
||||
version: 1.0.0.1
|
||||
filename: WinPackage-1.0.0.1.msix
|
||||
- identity: '{{ appx_id }}'
|
||||
version: 1.0.0.0
|
||||
filename: WinPackage.appx
|
||||
- identity: '{{ msixbundle_id }}'
|
||||
version: 1.0.0.1
|
||||
architecture: x64
|
||||
resource_id: resid
|
||||
filename: WinPackageBundle-x64.msix
|
||||
- identity: '{{ msixbundle_id }}'
|
||||
version: 1.0.0.1
|
||||
architecture: x86
|
||||
resource_id: resid
|
||||
filename: WinPackageBundle-x86.msix
|
||||
- identity: '{{ appxbundle_id }}'
|
||||
version: 1.0.0.1
|
||||
architecture: x64
|
||||
resource_id: resid
|
||||
filename: WinPackageBundle-x64.appx
|
||||
- identity: '{{ appxbundle_id }}'
|
||||
version: 1.0.0.1
|
||||
architecture: x86
|
||||
resource_id: resid
|
||||
filename: WinPackageBundle-x86.appx
|
||||
- identity: FailMsix
|
||||
version: 1.2.3.4
|
||||
min_version: 99.0.0.0
|
||||
max_version: 99.0.0.0
|
||||
filename: Fail.msix
|
||||
bundles:
|
||||
- files:
|
||||
- WinPackageBundle-x64.msix
|
||||
- WinPackageBundle-x86.msix
|
||||
filename: WinPackageBundle.msixbundle
|
||||
- files:
|
||||
- WinPackageBundle-x64.appx
|
||||
- WinPackageBundle-x86.appx
|
||||
filename: WinPackageBundle.appxbundle
|
||||
publisher: CN=Ansible Core, O=Ansible, L=Durhan, S=NC, C=USA
|
||||
path: '{{ test_path }}'
|
||||
makeappx_path: '{{ test_path }}\makeappx\makeappx.exe'
|
||||
signtool_path: '{{ test_path }}\makeappx\signtool.exe'
|
||||
become: yes # New-SelfSignedCertificate requires this to store the cert with key into the store.
|
||||
become_method: runas
|
||||
vars:
|
||||
ansible_become_user: '{{ ansible_user }}'
|
||||
ansible_become_pass: '{{ ansible_password }}'
|
||||
register: test_win_package_msix_packages
|
||||
notify: remove trusted root cert
|
||||
|
||||
- name: install msix (check mode)
|
||||
win_package:
|
||||
path: '{{ test_path }}\WinPackage-1.0.0.0.msix'
|
||||
state: present
|
||||
register: msix_install_check
|
||||
check_mode: yes
|
||||
|
||||
- name: get result of install msix (check mode)
|
||||
win_shell: if (Get-AppxPackage -Name '{{ msix_id }}') { $true } else { $false }
|
||||
register: msix_install_actual_check
|
||||
changed_when: False
|
||||
|
||||
- name: assert install msix (check mode)
|
||||
assert:
|
||||
that:
|
||||
- msix_install_check is changed
|
||||
- msix_install_check.rc == 0
|
||||
- not msix_install_check.reboot_required
|
||||
- not msix_install_actual_check.stdout | trim | bool
|
||||
|
||||
- name: install msix
|
||||
win_package:
|
||||
path: '{{ test_path }}\WinPackage-1.0.0.0.msix'
|
||||
state: present
|
||||
register: msix_install
|
||||
|
||||
- name: get result of install msix
|
||||
win_shell: if (Get-AppxPackage -Name '{{ msix_id }}') { $true } else { $false }
|
||||
register: msix_install_actual
|
||||
changed_when: False
|
||||
|
||||
- name: assert install msix
|
||||
assert:
|
||||
that:
|
||||
- msix_install is changed
|
||||
- msix_install.rc == 0
|
||||
- not msix_install.reboot_required
|
||||
- msix_install_actual.stdout | trim | bool
|
||||
|
||||
- name: install msix (idempotence)
|
||||
win_package:
|
||||
path: '{{ test_path }}\WinPackage-1.0.0.0.msix'
|
||||
state: present
|
||||
register: msix_install_again
|
||||
|
||||
- name: assert install msix (idempotence)
|
||||
assert:
|
||||
that:
|
||||
- not msix_install_again is changed
|
||||
|
||||
- name: install updated msix package
|
||||
win_package:
|
||||
path: '{{ test_path }}\WinPackage-1.0.0.1.msix'
|
||||
state: present
|
||||
register: msix_install_updated
|
||||
|
||||
- name: get result of install updated msix package
|
||||
win_shell: Get-AppxPackage -Name '{{ msix_id }}' | Select-Object -ExpandProperty Version
|
||||
changed_when: False
|
||||
register: msix_install_updated_actual
|
||||
|
||||
- name: assert result of install updated msix package
|
||||
assert:
|
||||
that:
|
||||
- msix_install_updated is changed
|
||||
- msix_install_updated.rc == 0
|
||||
- not msix_install_updated.reboot_required
|
||||
- msix_install_updated_actual.stdout | trim == "1.0.0.1"
|
||||
|
||||
- name: fail to install older msix when new is present
|
||||
win_package:
|
||||
path: '{{ test_path }}\WinPackage-1.0.0.0.msix'
|
||||
state: present
|
||||
register: fail_msix_older
|
||||
failed_when: "'unexpected status from Add-AppxPackage' not in fail_msix_older.msg"
|
||||
|
||||
- name: remove msix by path (check mode)
|
||||
win_package:
|
||||
path: '{{ test_path }}\WinPackage-1.0.0.1.msix'
|
||||
state: absent
|
||||
register: msix_uninstall_check
|
||||
check_mode: yes
|
||||
|
||||
- name: get result of remove msix by path (check mode)
|
||||
win_shell: if (Get-AppxPackage -Name '{{ msix_id }}') { $true } else { $false }
|
||||
changed_when: False
|
||||
register: msix_uninstall_actual_check
|
||||
|
||||
- name: assert results of remove msix by path (check mode)
|
||||
assert:
|
||||
that:
|
||||
- msix_uninstall_check is changed
|
||||
- msix_uninstall_check.rc == 0
|
||||
- not msix_uninstall_check.reboot_required
|
||||
- msix_uninstall_actual_check.stdout | trim | bool
|
||||
|
||||
- name: remove msix by path
|
||||
win_package:
|
||||
path: '{{ test_path }}\WinPackage-1.0.0.1.msix'
|
||||
state: absent
|
||||
register: msix_uninstall
|
||||
|
||||
- name: get result of remove msix by path
|
||||
win_shell: if (Get-AppxPackage -Name '{{ msix_id }}') { $true } else { $false }
|
||||
changed_when: False
|
||||
register: msix_uninstall_actual
|
||||
|
||||
- name: assert results of remove msix by path
|
||||
assert:
|
||||
that:
|
||||
- msix_uninstall is changed
|
||||
- msix_uninstall.rc == 0
|
||||
- not msix_uninstall.reboot_required
|
||||
- not msix_uninstall_actual.stdout | trim | bool
|
||||
|
||||
- name: remove msix by path (idempotence)
|
||||
win_package:
|
||||
path: '{{ test_path }}\WinPackage-1.0.0.1.msix'
|
||||
state: absent
|
||||
register: msix_uninstall_again
|
||||
|
||||
- name: assert results of remove msix by path (idempotence)
|
||||
assert:
|
||||
that:
|
||||
- not msix_uninstall_again is changed
|
||||
|
||||
# The install steps are the same as msix so no need for check and idempotency tests
|
||||
- name: install appx
|
||||
win_package:
|
||||
path: '{{ test_path }}\WinPackage.appx'
|
||||
state: present
|
||||
register: appx_install
|
||||
|
||||
- name: get result of install appx
|
||||
win_shell: if (Get-AppxPackage -Name '{{ appx_id }}') { $true } else { $false }
|
||||
changed_when: False
|
||||
register: appx_install_actual
|
||||
|
||||
- name: assert results of install appx
|
||||
assert:
|
||||
that:
|
||||
- appx_install is changed
|
||||
- appx_install.rc == 0
|
||||
- not appx_install.reboot_required
|
||||
- appx_install_actual.stdout | trim | bool
|
||||
|
||||
- name: remove appx by id (check mode)
|
||||
win_package:
|
||||
product_id: '{{ appx_id }}'
|
||||
state: absent
|
||||
register: appx_uninstall_check
|
||||
check_mode: yes
|
||||
|
||||
- name: get result of remove appx (check mode)
|
||||
win_shell: if (Get-AppxPackage -Name '{{ appx_id }}') { $true } else { $false }
|
||||
changed_when: False
|
||||
register: appx_uninstall_actual_check
|
||||
|
||||
- name: assert results of remove appx by id (check mode)
|
||||
assert:
|
||||
that:
|
||||
- appx_uninstall_check is changed
|
||||
- appx_uninstall_check.rc == 0
|
||||
- not appx_uninstall_check.reboot_required
|
||||
- appx_uninstall_actual_check.stdout | trim | bool
|
||||
|
||||
- name: remove appx by id
|
||||
win_package:
|
||||
product_id: '{{ appx_id }}'
|
||||
state: absent
|
||||
register: appx_uninstall
|
||||
|
||||
- name: get result of remove appx
|
||||
win_shell: if (Get-AppxPackage -Name '{{ appx_id }}') { $true } else { $false }
|
||||
changed_when: False
|
||||
register: appx_uninstall_actual
|
||||
|
||||
- name: assert results of remove appx by id
|
||||
assert:
|
||||
that:
|
||||
- appx_uninstall is changed
|
||||
- appx_uninstall.rc == 0
|
||||
- not appx_uninstall.reboot_required
|
||||
- not appx_uninstall_actual.stdout | trim | bool
|
||||
|
||||
- name: remove appx by id (idempotence)
|
||||
win_package:
|
||||
product_id: '{{ appx_id }}'
|
||||
state: absent
|
||||
register: appx_uninstall_again
|
||||
|
||||
- name: assert results of remove appx by id (idempotence)
|
||||
assert:
|
||||
that:
|
||||
- not appx_uninstall_again is changed
|
||||
|
||||
- name: validate failures are detected on a bad package
|
||||
win_package:
|
||||
path: '{{ test_path }}\Fail.msix'
|
||||
state: present
|
||||
register: fail_msix
|
||||
failed_when: "'unexpected status from Add-AppxPackage' not in fail_msix.msg"
|
||||
|
||||
- name: install msixbundle (check mode)
|
||||
win_package:
|
||||
path: '{{ test_path }}\WinPackageBundle.msixbundle'
|
||||
state: present
|
||||
register: msixbundle_install_check
|
||||
check_mode: yes
|
||||
|
||||
- name: get result of install msixbundle (check mode)
|
||||
win_shell: if (Get-AppxPackage -Name '{{ msixbundle_id }}') { $true } else { $false }
|
||||
changed_when: False
|
||||
register: msixbundle_install_actual_check
|
||||
|
||||
- name: assert install msixbundle (check mode)
|
||||
assert:
|
||||
that:
|
||||
- msixbundle_install_check is changed
|
||||
- msixbundle_install_check.rc == 0
|
||||
- not msixbundle_install_check.reboot_required
|
||||
- not msixbundle_install_actual_check.stdout | trim | bool
|
||||
|
||||
- name: install msixbundle
|
||||
win_package:
|
||||
path: '{{ test_path }}\WinPackageBundle.msixbundle'
|
||||
state: present
|
||||
register: msixbundle_install
|
||||
|
||||
- name: get result of install msixbundle
|
||||
win_shell: if (Get-AppxPackage -Name '{{ msixbundle_id }}') { $true } else { $false }
|
||||
changed_when: False
|
||||
register: msixbundle_install_actual
|
||||
|
||||
- name: assert install msixbundle
|
||||
assert:
|
||||
that:
|
||||
- msixbundle_install is changed
|
||||
- msixbundle_install.rc == 0
|
||||
- not msixbundle_install.reboot_required
|
||||
- msixbundle_install_actual.stdout | trim | bool
|
||||
|
||||
- name: install msixbundle (idempotence)
|
||||
win_package:
|
||||
path: '{{ test_path }}\WinPackageBundle.msixbundle'
|
||||
state: present
|
||||
register: msixbundle_install_again
|
||||
|
||||
- name: assert install msixbundle (idempotence)
|
||||
assert:
|
||||
that:
|
||||
- not msixbundle_install_again is changed
|
||||
|
||||
- name: uninstall msixbundle by id (check mode)
|
||||
win_package:
|
||||
product_id: '{{ msixbundle_id }}'
|
||||
state: absent
|
||||
register: msixbundle_uninstall_check
|
||||
check_mode: yes
|
||||
|
||||
- name: get result of uninstall msixbundle by id (check mode)
|
||||
win_shell: if (Get-AppxPackage -Name '{{ msixbundle_id }}') { $true } else { $false }
|
||||
changed_when: False
|
||||
register: msixbundle_uninstall_actual_check
|
||||
|
||||
- name: assert uninstall msixbundle by id (check mode)
|
||||
assert:
|
||||
that:
|
||||
- msixbundle_uninstall_check is changed
|
||||
- msixbundle_uninstall_check.rc == 0
|
||||
- not msixbundle_uninstall_check.reboot_required
|
||||
- msixbundle_uninstall_actual_check.stdout | trim | bool
|
||||
|
||||
- name: uninstall msixbundle by id
|
||||
win_package:
|
||||
product_id: '{{ msixbundle_id }}'
|
||||
state: absent
|
||||
register: msixbundle_uninstall
|
||||
|
||||
- name: get result of uninstall msixbundle by id
|
||||
win_shell: if (Get-AppxPackage -Name '{{ msixbundle_id }}') { $true } else { $false }
|
||||
changed_when: False
|
||||
register: msixbundle_uninstall_actual
|
||||
|
||||
- name: assert uninstall msixbundle by id
|
||||
assert:
|
||||
that:
|
||||
- msixbundle_uninstall is changed
|
||||
- msixbundle_uninstall.rc == 0
|
||||
- not msixbundle_uninstall.reboot_required
|
||||
- not msixbundle_uninstall_actual.stdout | trim | bool
|
||||
|
||||
- name: uninstall msixbundle by id (idempotence)
|
||||
win_package:
|
||||
product_id: '{{ msixbundle_id }}'
|
||||
state: absent
|
||||
register: msixbundle_uninstall_again
|
||||
|
||||
- name: assert uninstall msixbundle by id (idempotence)
|
||||
assert:
|
||||
that:
|
||||
- not msixbundle_uninstall_again is changed
|
||||
|
||||
# The logic for appxbundle is the same for msixbundle no need for check and idempotence tests
|
||||
- name: install appxbundle
|
||||
win_package:
|
||||
path: '{{ test_path }}\WinPackageBundle.appxbundle'
|
||||
state: present
|
||||
register: appxbundle_install
|
||||
|
||||
- name: get result of install appxbundle
|
||||
win_shell: if (Get-AppxPackage -Name '{{ appxbundle_id }}') { $true } else { $false }
|
||||
changed_when: False
|
||||
register: appxbundle_install_actual
|
||||
|
||||
- name: assert install appxbundle
|
||||
assert:
|
||||
that:
|
||||
- appxbundle_install is changed
|
||||
- appxbundle_install.rc == 0
|
||||
- not appxbundle_install.reboot_required
|
||||
- appxbundle_install_actual.stdout | trim | bool
|
||||
|
||||
- name: uninstall appxbundle by path (check mode)
|
||||
win_package:
|
||||
path: '{{ test_path }}\WinPackageBundle.appxbundle'
|
||||
state: absent
|
||||
register: msixbundle_uninstall_check
|
||||
check_mode: yes
|
||||
|
||||
- name: get result of uninstall appxbundle by path (check mode)
|
||||
win_shell: if (Get-AppxPackage -Name '{{ appxbundle_id }}') { $true } else { $false }
|
||||
changed_when: False
|
||||
register: msixbundle_uninstall_actual_check
|
||||
|
||||
- name: assert uninstall appxbundle by path (check mode)
|
||||
assert:
|
||||
that:
|
||||
- msixbundle_uninstall_check is changed
|
||||
- msixbundle_uninstall_check.rc == 0
|
||||
- not msixbundle_uninstall_check.reboot_required
|
||||
- msixbundle_uninstall_actual_check.stdout | trim | bool
|
||||
|
||||
- name: uninstall appxbundle by path
|
||||
win_package:
|
||||
path: '{{ test_path }}\WinPackageBundle.appxbundle'
|
||||
state: absent
|
||||
register: msixbundle_uninstall
|
||||
|
||||
- name: get result of uninstall appxbundle by path
|
||||
win_shell: if (Get-AppxPackage -Name '{{ appxbundle_id }}') { $true } else { $false }
|
||||
changed_when: False
|
||||
register: msixbundle_uninstall_actual
|
||||
|
||||
- name: assert uninstall appxbundle by path
|
||||
assert:
|
||||
that:
|
||||
- msixbundle_uninstall is changed
|
||||
- msixbundle_uninstall.rc == 0
|
||||
- not msixbundle_uninstall.reboot_required
|
||||
- not msixbundle_uninstall_actual.stdout | trim | bool
|
||||
|
||||
- name: uninstall appxbundle by path (idempotence)
|
||||
win_package:
|
||||
path: '{{ test_path }}\WinPackageBundle.appxbundle'
|
||||
state: absent
|
||||
register: msixbundle_uninstall_again
|
||||
|
||||
- name: assert uninstall appxbundle by path (idempotence)
|
||||
assert:
|
||||
that:
|
||||
- not msixbundle_uninstall_again is changed
|
@ -0,0 +1,167 @@
|
||||
---
|
||||
- name: fail if base product is not applied
|
||||
win_package:
|
||||
path: '{{ test_path }}\patch.msp'
|
||||
state: present
|
||||
register: fail_no_product_found
|
||||
failed_when: '"The specified patch does not apply to any installed MSI packages" not in fail_no_product_found.msg'
|
||||
|
||||
- name: install base package for msp patch
|
||||
win_package:
|
||||
path: '{{ test_path }}\patch.msi'
|
||||
state: present
|
||||
|
||||
- name: install msp (check mode)
|
||||
win_package:
|
||||
path: '{{ test_path }}\patch.msp'
|
||||
state: present
|
||||
register: msp_install_check
|
||||
check_mode: yes
|
||||
|
||||
- name: get result of install msp (check mode)
|
||||
slurp:
|
||||
path: '{{ patch_install_file }}'
|
||||
register: msp_install_actual_check
|
||||
|
||||
- name: assert install msp (check mode)
|
||||
assert:
|
||||
that:
|
||||
- msp_install_check is changed
|
||||
- msp_install_check.rc == 0
|
||||
- not msp_install_check.reboot_required
|
||||
- msp_install_actual_check.content | b64decode == 'This is version 1.0'
|
||||
|
||||
- name: install msp
|
||||
win_package:
|
||||
path: '{{ test_path }}\patch.msp'
|
||||
state: present
|
||||
register: msp_install
|
||||
|
||||
- name: get result of install msp
|
||||
slurp:
|
||||
path: '{{ patch_install_file }}'
|
||||
register: msp_install_actual
|
||||
|
||||
- name: assert install msp
|
||||
assert:
|
||||
that:
|
||||
- msp_install is changed
|
||||
- msp_install.rc == 0
|
||||
- not msp_install.reboot_required
|
||||
- msp_install_actual.content | b64decode == 'This is version 1.1'
|
||||
|
||||
- name: install msp (idempotence)
|
||||
win_package:
|
||||
path: '{{ test_path }}\patch.msp'
|
||||
state: present
|
||||
register: msp_install_again
|
||||
|
||||
- name: assert install msp (idempotence)
|
||||
assert:
|
||||
that:
|
||||
- not msp_install_again is changed
|
||||
|
||||
- name: remove msp by path (check mode)
|
||||
win_package:
|
||||
path: '{{ test_path }}\patch.msp'
|
||||
state: absent
|
||||
register: msp_uninstall_path_check
|
||||
check_mode: yes
|
||||
|
||||
- name: get result of remove msp by path (check mode)
|
||||
slurp:
|
||||
path: '{{ patch_install_file }}'
|
||||
register: msp_uninstall_path_actual_check
|
||||
|
||||
- name: assert remove msp by path (check mode)
|
||||
assert:
|
||||
that:
|
||||
- msp_uninstall_path_check is changed
|
||||
- msp_uninstall_path_check.rc == 0
|
||||
- not msp_uninstall_path_check.reboot_required
|
||||
- msp_uninstall_path_actual_check.content | b64decode == 'This is version 1.1'
|
||||
|
||||
- name: remove msp by path
|
||||
win_package:
|
||||
path: '{{ test_path }}\patch.msp'
|
||||
state: absent
|
||||
register: msp_uninstall_path
|
||||
|
||||
- name: get result of remove msp by path
|
||||
slurp:
|
||||
path: '{{ patch_install_file }}'
|
||||
register: msp_uninstall_path_actual
|
||||
|
||||
- name: assert remove msp by path
|
||||
assert:
|
||||
that:
|
||||
- msp_uninstall_path is changed
|
||||
- msp_uninstall_path.rc == 0
|
||||
- not msp_uninstall_path.reboot_required
|
||||
- msp_uninstall_path_actual.content | b64decode == 'This is version 1.0'
|
||||
|
||||
- name: remove msp by path (idempotence)
|
||||
win_package:
|
||||
path: '{{ test_path }}\patch.msp'
|
||||
state: absent
|
||||
register: msp_uninstall_path_again
|
||||
|
||||
- name: assert remove msp by path (idempotence)
|
||||
assert:
|
||||
that:
|
||||
- not msp_uninstall_path_again is changed
|
||||
|
||||
- name: install patch again
|
||||
win_package:
|
||||
path: '{{ test_path }}\patch.msp'
|
||||
state: present
|
||||
|
||||
- name: remove msp by id (check mode)
|
||||
win_package:
|
||||
product_id: '{{ patch_patch_id }}'
|
||||
state: absent
|
||||
register: msp_uninstall_id_check
|
||||
check_mode: yes
|
||||
|
||||
- name: get result of remove msp by id (check mode)
|
||||
slurp:
|
||||
path: '{{ patch_install_file }}'
|
||||
register: msp_uninstall_id_actual_check
|
||||
|
||||
- name: assert remove msp by id (check mode)
|
||||
assert:
|
||||
that:
|
||||
- msp_uninstall_id_check is changed
|
||||
- msp_uninstall_id_check.rc == 0
|
||||
- not msp_uninstall_id_check.reboot_required
|
||||
- msp_uninstall_id_actual_check.content | b64decode == 'This is version 1.1'
|
||||
|
||||
- name: remove msp by id
|
||||
win_package:
|
||||
product_id: '{{ patch_patch_id }}'
|
||||
state: absent
|
||||
register: msp_uninstall_id
|
||||
|
||||
- name: get result of remove msp by id
|
||||
slurp:
|
||||
path: '{{ patch_install_file }}'
|
||||
register: msp_uninstall_id_actual
|
||||
|
||||
- name: assert remove msp by id
|
||||
assert:
|
||||
that:
|
||||
- msp_uninstall_id is changed
|
||||
- msp_uninstall_id.rc == 0
|
||||
- not msp_uninstall_id.reboot_required
|
||||
- msp_uninstall_id_actual.content | b64decode == 'This is version 1.0'
|
||||
|
||||
- name: remove msp by id (idempotence)
|
||||
win_package:
|
||||
product_id: '{{ patch_patch_id }}'
|
||||
state: absent
|
||||
register: msp_uninstall_id_again
|
||||
|
||||
- name: assert remove msp by id (idempotence)
|
||||
assert:
|
||||
that:
|
||||
- not msp_uninstall_id_again is changed
|
@ -1,427 +0,0 @@
|
||||
---
|
||||
- name: install network msi (check mode)
|
||||
win_package:
|
||||
path: '{{test_win_package_network_path}}\good.msi'
|
||||
product_id: '{{test_win_package_good_id}}'
|
||||
state: present
|
||||
user_name: '{{test_win_package_network_username|default(omit)}}'
|
||||
user_password: '{{test_win_package_network_password|default(omit)}}'
|
||||
register: install_network_msi_check
|
||||
check_mode: yes
|
||||
|
||||
- name: get result of install network msi (check mode)
|
||||
win_reg_stat:
|
||||
path: HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{{test_win_package_good_id}}
|
||||
register: install_network_msi_actual_check
|
||||
|
||||
- name: assert install network msi (check mode)
|
||||
assert:
|
||||
that:
|
||||
- install_network_msi_check is changed
|
||||
- install_network_msi_check.reboot_required == False
|
||||
- install_network_msi_actual_check.exists == False
|
||||
|
||||
- name: install network msi
|
||||
win_package:
|
||||
path: '{{test_win_package_network_path}}\good.msi'
|
||||
product_id: '{{test_win_package_good_id}}'
|
||||
state: present
|
||||
user_name: '{{test_win_package_network_username|default(omit)}}'
|
||||
user_password: '{{test_win_package_network_password|default(omit)}}'
|
||||
register: install_network_msi
|
||||
|
||||
- name: get result of install network msi
|
||||
win_reg_stat:
|
||||
path: HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{{test_win_package_good_id}}
|
||||
register: install_network_msi_actual
|
||||
|
||||
- name: assert install network msi
|
||||
assert:
|
||||
that:
|
||||
- install_network_msi is changed
|
||||
- install_network_msi.reboot_required == False
|
||||
- install_network_msi.rc == 0
|
||||
- install_network_msi_actual.exists == True
|
||||
|
||||
- name: install network msi (idempotent)
|
||||
win_package:
|
||||
path: '{{test_win_package_network_path}}\good.msi'
|
||||
product_id: '{{test_win_package_good_id}}'
|
||||
state: present
|
||||
user_name: '{{test_win_package_network_username|default(omit)}}'
|
||||
user_password: '{{test_win_package_network_password|default(omit)}}'
|
||||
register: install_network_msi_idempotent
|
||||
|
||||
- name: assert install network msi (idempotent)
|
||||
assert:
|
||||
that:
|
||||
- install_network_msi_idempotent is not changed
|
||||
|
||||
- name: uninstall network msi with path (check mode)
|
||||
win_package:
|
||||
path: '{{test_win_package_network_path}}\good.msi'
|
||||
product_id: '{{test_win_package_good_id}}'
|
||||
state: absent
|
||||
user_name: '{{test_win_package_network_username|default(omit)}}'
|
||||
user_password: '{{test_win_package_network_password|default(omit)}}'
|
||||
register: uninstall_path_network_msi_check
|
||||
check_mode: yes
|
||||
|
||||
- name: get result of uninstall network msi with path (check mode)
|
||||
win_reg_stat:
|
||||
path: HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{{test_win_package_good_id}}
|
||||
register: uninstall_path_network_msi_actual_check
|
||||
|
||||
- name: assert uninstall network msi with path (check mode)
|
||||
assert:
|
||||
that:
|
||||
- uninstall_path_network_msi_check is changed
|
||||
- uninstall_path_network_msi_check.reboot_required == False
|
||||
- uninstall_path_network_msi_actual_check.exists == True
|
||||
|
||||
- name: uninstall network msi with path
|
||||
win_package:
|
||||
path: '{{test_win_package_network_path}}\good.msi'
|
||||
product_id: '{{test_win_package_good_id}}'
|
||||
state: absent
|
||||
user_name: '{{test_win_package_network_username|default(omit)}}'
|
||||
user_password: '{{test_win_package_network_password|default(omit)}}'
|
||||
register: uninstall_path_network_msi
|
||||
|
||||
- name: get result of uninstall network msi with path
|
||||
win_reg_stat:
|
||||
path: HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{{test_win_package_good_id}}
|
||||
register: uninstall_path_network_msi_actual
|
||||
|
||||
- name: assert uninstall network msi with path
|
||||
assert:
|
||||
that:
|
||||
- uninstall_path_network_msi is changed
|
||||
- uninstall_path_network_msi.reboot_required == False
|
||||
- uninstall_path_network_msi.rc == 0
|
||||
- uninstall_path_network_msi_actual.exists == False
|
||||
|
||||
- name: uninstall network msi with path (idempotent)
|
||||
win_package:
|
||||
path: '{{test_win_package_network_path}}\good.msi'
|
||||
product_id: '{{test_win_package_good_id}}'
|
||||
state: absent
|
||||
user_name: '{{test_win_package_network_username|default(omit)}}'
|
||||
user_password: '{{test_win_package_network_password|default(omit)}}'
|
||||
register: uninstall_path_network_msi_idempotent
|
||||
|
||||
- name: assert uninstall network msi with path (idempotent)
|
||||
assert:
|
||||
that:
|
||||
- uninstall_path_network_msi_idempotent is not changed
|
||||
|
||||
- name: install network reboot msi (check mode)
|
||||
win_package:
|
||||
path: '{{test_win_package_network_path}}\reboot.msi'
|
||||
product_id: '{{test_win_package_reboot_id}}'
|
||||
state: present
|
||||
user_name: '{{test_win_package_network_username|default(omit)}}'
|
||||
user_password: '{{test_win_package_network_password|default(omit)}}'
|
||||
register: install_network_reboot_msi_check
|
||||
check_mode: yes
|
||||
|
||||
- name: get result of install network reboot msi (check mode)
|
||||
win_reg_stat:
|
||||
path: HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{{test_win_package_reboot_id}}
|
||||
register: install_network_reboot_msi_actual_check
|
||||
|
||||
- name: assert install network reboot msi (check mode)
|
||||
assert:
|
||||
that:
|
||||
- install_network_reboot_msi_check is changed
|
||||
- install_network_reboot_msi_check.reboot_required == False
|
||||
- install_network_reboot_msi_actual_check.exists == False
|
||||
|
||||
- name: install network reboot msi
|
||||
win_package:
|
||||
path: '{{test_win_package_network_path}}\reboot.msi'
|
||||
product_id: '{{test_win_package_reboot_id}}'
|
||||
state: present
|
||||
user_name: '{{test_win_package_network_username|default(omit)}}'
|
||||
user_password: '{{test_win_package_network_password|default(omit)}}'
|
||||
register: install_network_reboot_msi
|
||||
|
||||
- name: get result of install network reboot msi
|
||||
win_reg_stat:
|
||||
path: HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{{test_win_package_reboot_id}}
|
||||
register: install_network_reboot_msi_actual
|
||||
|
||||
- name: assert install network reboot msi
|
||||
assert:
|
||||
that:
|
||||
- install_network_reboot_msi is changed
|
||||
- install_network_reboot_msi.reboot_required == True
|
||||
- install_network_reboot_msi.rc == 3010
|
||||
- install_network_reboot_msi_actual.exists == True
|
||||
|
||||
- name: install network reboot msi (idempotent)
|
||||
win_package:
|
||||
path: '{{test_win_package_network_path}}\reboot.msi'
|
||||
product_id: '{{test_win_package_reboot_id}}'
|
||||
state: present
|
||||
user_name: '{{test_win_package_network_username|default(omit)}}'
|
||||
user_password: '{{test_win_package_network_password|default(omit)}}'
|
||||
register: install_network_reboot_msi_idempotent
|
||||
|
||||
- name: assert install network reboot msi (idempotent)
|
||||
assert:
|
||||
that:
|
||||
- install_network_reboot_msi_idempotent is not changed
|
||||
|
||||
- name: uninstall network msi with product_id (check mode)
|
||||
win_package:
|
||||
product_id: '{{test_win_package_reboot_id}}'
|
||||
state: absent
|
||||
user_name: '{{test_win_package_network_username|default(omit)}}'
|
||||
user_password: '{{test_win_package_network_password|default(omit)}}'
|
||||
register: uninstall_id_network_msi_check
|
||||
check_mode: yes
|
||||
|
||||
- name: get result of uninstall network msi with product_id (check mode)
|
||||
win_reg_stat:
|
||||
path: HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{{test_win_package_reboot_id}}
|
||||
register: uninstall_id_network_msi_actual_check
|
||||
|
||||
- name: assert uninstall network msi with product_id (check mode)
|
||||
assert:
|
||||
that:
|
||||
- uninstall_id_network_msi_check is changed
|
||||
- uninstall_id_network_msi_check.reboot_required == False
|
||||
- uninstall_id_network_msi_actual_check.exists == True
|
||||
|
||||
- name: uninstall network msi with product_id
|
||||
win_package:
|
||||
product_id: '{{test_win_package_reboot_id}}'
|
||||
state: absent
|
||||
register: uninstall_id_network_msi
|
||||
|
||||
- name: get result of uninstall network msi with product_id
|
||||
win_reg_stat:
|
||||
path: HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{{test_win_package_reboot_id}}
|
||||
register: uninstall_id_network_msi_actual
|
||||
|
||||
- name: assert uninstall network msi with product_id
|
||||
assert:
|
||||
that:
|
||||
- uninstall_id_network_msi is changed
|
||||
- uninstall_id_network_msi.reboot_required == True
|
||||
- uninstall_id_network_msi.rc == 3010
|
||||
- uninstall_id_network_msi_actual.exists == False
|
||||
|
||||
- name: uninstall network msi with product_id (idempotent)
|
||||
win_package:
|
||||
product_id: '{{test_win_package_reboot_id}}'
|
||||
state: absent
|
||||
register: uninstall_id_network_msi_idempotent
|
||||
|
||||
- name: assert uninstall network msi with product_id (idempotent)
|
||||
assert:
|
||||
that:
|
||||
- uninstall_id_network_msi_idempotent is not changed
|
||||
|
||||
- name: ensure the install folder is cleaned in case uninstall didn't work
|
||||
win_file:
|
||||
path: '%ProgramFiles(x86)%\Bovine University'
|
||||
state: absent
|
||||
|
||||
- name: install network msi with arguments (check mode)
|
||||
win_package:
|
||||
path: '{{test_win_package_network_path}}\good.msi'
|
||||
product_id: '{{test_win_package_good_id}}'
|
||||
state: present
|
||||
arguments: ADDLOCAL=Cow
|
||||
user_name: '{{test_win_package_network_username|default(omit)}}'
|
||||
user_password: '{{test_win_package_network_password|default(omit)}}'
|
||||
register: install_network_msi_argument_check
|
||||
check_mode: yes
|
||||
|
||||
- name: get result of moo file after install network msi with arguments (check mode)
|
||||
win_stat:
|
||||
path: '%ProgramFiles(x86)%\Bovine University\moo.exe'
|
||||
register: install_network_msi_argument_moo_check
|
||||
|
||||
- name: get result of cow file after install network msi with arguments (check mode)
|
||||
win_stat:
|
||||
path: '%ProgramFiles(x86)%\Bovine University\cow.exe'
|
||||
register: install_network_msi_argument_cow_check
|
||||
|
||||
- name: assert install network msi with arguments (check mode)
|
||||
assert:
|
||||
that:
|
||||
- install_network_msi_argument_check is changed
|
||||
- install_network_msi_argument_check.reboot_required == False
|
||||
- install_network_msi_argument_moo_check.stat.exists == False
|
||||
- install_network_msi_argument_cow_check.stat.exists == False
|
||||
|
||||
- name: install network msi with arguments
|
||||
win_package:
|
||||
path: '{{test_win_package_network_path}}\good.msi'
|
||||
product_id: '{{test_win_package_good_id}}'
|
||||
state: present
|
||||
arguments: ADDLOCAL=Cow
|
||||
user_name: '{{test_win_package_network_username|default(omit)}}'
|
||||
user_password: '{{test_win_package_network_password|default(omit)}}'
|
||||
register: install_network_msi_argument
|
||||
|
||||
- name: get result of moo file after install network msi with arguments
|
||||
win_stat:
|
||||
path: '%ProgramFiles(x86)%\Bovine University\moo.exe'
|
||||
register: install_network_msi_argument_moo
|
||||
|
||||
- name: get result of cow file after install network msi with arguments
|
||||
win_stat:
|
||||
path: '%ProgramFiles(x86)%\Bovine University\cow.exe'
|
||||
register: install_network_msi_argument_cow
|
||||
|
||||
- name: assert install network msi with arguments
|
||||
assert:
|
||||
that:
|
||||
- install_network_msi_argument is changed
|
||||
- install_network_msi_argument.reboot_required == False
|
||||
- install_network_msi_argument.rc == 0
|
||||
- install_network_msi_argument_moo.stat.exists == False
|
||||
- install_network_msi_argument_cow.stat.exists == True
|
||||
|
||||
- name: install network msi with arguments (idempotent)
|
||||
win_package:
|
||||
path: '{{test_win_package_network_path}}\good.msi'
|
||||
product_id: '{{test_win_package_good_id}}'
|
||||
state: present
|
||||
arguments: ADDLOCAL=Cow
|
||||
user_name: '{{test_win_package_network_username|default(omit)}}'
|
||||
user_password: '{{test_win_package_network_password|default(omit)}}'
|
||||
register: install_network_msi_argument_again
|
||||
|
||||
- name: assert install network msi with arguments (idempotent)
|
||||
assert:
|
||||
that:
|
||||
- install_network_msi_argument_again is not changed
|
||||
|
||||
- name: uninstall msi after test
|
||||
win_package:
|
||||
product_id: '{{test_win_package_good_id}}'
|
||||
state: absent
|
||||
|
||||
- name: install network exe (check mode)
|
||||
win_package:
|
||||
path: '{{test_win_package_network_path}}\7z.exe'
|
||||
product_id: '{{test_win_package_exe_id}}'
|
||||
arguments: /S
|
||||
state: present
|
||||
user_name: '{{test_win_package_network_username|default(omit)}}'
|
||||
user_password: '{{test_win_package_network_password|default(omit)}}'
|
||||
register: install_network_exe_check
|
||||
check_mode: yes
|
||||
|
||||
- name: get result of install network exe (check mode)
|
||||
win_reg_stat:
|
||||
path: HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{{test_win_package_exe_id}}
|
||||
register: install_network_exe_actual_check
|
||||
|
||||
- name: assert install network exe (check mode)
|
||||
assert:
|
||||
that:
|
||||
- install_network_exe_check is changed
|
||||
- install_network_exe_check.reboot_required == False
|
||||
- install_network_exe_actual_check.exists == False
|
||||
|
||||
- name: install network exe
|
||||
win_package:
|
||||
path: '{{test_win_package_network_path}}\7z.exe'
|
||||
product_id: '{{test_win_package_exe_id}}'
|
||||
arguments: /S
|
||||
state: present
|
||||
user_name: '{{test_win_package_network_username|default(omit)}}'
|
||||
user_password: '{{test_win_package_network_password|default(omit)}}'
|
||||
register: install_network_exe
|
||||
|
||||
- name: get result of install network exe
|
||||
win_reg_stat:
|
||||
path: HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{{test_win_package_exe_id}}
|
||||
register: install_network_exe_actual
|
||||
|
||||
- name: assert install network exe
|
||||
assert:
|
||||
that:
|
||||
- install_network_exe is changed
|
||||
- install_network_exe.reboot_required == False
|
||||
- install_network_exe.rc == 0
|
||||
- install_network_exe_actual.exists == True
|
||||
|
||||
- name: install network exe (idempotent)
|
||||
win_package:
|
||||
path: '{{test_win_package_network_path}}\7z.exe'
|
||||
product_id: '{{test_win_package_exe_id}}'
|
||||
arguments: /S
|
||||
state: present
|
||||
user_name: '{{test_win_package_network_username|default(omit)}}'
|
||||
user_password: '{{test_win_package_network_password|default(omit)}}'
|
||||
register: install_network_exe_idempotent
|
||||
|
||||
- name: assert install network exe (idempotent)
|
||||
assert:
|
||||
that:
|
||||
- install_network_exe_idempotent is not changed
|
||||
|
||||
- name: uninstall network exe (check mode)
|
||||
win_package:
|
||||
product_id: '{{test_win_package_exe_id}}'
|
||||
arguments: /S
|
||||
state: absent
|
||||
user_name: '{{test_win_package_network_username|default(omit)}}'
|
||||
user_password: '{{test_win_package_network_password|default(omit)}}'
|
||||
register: uninstall_network_exe_check
|
||||
check_mode: yes
|
||||
|
||||
- name: get result of uninstall network exe (check mode)
|
||||
win_reg_stat:
|
||||
path: HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{{test_win_package_exe_id}}
|
||||
register: uninstall_network_exe_actual_check
|
||||
|
||||
- name: assert uninstall network exe (check mode)
|
||||
assert:
|
||||
that:
|
||||
- uninstall_network_exe_check is changed
|
||||
- uninstall_network_exe_check.reboot_required == False
|
||||
- uninstall_network_exe_actual_check.exists == True
|
||||
|
||||
- name: uninstall network exe
|
||||
win_package:
|
||||
product_id: '{{test_win_package_exe_id}}'
|
||||
arguments: /S
|
||||
state: absent
|
||||
user_name: '{{test_win_package_network_username|default(omit)}}'
|
||||
user_password: '{{test_win_package_network_password|default(omit)}}'
|
||||
register: uninstall_network_exe
|
||||
|
||||
- name: get result of uninstall network exe
|
||||
win_reg_stat:
|
||||
path: HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{{test_win_package_exe_id}}
|
||||
register: uninstall_network_exe_actual
|
||||
|
||||
- name: assert uninstall network exe
|
||||
assert:
|
||||
that:
|
||||
- uninstall_network_exe is changed
|
||||
- uninstall_network_exe.reboot_required == False
|
||||
- uninstall_network_exe.rc == 0
|
||||
- uninstall_network_exe_actual.exists == False
|
||||
|
||||
- name: uninstall network exe (idempotent)
|
||||
win_package:
|
||||
product_id: '{{test_win_package_exe_id}}'
|
||||
arguments: /S
|
||||
state: absent
|
||||
user_name: '{{test_win_package_network_username|default(omit)}}'
|
||||
user_password: '{{test_win_package_network_password|default(omit)}}'
|
||||
register: uninstall_network_exe_idempotent
|
||||
|
||||
- name: assert uninstall network exe (idempotent)
|
||||
assert:
|
||||
that:
|
||||
- uninstall_network_exe_idempotent is not changed
|
@ -0,0 +1,393 @@
|
||||
---
|
||||
# This symlink allows us to test paths with a space in the executable path
|
||||
- name: create symbolic link in test folder to powershell
|
||||
win_command: cmd.exe /c mklink "{{ test_path }}\powershell symlink.exe" C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
|
||||
|
||||
- name: copy across test script that creates a registry install entry
|
||||
win_template:
|
||||
src: registry_package.ps1.j2
|
||||
dest: '{{ test_path }}\registry_package.ps1'
|
||||
|
||||
- name: install registry package not quoted and no spaces in path
|
||||
win_package:
|
||||
path: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
|
||||
arguments:
|
||||
- -File
|
||||
- '{{ test_path }}\registry_package.ps1'
|
||||
- HKLMx64
|
||||
- UninstallString
|
||||
- C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command Remove-Item -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{{ registry_id }} -Force -Recurse
|
||||
state: present
|
||||
|
||||
- name: uninstall registry package not quoted and no spaces in path (check mode)
|
||||
win_package:
|
||||
product_id: '{{ registry_id }}'
|
||||
state: absent
|
||||
register: registry_uninstall_normal_check
|
||||
check_mode: yes
|
||||
|
||||
- name: get result of uninstall registry package not quoted and no spaces in path (check mode)
|
||||
win_reg_stat:
|
||||
path: HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{{ registry_id }}
|
||||
register: registry_uninstall_normal_actual_check
|
||||
|
||||
- name: assert uninstall registry package not quoted and no spaces in path (check mode)
|
||||
assert:
|
||||
that:
|
||||
- registry_uninstall_normal_check is changed
|
||||
- registry_uninstall_normal_check.rc == 0
|
||||
- not registry_uninstall_normal_check.reboot_required
|
||||
- registry_uninstall_normal_actual_check.exists
|
||||
|
||||
- name: uninstall registry package not quoted and no spaces in path
|
||||
win_package:
|
||||
product_id: '{{ registry_id }}'
|
||||
state: absent
|
||||
register: registry_uninstall_normal
|
||||
|
||||
- name: get result of uninstall registry package not quoted and no spaces in path
|
||||
win_reg_stat:
|
||||
path: HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{{ registry_id }}
|
||||
register: registry_uninstall_normal_actual
|
||||
|
||||
- name: assert uninstall registry package not quoted and no spaces in path
|
||||
assert:
|
||||
that:
|
||||
- registry_uninstall_normal is changed
|
||||
- registry_uninstall_normal.rc == 0
|
||||
- not registry_uninstall_normal.reboot_required
|
||||
- not registry_uninstall_normal_actual.exists
|
||||
|
||||
- name: uninstall registry package not quoted and no spaces in path (idempotence)
|
||||
win_package:
|
||||
product_id: '{{ registry_id }}'
|
||||
state: absent
|
||||
register: registry_uninstall_normal_again
|
||||
|
||||
- name: assert uninstall registry package not quoted and no spaces in path (idempotence)
|
||||
assert:
|
||||
that:
|
||||
- not registry_uninstall_normal_again is changed
|
||||
|
||||
- name: install registry package not quoted and spaces in path
|
||||
win_package:
|
||||
path: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
|
||||
arguments:
|
||||
- -File
|
||||
- '{{ test_path }}\registry_package.ps1'
|
||||
- HKLMx86
|
||||
- QuietUninstallString
|
||||
- '{{ test_path }}\powershell symlink.exe -Command Remove-Item -Path HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{{ registry_id }} -Force -Recurse'
|
||||
state: present
|
||||
|
||||
- name: uninstall registry package not quoted and spaces in path
|
||||
win_package:
|
||||
product_id: '{{ registry_id }}'
|
||||
state: absent
|
||||
register: registry_uninstall_not_quoted
|
||||
|
||||
- name: get result of uninstall registry package not quoted and spaces in path
|
||||
win_reg_stat:
|
||||
path: HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{{ registry_id }}
|
||||
register: registry_uninstall_not_quoted_actual
|
||||
|
||||
- name: assert uninstall registry package not quoted and spaces in path
|
||||
assert:
|
||||
that:
|
||||
- registry_uninstall_not_quoted is changed
|
||||
- registry_uninstall_not_quoted.rc == 0
|
||||
- not registry_uninstall_not_quoted.reboot_required
|
||||
- not registry_uninstall_not_quoted_actual.exists
|
||||
|
||||
- name: install registry package quoted and no spaces in path
|
||||
win_package:
|
||||
path: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
|
||||
arguments:
|
||||
- -File
|
||||
- '{{ test_path }}\registry_package.ps1'
|
||||
- HKCUx64
|
||||
- UninstallString
|
||||
- '"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -Command Remove-Item -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{{ registry_id }} -Force -Recurse'
|
||||
state: present
|
||||
|
||||
- name: uninstall registry package quoted and no spaces in path
|
||||
win_package:
|
||||
product_id: '{{ registry_id }}'
|
||||
state: absent
|
||||
register: registry_uninstall_quoted_normal
|
||||
|
||||
- name: get result of uninstall registry package quoted and no spaces in path
|
||||
win_reg_stat:
|
||||
path: HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Unisntall\{{ registry_id }}
|
||||
register: registry_uninstall_quoted_normal_actual
|
||||
|
||||
- name: assert uninstall registry package quoted and no spaces in path
|
||||
assert:
|
||||
that:
|
||||
- registry_uninstall_quoted_normal is changed
|
||||
- registry_uninstall_quoted_normal.rc == 0
|
||||
- not registry_uninstall_quoted_normal.reboot_required
|
||||
- not registry_uninstall_quoted_normal_actual.exists
|
||||
|
||||
- name: install registry package quoted and spaces in path
|
||||
win_package:
|
||||
path: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
|
||||
arguments:
|
||||
- -File
|
||||
- '{{ test_path }}\registry_package.ps1'
|
||||
- HKCUx86
|
||||
- QuietUninstallString
|
||||
- '"{{ test_path }}\powershell symlink.exe" -Command Remove-Item -Path HKCU:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{{ registry_id }} -Force -Recurse'
|
||||
state: present
|
||||
|
||||
- name: uninstall registry package quoted and spaces in path
|
||||
win_package:
|
||||
product_id: '{{ registry_id }}'
|
||||
state: absent
|
||||
register: registry_uninstall_quoted_spaces
|
||||
|
||||
- name: get result of uninstall registry package quoted and spaces in path
|
||||
win_reg_stat:
|
||||
path: HKCU:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{{ registry_id }}
|
||||
register: registry_uninstall_quoted_spaces_actual
|
||||
|
||||
- name: assert uninstall registry package quoted and spaces in path
|
||||
assert:
|
||||
that:
|
||||
- registry_uninstall_quoted_spaces is changed
|
||||
- registry_uninstall_quoted_spaces.rc == 0
|
||||
- not registry_uninstall_quoted_spaces.reboot_required
|
||||
- not registry_uninstall_quoted_spaces_actual.exists
|
||||
|
||||
- name: install registry package with unquoted env vars
|
||||
win_package:
|
||||
path: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
|
||||
arguments:
|
||||
- -File
|
||||
- '{{ test_path }}\registry_package.ps1'
|
||||
- HKLMx64
|
||||
- UninstallString
|
||||
- '%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe -Command Remove-Item -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{{ registry_id }} -Force -Recurse'
|
||||
state: present
|
||||
|
||||
- name: uninstall registry package with unquoted env vars
|
||||
win_package:
|
||||
product_id: '{{ registry_id }}'
|
||||
state: absent
|
||||
register: registry_uninstall_env
|
||||
|
||||
- name: get result of ininstall registry package with unquoted env vars
|
||||
win_reg_stat:
|
||||
path: HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{{ registry_id }}
|
||||
register: registry_uninstall_env_actual
|
||||
|
||||
- name: assert uninstall registry package with unquoted env vars
|
||||
assert:
|
||||
that:
|
||||
- registry_uninstall_env is changed
|
||||
- registry_uninstall_env.rc == 0
|
||||
- not registry_uninstall_env.reboot_required
|
||||
- not registry_uninstall_env_actual.exists
|
||||
|
||||
- name: install registry package quoted env vars
|
||||
win_package:
|
||||
path: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
|
||||
arguments:
|
||||
- -File
|
||||
- '{{ test_path }}\registry_package.ps1'
|
||||
- HKLMx64
|
||||
- UninstallString
|
||||
- '"%TestVar%\powershell symlink.exe" -Command Remove-Item -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{{ registry_id }} -Force -Recurse'
|
||||
state: present
|
||||
|
||||
- name: uninstall registry package quoted env vars
|
||||
win_package:
|
||||
product_id: '{{ registry_id }}'
|
||||
state: absent
|
||||
register: registry_uninstall_env_quoted
|
||||
environment:
|
||||
TestVar: '{{ test_path }}'
|
||||
|
||||
- name: get result of uninstall registry package quoted env vars
|
||||
win_reg_stat:
|
||||
path: HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{{ registry_id }}
|
||||
register: registry_uninstall_env_quoted_actual
|
||||
|
||||
- name: assert uninstall registry package quoted env vars
|
||||
assert:
|
||||
that:
|
||||
- registry_uninstall_env_quoted is changed
|
||||
- registry_uninstall_env_quoted.rc == 0
|
||||
- not registry_uninstall_env_quoted.reboot_required
|
||||
- not registry_uninstall_env_quoted_actual.exists
|
||||
|
||||
- name: install registry package for overriding path test
|
||||
win_package:
|
||||
path: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
|
||||
arguments:
|
||||
- -File
|
||||
- '{{ test_path }}\registry_package.ps1'
|
||||
- HKLMx64
|
||||
- UninstallString
|
||||
- Fail path
|
||||
state: present
|
||||
|
||||
- name: uninstall registry package with overridden path and explicit error code
|
||||
win_package:
|
||||
path: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
|
||||
product_id: '{{ registry_id }}'
|
||||
arguments: '-Command Remove-Item -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{{ registry_id }}; exit 1'
|
||||
expected_return_code: 1
|
||||
state: absent
|
||||
register: registry_uninstall_explicit_path
|
||||
|
||||
- name: get result of uninstall registry package with overridden path and explicit error code
|
||||
win_reg_stat:
|
||||
path: HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{{ registry_id }}
|
||||
register: registry_uninstall_explicit_path_actual
|
||||
|
||||
- name: assert unisntall registry package with overridden path and explicit error code
|
||||
assert:
|
||||
that:
|
||||
- registry_uninstall_explicit_path is changed
|
||||
- registry_uninstall_explicit_path.rc == 1
|
||||
- not registry_uninstall_explicit_path.reboot_required
|
||||
- not registry_uninstall_explicit_path_actual.exists
|
||||
|
||||
- name: create registry package for uninstal with explicit arguments test
|
||||
win_package:
|
||||
path: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
|
||||
arguments:
|
||||
- -File
|
||||
- '{{ test_path }}\registry_package.ps1'
|
||||
- HKLMx64
|
||||
- QuietUninstallString
|
||||
- C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
|
||||
state: present
|
||||
|
||||
- name: uninstall registry package with explicit arguments and chdir
|
||||
win_package:
|
||||
product_id: '{{ registry_id }}'
|
||||
arguments: -Command Remove-Item -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{{ registry_id }} -Force -Recurse; [System.IO.File]::WriteAllText('{{ test_path }}\reg_out.txt', $pwd.Path, [System.Text.Encoding]::Unicode); exit 3010
|
||||
state: absent
|
||||
chdir: C:\Users
|
||||
register: registry_uninstall_arguments
|
||||
|
||||
- name: get package result of uninstall registry package with explicit arguments and chdir
|
||||
win_reg_stat:
|
||||
path: HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{{ registry_id }}
|
||||
register: registry_uninstall_arguments_reg_actual
|
||||
|
||||
- name: get package output of uninstall registry package with explicit arguments and chdir
|
||||
slurp:
|
||||
path: '{{ test_path }}\reg_out.txt'
|
||||
register: registry_uninstall_arguments_chdir_actual
|
||||
|
||||
- name: assert uninstall registry package with explicit arguments and chdir
|
||||
assert:
|
||||
that:
|
||||
- registry_uninstall_arguments is changed
|
||||
- registry_uninstall_arguments.rc == 3010
|
||||
- registry_uninstall_arguments.reboot_required
|
||||
- not registry_uninstall_arguments_reg_actual.exists
|
||||
# backslash escaping makes it hard to compare the value, just compare the raw base64 string expected which is 'C:\Users' as UTF-16-LE
|
||||
- registry_uninstall_arguments_chdir_actual.content == '//5DADoAXABVAHMAZQByAHMA'
|
||||
|
||||
- name: install package for creates_* tests
|
||||
win_package:
|
||||
path: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
|
||||
arguments:
|
||||
- -File
|
||||
- '{{ test_path }}\registry_package.ps1'
|
||||
- HKLMx64
|
||||
- UninstallString
|
||||
- powershell.exe -Command Remove-Item -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{{ registry_id }} -Force -Recurse
|
||||
state: present
|
||||
|
||||
- name: get actual PowerShell file version for tests
|
||||
win_shell: |
|
||||
$path = '{{ test_path }}\powershell symlink.exe'
|
||||
$version = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($path)
|
||||
(New-Object -TypeName System.Version -ArgumentList @(
|
||||
$version.FileMajorPart, $version.FileMinorPart, $version.FileBuildPart, $version.FilePrivatePart
|
||||
)).ToString()
|
||||
changed_when: False
|
||||
register: powershell_version
|
||||
|
||||
- name: test creates_path overrides product_id
|
||||
win_package:
|
||||
path: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
|
||||
arguments: echo hi
|
||||
product_id: '{{ registry_id }}'
|
||||
creates_path: C:\missing
|
||||
state: present
|
||||
register: creates_path
|
||||
|
||||
- name: test creates_version overrides product_id
|
||||
win_package:
|
||||
path: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
|
||||
arguments: echo hi
|
||||
product_id: '{{ registry_id }}'
|
||||
creates_path: '{{ test_path }}\powershell symlink.exe'
|
||||
creates_version: 1.0.0
|
||||
state: present
|
||||
register: creates_version
|
||||
|
||||
- name: assert test creates_path and creates_version override product_id is changed
|
||||
assert:
|
||||
that:
|
||||
- creates_path is changed
|
||||
- creates_version is changed
|
||||
|
||||
- name: test creates_path to existing but no product_id
|
||||
win_package:
|
||||
path: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
|
||||
arguments: echo hi
|
||||
product_id: Fake
|
||||
creates_path: C:\Windows
|
||||
state: present
|
||||
register: creates_path_present
|
||||
|
||||
- name: test creates_version to existing but no product_id
|
||||
win_package:
|
||||
path: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
|
||||
arguments: echo hi
|
||||
product_id: Fake
|
||||
creates_path: '{{ test_path }}\powershell symlink.exe'
|
||||
creates_version: '{{ powershell_version.stdout | trim }}'
|
||||
state: present
|
||||
register: creates_version_present
|
||||
|
||||
- name: assert test creates_path to existing but no product_Id
|
||||
assert:
|
||||
that:
|
||||
- not creates_path_present is changed
|
||||
- not creates_version_present is changed
|
||||
|
||||
- name: test creates_service overrides product_id
|
||||
win_package:
|
||||
path: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
|
||||
arguments: echo hi
|
||||
product_id: '{{ registry_id }}'
|
||||
creates_service: missing service
|
||||
state: present
|
||||
register: creates_service
|
||||
|
||||
- name: assert test creates_service overrides product_id
|
||||
assert:
|
||||
that:
|
||||
- creates_service is changed
|
||||
|
||||
- name: test creates_service to existing but no product_id
|
||||
win_package:
|
||||
path: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
|
||||
arguments: echo hi
|
||||
product_id: Fake
|
||||
creates_service: winrm
|
||||
state: present
|
||||
register: creates_service_present
|
||||
|
||||
- name: assert test creates_service to existing but no product_Id
|
||||
assert:
|
||||
that:
|
||||
- not creates_service_present is changed
|
@ -0,0 +1,26 @@
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
$productId = '{{ registry_id }}'
|
||||
|
||||
$regPath = switch ($args[0]) {
|
||||
HKLMx64 { 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall' }
|
||||
HKLMx86 { 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall' }
|
||||
HKCUx64 { 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall' }
|
||||
HKCUx86 { 'HKCU:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall' }
|
||||
default { throw "Invalid registry path specified $($args[0])" }
|
||||
}
|
||||
$regProperty = $args[1]
|
||||
$regUninstallString = $args[2]
|
||||
#$regUninstallString = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($args[2]))
|
||||
|
||||
$null = New-Item -Path $regPath -Name $productId -Force
|
||||
|
||||
$propParams = @{
|
||||
Path = "$regPath\$productId"
|
||||
Force = $true
|
||||
PropertyType = 'String'
|
||||
}
|
||||
New-ItemProperty -Name $regProperty -Value $regUninstallString @propParams
|
||||
if ($regProperty -eq 'QuietUninstallString') {
|
||||
New-ItemProperty -Name 'UninstallString' -Value 'Fail if used' @propParams
|
||||
}
|
Loading…
Reference in New Issue