win_package: rewrite, check mode, tests, more check options (#27470)

* rewrite of win_package to enable win_msi deprecation

* fix some minor doc issues

* Removed exe tests

* dag's changes seem to be missing, re-add them

* fixed yaml for return values
This commit is contained in:
Jordan Borean 2017-08-28 19:03:10 -04:00 committed by GitHub
commit adabefd016
11 changed files with 1980 additions and 1450 deletions

View file

@ -1,6 +1,18 @@
---
# spaces are tricky, let's have one by default
test_win_package_path: C:\ansible\win package
test_win_package_good_url: https://s3.amazonaws.com/ansible-ci-files/test/integration/roles/test_win_package/good.msi
test_win_package_reboot_url: https://s3.amazonaws.com/ansible-ci-files/test/integration/roles/test_win_package/reboot.msi
test_win_package_bad_url: https://s3.amazonaws.com/ansible-ci-files/test/integration/roles/test_win_package/bad.msi
test_win_package_exe_url: https://s3.amazonaws.com/ansible-ci-files/test/integration/roles/test_win_package/7z.exe # TODO: change to it's own executable
msi_url: https://ansible-ci-files.s3.amazonaws.com/test/integration/roles/test_win_msi/7z922-x64.msi
msi_download_path: "C:\\Program Files\\7z922-x64.msi"
msi_install_path: "C:\\Program Files\\7-Zip"
msi_product_code: "{23170F69-40C1-2702-0922-000001000000}"
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
# define the below to run the network tests, all 3 msi's should exist in this path
# test_win_package_network_path: \\ANSIBLE\network
# 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

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="223D9A13-653B-4231-A365-EDDC30B4F228" UpgradeCode="575580C0-AFA1-4C17-8A9C-3CB0CEDC6A06" Name="Bovine University" Manufacturer="Ansible" Version="1.0.0" Language="1033" Codepage="1252">
<Package InstallerVersion="200" Compressed="yes" Comments="When I grow up I want to go to Bovine University" />
<Media Id="1" Cabinet="product.cab" EmbedCab="yes" />
</Product>
</Wix>

View file

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="223D9A13-653B-4231-A365-EDDC30B4F226" UpgradeCode="575580C0-AFA1-4C17-8A9C-3CB0CEDC6A05" Name="Bovine University" Manufacturer="Ansible" Version="1.0.0" Language="1033" Codepage="1252">
<Package InstallerVersion="200" Compressed="yes" Comments="When I grow up I want to go to Bovine University" />
<Media Id="1" Cabinet="product.cab" EmbedCab="yes" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLDIR" Name="Bovine University">
<Component Id="MooFiles" Guid="D7BC586D-A23C-4002-BC20-76579F25C67D">
<File Id="MooFile" Source="moo.exe" />
</Component>
<Component Id="CowFiles" Guid="D1801B2D-8E54-4F19-8B14-A42D8A122A24">
<File Id="CowFile" Source="cow.exe" />
</Component>
</Directory>
</Directory>
</Directory>
<Feature Id="Moo" Level="1">
<ComponentRef Id="MooFiles" />
</Feature>
<Feature Id="Cow" Level="1">
<ComponentRef Id="CowFiles" />
</Feature>
</Product>
</Wix>

View file

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="223D9A13-653B-4231-A365-EDDC30B4F227" UpgradeCode="575580C0-AFA1-4C17-8A9C-3CB0CEDC6A06" Name="Bovine University" Manufacturer="Ansible" Version="1.0.0" Language="1033" Codepage="1252">
<Package InstallerVersion="200" Compressed="yes" Comments="When I grow up I want to go to Bovine University" />
<Media Id="1" Cabinet="product.cab" EmbedCab="yes" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLDIR" Name="Bovine University">
<Component Id="MooFiles" Guid="D7BC586D-A23C-4002-BC20-76579F25C67D">
<File Id="MooFile" Source="moo.exe" />
</Component>
<Component Id="CowFiles" Guid="D1801B2D-8E54-4F19-8B14-A42D8A122A24">
<File Id="CowFile" Source="cow.exe" />
</Component>
</Directory>
</Directory>
</Directory>
<Feature Id="Moo" Level="1">
<ComponentRef Id="MooFiles" />
</Feature>
<Feature Id="Cow" Level="1">
<ComponentRef Id="CowFiles" />
</Feature>
<InstallExecuteSequence>
<ScheduleReboot After="InstallFinalize" />
</InstallExecuteSequence>
</Product>
</Wix>

View file

@ -0,0 +1,303 @@
---
- 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|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|changed
- install_local_exe.reboot_required == False
- install_local_exe.exit_code == 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:
- not install_local_exe_idempotent|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|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|changed
- uninstall_path_local_exe.reboot_required == False
- uninstall_path_local_exe.exit_code == 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:
- not uninstall_path_local_exe_idempotent|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|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|changed
- install_url_exe.reboot_required == False
- install_url_exe.exit_code == 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:
- not install_url_exe_again|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|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|changed
- uninstall_id_local_exe.reboot_required == False
- uninstall_id_local_exe.exit_code == 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:
- not uninstall_id_local_exe_idempotent|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:
- not install_exe_create_version_match|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|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:
- not install_exe_create_service_match|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|changed
- name: uninstall exe post tests
win_package:
arguments: /S
product_id: '{{test_win_package_exe_id}}'
state: absent

View file

@ -0,0 +1,82 @@
# these tests are invalid arguments and failure states for win_package
---
- name: fail to install broken msi
win_package:
path: '{{test_win_package_path}}\bad.msi'
state: present
register: fail_bad_rc
failed_when: "'unexpected rc from install' not in fail_bad_rc.msg and fail_bad_rc.exit_code != 1603"
- name: fail when not using an int for a return code
win_package:
path: '{{test_win_package_path}}\good.msi'
state: present
expected_return_code: 0,abc
register: fail_invalid_return_code
failed_when: fail_invalid_return_code.msg != 'failed to parse expected return code abc as an integer'
- name: fail when path is not set and state!= absent
win_package:
state: present
register: fail_no_path
failed_when: fail_no_path.msg != 'path can only be null when state=absent and product_id is not null'
- name: fail when path is not set and state=absent but product_id is null
win_package:
state: absent
register: fail_no_path_state_absent_no_id
failed_when: fail_no_path_state_absent_no_id.msg != 'path can only be null when state=absent and product_id is not null'
- name: fail when product_id is not set and path is not a local MSI
win_package:
path: '{{test_win_package_good_url}}'
state: present
register: fail_install_url_no_id
failed_when: fail_install_url_no_id.msg != 'product_id is required when the path is not an MSI or the path is an MSI but not local'
- name: fail invalid local path
win_package:
path: '{{test_win_package_path}}\no file.msi'
state: present
register: fail_invalid_local_path
failed_when: fail_invalid_local_path.msg != 'the file at the local path ' + test_win_package_path + '\\no file.msi cannot be reached'
- name: fail invalid URL
win_package:
path: http://fakeurl/file.msi
product_id: 'id'
state: present
register: fail_invalid_url_path
failed_when: "fail_invalid_url_path.msg != 'the file at the URL http://fakeurl/file.msi cannot be reached: The remote name could not be resolved: \\'fakeurl\\''"
- name: fail invalid UNC path
win_package:
path: \\fakenetwork\unc file.msi
product_id: 'id'
state: present
register: fail_invalid_unc_path
failed_when: fail_invalid_unc_path.msg != 'the file at the UNC path \\\\fakenetwork\\unc file.msi cannot be reached, ensure the user_name account has access to this path or use an auth transport with credential delegation'
- name: fail when product_id is not set and path is not a local MSI
win_package:
path: '{{test_win_package_good_url}}'
state: present
register: fail_no_id_not_local_msi
failed_when: fail_no_id_not_local_msi.msg != 'product_id is required when the path is not an MSI or the path is an MSI but not local'
- name: fail to check version without creates_path
win_package:
path: '{{test_win_package_path}}\7z.exe'
state: present
creates_version: 1
register: fail_creates_version_without_path
failed_when: fail_creates_version_without_path.msg != 'creates_path must be set when creates_version is set'
- name: fail to check version without when path is not a file
win_package:
path: '{{test_win_package_path}}\7z.exe'
state: present
creates_path: C:\Windows
creates_version: 1
register: fail_creates_version_not_a_file
failed_when: fail_creates_version_not_a_file.msg != 'creates_path must be a file not a directory when creates_version is set'

View file

@ -1,81 +1,52 @@
# test code for the win_package module
# (c) 2014, Chris Church <chris@ninemoreminutes.com>
---
- name: ensure testing folder exists
win_file:
path: '{{test_win_package_path}}'
state: directory
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
- name: use win_get_url module to download msi
- name: download msi files from S3 bucket
win_get_url:
url: "{{msi_url}}"
dest: "{{msi_download_path}}"
register: win_get_url_result
url: '{{item.url}}'
dest: '{{test_win_package_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' }
- name: make sure msi is uninstalled
- name: make sure all test msi's are uninstalled before test
win_package:
path: "{{msi_download_path}}"
product_id: "{{msi_product_code}}"
product_id: '{{item.id}}'
arguments: '{{item.args|default(omit)}}'
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: install msi
win_package:
path: "{{msi_download_path}}"
product_id: "{{msi_product_code}}"
state: present
register: win_package_install_result
- block:
- name: run tests for expected failures
include_tasks: failure_tests.yml
- name: check win_package install result
assert:
that:
- "not win_package_install_result|failed"
- "win_package_install_result|changed"
- name: run tests for local and URL msi files
include_tasks: msi_tests.yml
- name: install msi again (check for no change)
win_package:
path: "{{msi_download_path}}"
product_id: "{{msi_product_code}}"
state: present
register: win_package_install_again_result
# 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
- name: check win_package install again result
assert:
that:
- "not win_package_install_again_result|failed"
- "not win_package_install_again_result|changed"
# 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: uninstall msi
win_package:
path: "{{msi_download_path}}"
product_id: "{{msi_product_code}}"
state: absent
register: win_package_uninstall_result
- name: check win_package uninstall result
assert:
that:
- "not win_package_uninstall_result|failed"
- "win_package_uninstall_result|changed"
- name: uninstall msi again (check for no change)
win_package:
path: "{{msi_download_path}}"
product_id: "{{msi_product_code}}"
state: absent
register: win_package_uninstall_again_result
- name: check win_package uninstall result
assert:
that:
- "not win_package_uninstall_result|failed"
- "not win_package_uninstall_again_result|changed"
always:
- name: make sure all test msi's are uninstalled after test
win_package:
product_id: '{{item.id}}'
arguments: '{{item.args|default(omit)}}'
state: absent
with_items:
- { id: '{{test_win_package_good_id}}' }
- { id: '{{test_win_package_reboot_id}}' }
# - { id: '{{test_win_package_exe_id}}', args: '/S' }

