2017-06-26 21:01:38 +00:00
|
|
|
#!/usr/bin/python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2019-03-05 20:56:55 +00:00
|
|
|
# Copyright: (c) 2018, Wojciech Sciesinski <wojciech[at]sciesinski[dot]net>
|
2018-02-25 02:09:54 +00:00
|
|
|
# Copyright: (c) 2017, Daniele Lazzari <lazzari@mailup.com>
|
|
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
2017-06-26 21:01:38 +00:00
|
|
|
|
|
|
|
# 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-06-26 21:01:38 +00:00
|
|
|
'status': ['preview'],
|
|
|
|
'supported_by': 'community'}
|
|
|
|
|
|
|
|
DOCUMENTATION = r'''
|
|
|
|
---
|
|
|
|
module: win_psmodule
|
|
|
|
version_added: "2.4"
|
2019-03-05 20:56:55 +00:00
|
|
|
short_description: Adds or removes a Windows PowerShell module
|
2017-06-26 21:01:38 +00:00
|
|
|
description:
|
2019-03-05 20:56:55 +00:00
|
|
|
- This module helps to install Windows PowerShell modules and register custom modules repository on Windows-based systems.
|
2017-06-26 21:01:38 +00:00
|
|
|
options:
|
|
|
|
name:
|
|
|
|
description:
|
2019-03-05 20:56:55 +00:00
|
|
|
- Name of the Windows PowerShell module that has to be installed.
|
2019-01-03 16:50:44 +00:00
|
|
|
type: str
|
2018-02-25 02:09:54 +00:00
|
|
|
required: yes
|
2019-03-05 20:56:55 +00:00
|
|
|
state:
|
|
|
|
description:
|
|
|
|
- If C(present) a new module is installed.
|
|
|
|
- If C(absent) a module is removed.
|
|
|
|
- If C(latest) a module is updated to the newest version. This option was added in version 2.8.
|
|
|
|
type: str
|
|
|
|
choices: [ absent, latest, present ]
|
|
|
|
default: present
|
|
|
|
required_version:
|
|
|
|
description:
|
|
|
|
- The exact version of the PowerShell module that has to be installed.
|
|
|
|
type: str
|
|
|
|
version_added: "2.8"
|
|
|
|
minimum_version:
|
|
|
|
description:
|
|
|
|
- The minimum version of the PowerShell module that has to be installed.
|
|
|
|
type: str
|
|
|
|
version_added: "2.8"
|
|
|
|
maximum_version:
|
|
|
|
description:
|
|
|
|
- The maximum version of the PowerShell module that has to be installed.
|
|
|
|
type: str
|
|
|
|
version_added: "2.8"
|
2017-06-26 21:01:38 +00:00
|
|
|
allow_clobber:
|
|
|
|
description:
|
2019-03-05 20:56:55 +00:00
|
|
|
- If C(yes) allows install modules that contains commands those have the same names as commands that already exists.
|
|
|
|
type: bool
|
|
|
|
default: no
|
|
|
|
skip_publisher_check:
|
|
|
|
description:
|
|
|
|
- If C(yes), allows you to install a different version of a module that already exists on your computer in the case when a different one
|
|
|
|
is not digitally signed by a trusted publisher and the newest existing module is digitally signed by a trusted publisher.
|
2018-02-25 02:09:54 +00:00
|
|
|
type: bool
|
2019-01-03 16:50:44 +00:00
|
|
|
default: no
|
2019-03-05 20:56:55 +00:00
|
|
|
version_added: "2.8"
|
|
|
|
allow_prerelease:
|
|
|
|
description:
|
|
|
|
- If C(yes) installs modules marked as prereleases.
|
|
|
|
- It doesn't work with the parameters C(minimum_version) and/or C(maximum_version).
|
|
|
|
- It doesn't work with the C(state) set to absent.
|
|
|
|
type: bool
|
|
|
|
default: no
|
|
|
|
version_added: "2.8"
|
2017-06-26 21:01:38 +00:00
|
|
|
repository:
|
|
|
|
description:
|
2019-03-10 19:43:21 +00:00
|
|
|
- Name of the custom repository to use.
|
2019-01-03 16:50:44 +00:00
|
|
|
type: str
|
2017-06-26 21:01:38 +00:00
|
|
|
url:
|
|
|
|
description:
|
2018-05-22 21:36:57 +00:00
|
|
|
- URL of the custom repository to register.
|
2019-03-10 19:43:21 +00:00
|
|
|
- This option is deprecated and will be removed in Ansible 2.12. Use the
|
|
|
|
M(win_psrepository) module instead.
|
2019-01-03 16:50:44 +00:00
|
|
|
type: str
|
2017-06-26 21:01:38 +00:00
|
|
|
notes:
|
2019-03-05 20:56:55 +00:00
|
|
|
- PowerShell modules needed
|
|
|
|
- PowerShellGet >= 1.6.0
|
|
|
|
- PackageManagement >= 1.1.7
|
|
|
|
- PowerShell package provider needed
|
|
|
|
- NuGet >= 2.8.5.201
|
|
|
|
- On PowerShell 5.x required modules and a package provider will be updated under the first run of the win_psmodule module.
|
|
|
|
- On PowerShell 3.x and 4.x you have to install them before using the win_psmodule.
|
2018-12-15 02:23:59 +00:00
|
|
|
seealso:
|
|
|
|
- module: win_psrepository
|
2018-02-25 02:09:54 +00:00
|
|
|
author:
|
2019-03-05 20:56:55 +00:00
|
|
|
- Wojciech Sciesinski (@it-praktyk)
|
2018-11-20 19:31:35 +00:00
|
|
|
- Daniele Lazzari (@dlazz)
|
2017-06-26 21:01:38 +00:00
|
|
|
'''
|
|
|
|
|
2019-01-03 16:50:44 +00:00
|
|
|
EXAMPLES = r'''
|
2017-06-26 21:01:38 +00:00
|
|
|
---
|
2019-03-05 20:56:55 +00:00
|
|
|
- name: Add a PowerShell module
|
2017-06-26 21:01:38 +00:00
|
|
|
win_psmodule:
|
2019-03-05 20:56:55 +00:00
|
|
|
name: PowerShellModule
|
2017-06-26 21:01:38 +00:00
|
|
|
state: present
|
|
|
|
|
2019-03-05 20:56:55 +00:00
|
|
|
- name: Add an exact version of PowerShell module
|
2017-06-26 21:01:38 +00:00
|
|
|
win_psmodule:
|
2019-03-05 20:56:55 +00:00
|
|
|
name: PowerShellModule
|
|
|
|
required_version: "4.0.2"
|
2017-06-26 21:01:38 +00:00
|
|
|
state: present
|
|
|
|
|
2019-03-05 20:56:55 +00:00
|
|
|
- name: Install or update an existing PowerShell module to the newest version
|
2018-05-22 21:36:57 +00:00
|
|
|
win_psmodule:
|
2019-03-05 20:56:55 +00:00
|
|
|
name: PowerShellModule
|
|
|
|
state: latest
|
2018-05-22 21:36:57 +00:00
|
|
|
|
2019-03-05 20:56:55 +00:00
|
|
|
- name: Install newer version of built-in Windows module
|
2017-06-26 21:01:38 +00:00
|
|
|
win_psmodule:
|
2019-03-05 20:56:55 +00:00
|
|
|
name: Pester
|
|
|
|
skip_publisher_check: yes
|
|
|
|
state: present
|
2017-06-26 21:01:38 +00:00
|
|
|
|
2019-03-05 20:56:55 +00:00
|
|
|
- name: Add a PowerShell module and register a repository
|
2017-06-26 21:01:38 +00:00
|
|
|
win_psmodule:
|
|
|
|
name: MyCustomModule
|
|
|
|
repository: MyRepository
|
2019-03-05 20:56:55 +00:00
|
|
|
state: present
|
|
|
|
|
|
|
|
- name: Add a PowerShell module from a specific repository
|
|
|
|
win_psmodule:
|
|
|
|
name: PowerShellModule
|
|
|
|
repository: MyRepository
|
|
|
|
state: present
|
|
|
|
|
|
|
|
- name: Remove a PowerShell module
|
|
|
|
win_psmodule:
|
|
|
|
name: PowerShellModule
|
2017-06-26 21:01:38 +00:00
|
|
|
state: absent
|
|
|
|
'''
|
|
|
|
|
2019-01-03 16:50:44 +00:00
|
|
|
RETURN = r'''
|
2017-06-26 21:01:38 +00:00
|
|
|
---
|
|
|
|
output:
|
2019-01-03 16:50:44 +00:00
|
|
|
description: A message describing the task result.
|
2017-06-26 21:01:38 +00:00
|
|
|
returned: always
|
|
|
|
sample: "Module PowerShellCookbook installed"
|
2018-12-18 21:25:30 +00:00
|
|
|
type: str
|
2017-06-26 21:01:38 +00:00
|
|
|
nuget_changed:
|
2019-01-03 16:50:44 +00:00
|
|
|
description: True when Nuget package provider is installed.
|
2017-06-26 21:01:38 +00:00
|
|
|
returned: always
|
2018-12-18 21:25:30 +00:00
|
|
|
type: bool
|
2019-01-03 16:50:44 +00:00
|
|
|
sample: true
|
2017-06-26 21:01:38 +00:00
|
|
|
repository_changed:
|
2019-01-03 16:50:44 +00:00
|
|
|
description: True when a custom repository is installed or removed.
|
2017-06-26 21:01:38 +00:00
|
|
|
returned: always
|
2018-12-18 21:25:30 +00:00
|
|
|
type: bool
|
2019-01-03 16:50:44 +00:00
|
|
|
sample: true
|
2017-06-26 21:01:38 +00:00
|
|
|
'''
|