win_package – Installs/uninstalls an installable package¶
Synopsis¶
- Installs or uninstalls a package in either an MSI or EXE format.
- These packages can be sources from the local file system, network file share or a url.
- Please read the notes section around some caveats with this module.
Parameters¶
Notes¶
Note
- When
state=absent
and the product is an exe, the path may be different from what was used to install the package originally. If path is not set then the path used will be what is set underUninstallString
in the registry for that product_id. - Not all product ids are in a GUID form, some programs incorrectly use a different structure but this module should support any format.
- By default all msi installs and uninstalls will be run with the options
/log, /qn, /norestart
. - It is recommended you download the package first from the URL using the win_get_url module as it opens up more flexibility with what must be set when calling
win_package
. - Packages will be temporarily downloaded or copied locally when path is a network location and credential delegation is not set, or path is a URL and the file is not an MSI.
- All the installation checks under
product_id
andcreates_*
add together, if one fails then the program is considered to be absent.
See Also¶
See also
- win_chocolatey – Manage packages using chocolatey
- The official documentation on the win_chocolatey module.
- win_hotfix – Install and uninstalls Windows hotfixes
- The official documentation on the win_hotfix module.
- win_updates – Download and install Windows updates
- The official documentation on the win_updates module.
Examples¶
- name: Install the Visual C thingy
win_package:
path: http://download.microsoft.com/download/1/6/B/16B06F60-3B20-4FF2-B699-5E9B7962F9AE/VSU_4/vcredist_x64.exe
product_id: '{CF2BEA3C-26EA-32F8-AA9B-331F7E34BA97}'
arguments: /install /passive /norestart
- name: Install Visual C thingy with list of arguments instead of a string, and permanent log
win_package:
path: http://download.microsoft.com/download/1/6/B/16B06F60-3B20-4FF2-B699-5E9B7962F9AE/VSU_4/vcredist_x64.exe
product_id: '{CF2BEA3C-26EA-32F8-AA9B-331F7E34BA97}'
arguments:
- /install
- /passive
- /norestart
log_path: D:\logs\vcredist_x64-exe-{{lookup('pipe', 'date +%Y%m%dT%H%M%S')}}.log
- name: Install Remote Desktop Connection Manager from msi
win_package:
path: https://download.microsoft.com/download/A/F/0/AF0071F3-B198-4A35-AA90-C68D103BDCCF/rdcman.msi
product_id: '{0240359E-6A4C-4884-9E94-B397A02D893C}'
state: present
- name: Uninstall Remote Desktop Connection Manager
win_package:
product_id: '{0240359E-6A4C-4884-9E94-B397A02D893C}'
state: absent
- name: Install Remote Desktop Connection Manager locally omitting the product_id
win_package:
path: C:\temp\rdcman.msi
state: present
- name: Uninstall Remote Desktop Connection Manager from local MSI omitting the product_id
win_package:
path: C:\temp\rdcman.msi
state: absent
# 7-Zip exe doesn't use a guid for the Product ID
- name: Install 7zip from a network share specifying the credentials
win_package:
path: \\domain\programs\7z.exe
product_id: 7-Zip
arguments: /S
state: present
user_name: DOMAIN\User
user_password: Password
- name: Install 7zip and use a file version for the installation check
win_package:
path: C:\temp\7z.exe
creates_path: C:\Program Files\7-Zip\7z.exe
creates_version: 16.04
state: present
- name: Uninstall 7zip from the exe
win_package:
path: C:\Program Files\7-Zip\Uninstall.exe
product_id: 7-Zip
arguments: /S
state: absent
- name: Uninstall 7zip without specifying the path
win_package:
product_id: 7-Zip
arguments: /S
state: absent
- name: Install application and override expected return codes
win_package:
path: https://download.microsoft.com/download/1/6/7/167F0D79-9317-48AE-AEDB-17120579F8E2/NDP451-KB2858728-x86-x64-AllOS-ENU.exe
product_id: '{7DEBE4EB-6B40-3766-BB35-5CBBC385DA37}'
arguments: '/q /norestart'
state: present
expected_return_code: [0, 666, 3010]
Return Values¶
Common return values are documented here, the following are the fields unique to this module:
Status¶
- This module is not guaranteed to have a backwards compatible interface. [preview]
- This module is maintained by the Ansible Core Team. [core]
Red Hat Support¶
More information about Red Hat’s support of this module is available from this Red Hat Knowledge Base article.
Authors¶
- Trond Hindenes (@trondhindenes)
- Jordan Borean (@jborean93)
Hint
If you notice any issues in this documentation, you can edit this document to improve it.