2015-07-14 10:03:04 +00:00
|
|
|
#!/usr/bin/python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
# (c) 2014, Trond Hindenes <trond@hindenes.com>, and others
|
|
|
|
#
|
|
|
|
# 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/>.
|
|
|
|
|
|
|
|
# this is a windows documentation stub. actual code lives in the .ps1
|
|
|
|
# file of the same name
|
|
|
|
|
2017-08-16 03:16:38 +00:00
|
|
|
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
2017-03-14 16:07:22 +00:00
|
|
|
'status': ['preview'],
|
|
|
|
'supported_by': 'core'}
|
|
|
|
|
2016-12-06 10:35:25 +00:00
|
|
|
|
2017-01-19 01:57:33 +00:00
|
|
|
DOCUMENTATION = r'''
|
2015-07-14 10:03:04 +00:00
|
|
|
---
|
|
|
|
module: win_package
|
|
|
|
version_added: "1.7"
|
2015-10-01 17:12:21 +00:00
|
|
|
author: Trond Hindenes
|
2016-05-31 01:33:16 +00:00
|
|
|
short_description: Installs/Uninstalls an installable package, either from local file system or url
|
2015-07-14 10:03:04 +00:00
|
|
|
description:
|
2016-05-24 11:24:04 +00:00
|
|
|
- Installs or uninstalls a package.
|
2017-03-23 01:50:28 +00:00
|
|
|
- >
|
2017-04-26 11:36:12 +00:00
|
|
|
Use a product_id to check if the package needs installing. You can find product ids for installed programs in the windows registry
|
2017-03-23 01:50:28 +00:00
|
|
|
either in C(HKLM:Software\Microsoft\Windows\CurrentVersion\Uninstall) or for 32 bit programs
|
|
|
|
C(HKLM:Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall)
|
2017-06-26 15:26:53 +00:00
|
|
|
- For non-Windows targets, use the M(package) module instead.
|
2015-07-14 10:03:04 +00:00
|
|
|
options:
|
|
|
|
path:
|
|
|
|
description:
|
|
|
|
- Location of the package to be installed (either on file system, network share or url)
|
|
|
|
required: true
|
|
|
|
name:
|
|
|
|
description:
|
2016-05-31 01:33:16 +00:00
|
|
|
- Name of the package, if name isn't specified the path will be used for log messages
|
2015-07-14 10:03:04 +00:00
|
|
|
required: false
|
|
|
|
default: null
|
|
|
|
product_id:
|
|
|
|
description:
|
2017-01-06 21:00:32 +00:00
|
|
|
- Product id of the installed package (used for checking if already installed)
|
2017-03-23 01:50:28 +00:00
|
|
|
- >
|
|
|
|
You can find product ids for installed programs in the windows registry either in C(HKLM:Software\Microsoft\Windows\CurrentVersion\Uninstall)
|
|
|
|
or for 32 bit programs C(HKLM:Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall)
|
2015-10-01 17:08:42 +00:00
|
|
|
required: true
|
|
|
|
aliases: [productid]
|
2015-07-14 10:03:04 +00:00
|
|
|
arguments:
|
|
|
|
description:
|
|
|
|
- Any arguments the installer needs
|
|
|
|
default: null
|
2016-05-24 11:24:04 +00:00
|
|
|
required: false
|
2015-07-14 10:03:04 +00:00
|
|
|
state:
|
|
|
|
description:
|
2015-09-05 15:55:34 +00:00
|
|
|
- Install or Uninstall
|
|
|
|
choices:
|
2015-07-14 10:03:04 +00:00
|
|
|
- present
|
|
|
|
- absent
|
|
|
|
default: present
|
2016-05-24 11:24:04 +00:00
|
|
|
required: false
|
2015-07-14 10:03:04 +00:00
|
|
|
aliases: [ensure]
|
|
|
|
user_name:
|
|
|
|
description:
|
2017-03-23 01:50:28 +00:00
|
|
|
- Username of an account with access to the package if it's located on a file share. Only needed if the winrm user doesn't have access to the package.
|
|
|
|
Also specify user_password for this to function properly.
|
2015-07-14 10:03:04 +00:00
|
|
|
default: null
|
2016-05-24 11:24:04 +00:00
|
|
|
required: false
|
2015-07-14 10:03:04 +00:00
|
|
|
user_password:
|
|
|
|
description:
|
2017-03-23 01:50:28 +00:00
|
|
|
- Password of an account with access to the package if it's located on a file share. Only needed if the winrm user doesn't have access to the package.
|
|
|
|
Also specify user_name for this to function properly.
|
2015-07-14 10:03:04 +00:00
|
|
|
default: null
|
2016-05-24 11:24:04 +00:00
|
|
|
required: false
|
2017-01-27 00:32:49 +00:00
|
|
|
expected_return_code:
|
|
|
|
description:
|
|
|
|
- One or more return codes from the package installation that indicates success.
|
|
|
|
- If not provided, defaults to 0
|
|
|
|
required: no
|
|
|
|
default: 0
|
2017-06-26 15:26:53 +00:00
|
|
|
notes:
|
|
|
|
- For non-Windows targets, use the M(package) module instead.
|
2015-07-14 10:03:04 +00:00
|
|
|
'''
|
|
|
|
|
2017-01-19 01:57:33 +00:00
|
|
|
EXAMPLES = r'''
|
2016-12-19 21:58:28 +00:00
|
|
|
- name: Install the Visual C thingy
|
2016-05-24 11:24:04 +00:00
|
|
|
win_package:
|
2016-12-19 21:58:28 +00:00
|
|
|
name: Microsoft Visual C thingy
|
|
|
|
path: http://download.microsoft.com/download/1/6/B/16B06F60-3B20-4FF2-B699-5E9B7962F9AE/VSU_4/vcredist_x64.exe
|
2017-01-06 21:00:32 +00:00
|
|
|
product_id: '{CF2BEA3C-26EA-32F8-AA9B-331F7E34BA97}'
|
|
|
|
arguments: /install /passive /norestart
|
2016-08-06 07:45:46 +00:00
|
|
|
|
2016-12-19 21:58:28 +00:00
|
|
|
- name: Install Remote Desktop Connection Manager from msi
|
2016-08-06 07:45:46 +00:00
|
|
|
win_package:
|
2016-12-19 21:58:28 +00:00
|
|
|
path: https://download.microsoft.com/download/A/F/0/AF0071F3-B198-4A35-AA90-C68D103BDCCF/rdcman.msi
|
|
|
|
product_id: '{0240359E-6A4C-4884-9E94-B397A02D893C}'
|
|
|
|
|
|
|
|
- name: Uninstall Remote Desktop Connection Manager installed from msi
|
2016-08-06 07:45:46 +00:00
|
|
|
win_package:
|
2016-12-19 21:58:28 +00:00
|
|
|
path: https://download.microsoft.com/download/A/F/0/AF0071F3-B198-4A35-AA90-C68D103BDCCF/rdcman.msi
|
|
|
|
product_id: '{0240359E-6A4C-4884-9E94-B397A02D893C}'
|
2016-08-06 07:45:46 +00:00
|
|
|
state: absent
|
2017-01-27 23:45:23 +00:00
|
|
|
|
2017-01-27 00:32:49 +00:00
|
|
|
# Specify the expected non-zero return code when successful
|
|
|
|
# In this case 3010 indicates 'reboot required'
|
|
|
|
- name: 'Microsoft .NET Framework 4.5.1'
|
2017-02-07 21:39:24 +00:00
|
|
|
win_package:
|
|
|
|
path: https://download.microsoft.com/download/1/6/7/167F0D79-9317-48AE-AEDB-17120579F8E2/NDP451-KB2858728-x86-x64-AllOS-ENU.exe
|
|
|
|
productid: '{7DEBE4EB-6B40-3766-BB35-5CBBC385DA37}'
|
|
|
|
arguments: '/q /norestart'
|
|
|
|
ensure: present
|
|
|
|
expected_return_code: 3010
|
2017-01-27 00:32:49 +00:00
|
|
|
|
|
|
|
# Specify multiple non-zero return codes when successful
|
|
|
|
# In this case we can say that both 0 (SUCCESSFUL) and 3010 (REBOOT REQUIRED) codes are acceptable
|
2017-02-07 21:39:24 +00:00
|
|
|
- name: 'Microsoft .NET Framework 4.5.1'
|
|
|
|
win_package:
|
|
|
|
path: https://download.microsoft.com/download/1/6/7/167F0D79-9317-48AE-AEDB-17120579F8E2/NDP451-KB2858728-x86-x64-AllOS-ENU.exe
|
|
|
|
productid: '{7DEBE4EB-6B40-3766-BB35-5CBBC385DA37}'
|
|
|
|
arguments: '/q /norestart'
|
|
|
|
ensure: present
|
|
|
|
expected_return_code: [0,3010]
|
2015-07-14 10:03:04 +00:00
|
|
|
'''
|