View file

@ -0,0 +1,335 @@
---
# this test just makes sure the task doesn't fail when we set out expected rc
- name: install broken msi override expected rc
win_package:
path: '{{test_win_package_path}}\bad.msi'
state: present
expected_return_code: 0,1603
- name: install local msi (check mode)
win_package:
path: '{{test_win_package_path}}\good.msi'
state: present
register: install_local_msi_check
check_mode: yes
- name: get result of install local msi (check mode)
win_reg_stat:
path: HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{{test_win_package_good_id}}
register: install_local_msi_actual_check
- name: assert install local msi (check mode)
assert:
that:
- install_local_msi_check|changed
- install_local_msi_check.reboot_required == False
- install_local_msi_actual_check.exists == False
- name: install local msi
win_package:
path: '{{test_win_package_path}}\good.msi'
state: present
expected_return_code: "" # historical, an empty string means 0, 3010
register: install_local_msi
- name: get result of install local msi
win_reg_stat:
path: HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{{test_win_package_good_id}}
register: install_local_msi_actual
- name: assert install local msi
assert:
that:
- install_local_msi|changed
- install_local_msi.reboot_required == False
- install_local_msi.exit_code == 0
- install_local_msi_actual.exists == True
- name: install local msi (idempotent)
win_package:
path: '{{test_win_package_path}}\good.msi'
state: present
register: install_local_msi_idempotent
- name: assert install local msi (idempotent)
assert:
that:
- not install_local_msi_idempotent|changed
- name: uninstall local msi with path (check mode)
win_package:
path: '{{test_win_package_path}}\good.msi'
state: absent
register: uninstall_path_local_msi_check
check_mode: yes
- name: get result of uninstall local msi with path (check mode)
win_reg_stat:
path: HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{{test_win_package_good_id}}
register: uninstall_path_local_msi_actual_check
- name: assert uninstall local msi with path (check mode)
assert:
that:
- uninstall_path_local_msi_check|changed
- uninstall_path_local_msi_check.reboot_required == False
- uninstall_path_local_msi_actual_check.exists == True
- name: uninstall local msi with path
win_package:
path: '{{test_win_package_path}}\good.msi'
state: absent
register: uninstall_path_local_msi
- name: get result of uninstall local msi with path
win_reg_stat:
path: HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{{test_win_package_good_id}}
register: uninstall_path_local_msi_actual
- name: assert uninstall local msi with path
assert:
that:
- uninstall_path_local_msi|changed
- uninstall_path_local_msi.reboot_required == False
- uninstall_path_local_msi.exit_code == 0
- uninstall_path_local_msi_actual.exists == False
- name: uninstall local msi with path (idempotent)
win_package:
path: '{{test_win_package_path}}\good.msi'
state: absent
register: uninstall_path_local_msi_idempotent
- name: assert uninstall local msi with path (idempotent)
assert:
that:
- not uninstall_path_local_msi_idempotent|changed
- name: install url msi (check mode)
win_package:
path: '{{test_win_package_good_url}}'
product_id: '{{test_win_package_good_id}}'
state: present
register: install_url_msi_check
check_mode: yes
- name: get result of install url msi (check mode)
win_reg_stat:
path: HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{{test_win_package_good_id}}
register: install_url_msi_actual_check
- name: assert install url msi (check mode)
assert:
that:
- install_url_msi_check|changed
- install_url_msi_check.reboot_required == False
- install_url_msi_actual_check.exists == False
- name: install url msi
win_package:
path: '{{test_win_package_good_url}}'
product_id: '{{test_win_package_good_id}}'
state: present
register: install_url_msi
- name: get result of install url msi
win_reg_stat:
path: HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{{test_win_package_good_id}}
register: install_url_msi_actual
- name: assert install url msi
assert:
that:
- install_url_msi|changed
- install_url_msi.reboot_required == False
- install_url_msi.exit_code == 0
- install_url_msi_actual.exists == True
- name: install url msi (idempotent)
win_package:
path: '{{test_win_package_good_url}}'
product_id: '{{test_win_package_good_id}}'
state: present
register: install_url_msi_again
- name: assert install url msi (idempotent)
assert:
that:
- not install_url_msi_again|changed
- name: uninstall local msi with product_id (check mode)
win_package:
product_id: '{{test_win_package_good_id}}'
state: absent
register: uninstall_id_local_msi_check
check_mode: yes
- name: get result of uninstall local msi with product_id (check mode)
win_reg_stat:
path: HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{{test_win_package_good_id}}
register: uninstall_id_local_msi_actual_check
- name: assert uninstall local msi with product_id (check mode)
assert:
that:
- uninstall_id_local_msi_check|changed
- uninstall_id_local_msi_check.reboot_required == False
- uninstall_id_local_msi_actual_check.exists == True
- name: uninstall local msi with product_id
win_package:
product_id: '{{test_win_package_good_id}}'
state: absent
register: uninstall_id_local_msi
- name: get result of uninstall local msi with product_id
win_reg_stat:
path: HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{{test_win_package_good_id}}
register: uninstall_id_local_msi_actual
- name: assert uninstall local msi with product_id
assert:
that:
- uninstall_id_local_msi|changed
- uninstall_id_local_msi.reboot_required == False
- uninstall_id_local_msi.exit_code == 0
- uninstall_id_local_msi_actual.exists == False
- name: uninstall local msi with product_id (idempotent)
win_package:
product_id: '{{test_win_package_good_id}}'
state: absent
register: uninstall_id_local_msi_idempotent
- name: assert uninstall local msi with product_id (idempotent)
assert:
that:
- not uninstall_id_local_msi_idempotent|changed
- name: install local reboot msi (check mode)
win_package:
path: '{{test_win_package_path}}\reboot.msi'
state: present
register: install_local_reboot_msi_check
check_mode: yes
- name: get result of install local reboot msi (check mode)
win_reg_stat:
path: HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{{test_win_package_reboot_id}}
register: install_local_reboot_msi_actual_check
- name: assert install local reboot msi (check mode)
assert:
that:
- install_local_reboot_msi_check|changed
- install_local_reboot_msi_check.reboot_required == False
- install_local_reboot_msi_actual_check.exists == False
- name: install local reboot msi
win_package:
path: '{{test_win_package_path}}\reboot.msi'
state: present
register: install_local_reboot_msi
- name: get result of install local reboot msi
win_reg_stat:
path: HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{{test_win_package_reboot_id}}
register: install_local_reboot_msi_actual
- name: assert install local reboot msi
assert:
that:
- install_local_reboot_msi|changed
- install_local_reboot_msi.reboot_required == True
- install_local_reboot_msi.exit_code == 3010
- install_local_reboot_msi_actual.exists == True
- name: install local reboot msi (idempotent)
win_package:
path: '{{test_win_package_path}}\reboot.msi'
state: present
register: install_local_reboot_msi_idempotent
- name: assert install local reboot msi (idempotent)
assert:
that:
- not install_local_reboot_msi_idempotent|changed
- name: uninstall reboot msi after test
win_package:
path: '{{test_win_package_path}}\reboot.msi'
state: absent
- name: ensure the install folder is cleaned in case uninstall didn't work
win_file:
path: '%ProgramFiles(x86)%\Bovine University'
state: absent
- name: install local msi with arguments (check mode)
win_package:
path: '{{test_win_package_path}}\good.msi'
state: present
arguments: ADDLOCAL=Cow
register: install_msi_argument_check
check_mode: yes
- name: get result of moo file after install local msi with arguments (check mode)
win_stat:
path: '%ProgramFiles(x86)%\Bovine University\moo.exe'
register: install_msi_argument_moo_check
- name: get result of cow file after install local msi with arguments (check mode)
win_stat:
path: '%ProgramFiles(x86)%\Bovine University\cow.exe'
register: install_msi_argument_cow_check
- name: assert install local msi with arguments (check mode)
assert:
that:
- install_msi_argument_check|changed
- install_msi_argument_check.reboot_required == False
- install_msi_argument_moo_check.stat.exists == False
- install_msi_argument_cow_check.stat.exists == False
- name: install local msi with arguments
win_package:
path: '{{test_win_package_path}}\good.msi'
state: present
arguments: ADDLOCAL=Cow
register: install_msi_argument
- name: get result of moo file after install local msi with arguments
win_stat:
path: '%ProgramFiles(x86)%\Bovine University\moo.exe'
register: install_msi_argument_moo
- name: get result of cow file after install local msi with arguments
win_stat:
path: '%ProgramFiles(x86)%\Bovine University\cow.exe'
register: install_msi_argument_cow
- name: assert install local msi with arguments
assert:
that:
- install_msi_argument|changed
- install_msi_argument.reboot_required == False
- install_msi_argument.exit_code == 0
- install_msi_argument_moo.stat.exists == False
- install_msi_argument_cow.stat.exists == True
- name: install local msi with arguments (idempotent)
win_package:
path: '{{test_win_package_path}}\good.msi'
state: present
arguments: ADDLOCAL=Cow
register: install_msi_argument_again
- name: assert install local msi with arguments (idempotent)
assert:
that:
- not install_msi_argument_again|changed
- name: uninstall good msi after test
win_package:
path: '{{test_win_package_path}}\good.msi'
state: absent

View file

@ -0,0 +1,427 @@
---
- 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|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|changed
- install_network_msi.reboot_required == False
- install_network_msi.exit_code == 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:
- not install_network_msi_idempotent|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|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|changed
- uninstall_path_network_msi.reboot_required == False
- uninstall_path_network_msi.exit_code == 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:
- not uninstall_path_network_msi_idempotent|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|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|changed
- install_network_reboot_msi.reboot_required == True
- install_network_reboot_msi.exit_code == 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:
- not install_network_reboot_msi_idempotent|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|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|changed
- uninstall_id_network_msi.reboot_required == True
- uninstall_id_network_msi.exit_code == 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:
- not uninstall_id_network_msi_idempotent|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|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|changed
- install_network_msi_argument.reboot_required == False
- install_network_msi_argument.exit_code == 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:
- not install_network_msi_argument_again|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|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|changed
- install_network_exe.reboot_required == False
- install_network_exe.exit_code == 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:
- not install_network_exe_idempotent|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|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|changed
- uninstall_network_exe.reboot_required == False
- uninstall_network_exe.exit_code == 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:
- not uninstall_network_exe_idempotent|changed