--- - 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