ansible.builtin.win_psmodule (v2.9.27) — module

Adds or removes a Windows PowerShell module

| "added in version" 2.4 of ansible.builtin"

Authors: Wojciech Sciesinski (@it-praktyk), Daniele Lazzari (@dlazz)

preview | supported by community

Install Ansible via pip

Install with pip install ansible==2.9.27

Description

This module helps to install Windows PowerShell modules and register custom modules repository on Windows-based systems.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
---
- name: Add a PowerShell module
  win_psmodule:
    name: PowerShellModule
    state: present
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Add an exact version of PowerShell module
  win_psmodule:
    name: PowerShellModule
    required_version: "4.0.2"
    state: present
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Install or update an existing PowerShell module to the newest version
  win_psmodule:
    name: PowerShellModule
    state: latest
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Install newer version of built-in Windows module
  win_psmodule:
    name: Pester
    skip_publisher_check: yes
    state: present
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Add a PowerShell module and register a repository
  win_psmodule:
    name: MyCustomModule
    repository: MyRepository
    state: present
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Add a PowerShell module from a specific repository
  win_psmodule:
    name: PowerShellModule
    repository: MyRepository
    state: present
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Remove a PowerShell module
  win_psmodule:
    name: PowerShellModule
    state: absent

Inputs

    
url:
    description:
    - URL of the custom repository to register.
    - This option is deprecated and will be removed in Ansible 2.12. Use the M(win_psrepository)
      module instead.
    type: str

name:
    description:
    - Name of the Windows PowerShell module that has to be installed.
    required: true
    type: str

state:
    choices:
    - absent
    - latest
    - present
    default: present
    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

repository:
    description:
    - Name of the custom repository to use.
    type: str

allow_clobber:
    default: false
    description:
    - If C(yes) allows install modules that contains commands those have the same names
      as commands that already exists.
    type: bool

maximum_version:
    description:
    - The maximum version of the PowerShell module that has to be installed.
    type: str
    version_added: '2.8'
    version_added_collection: ansible.builtin

minimum_version:
    description:
    - The minimum version of the PowerShell module that has to be installed.
    type: str
    version_added: '2.8'
    version_added_collection: ansible.builtin

allow_prerelease:
    default: false
    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
    version_added: '2.8'
    version_added_collection: ansible.builtin

required_version:
    description:
    - The exact version of the PowerShell module that has to be installed.
    type: str
    version_added: '2.8'
    version_added_collection: ansible.builtin

skip_publisher_check:
    default: false
    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.
    type: bool
    version_added: '2.8'
    version_added_collection: ansible.builtin

Outputs

nuget_changed:
  description: True when Nuget package provider is installed.
  returned: always
  sample: true
  type: bool
output:
  description: A message describing the task result.
  returned: always
  sample: Module PowerShellCookbook installed
  type: str
repository_changed:
  description: True when a custom repository is installed or removed.
  returned: always
  sample: true
  type: bool

See also