community.windows.win_psmodule 模块 – 添加或删除 Windows PowerShell 模块
注意
此模块是 community.windows 集合 (版本 2.3.0) 的一部分。
如果您使用的是 ansible
软件包,则可能已安装此集合。它不包含在 ansible-core
中。要检查它是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用:ansible-galaxy collection install community.windows
。
要在剧本中使用它,请指定:community.windows.win_psmodule
。
概要
此模块有助于在基于 Windows 的系统上安装 Windows PowerShell 模块并在 Windows 系统上注册自定义模块存储库。
参数
参数 |
注释 |
---|---|
接受模块的许可证。 对于需要接受许可证的模块是必需的,因为无法交互式地回答提示。 对应于 在检查模式下无法检测到需要接受许可证的模块或依赖项的安装,但除非 *accept_license=true*,否则会在运行时导致失败。 选项
|
|
如果 选项
|
|
如果 它不适用于参数 它不适用于设置为 absent 的 选项
|
|
覆盖有关模块安装冲突的警告消息 如果存在具有相同名称和版本的模块,则 force 会覆盖该版本 对应于 如果模块作为依赖项,它还会强制重新安装依赖项。如果模块清单中未指定版本,则将其更新到最新版本。 选项
|
|
必须安装的 PowerShell 模块的最大版本。 |
|
必须安装的 PowerShell 模块的最小版本。 |
|
必须安装的 Windows PowerShell 模块的名称。 |
|
用于对私有存储库进行身份验证的密码。 |
|
要使用的自定义存储库的名称。 |
|
必须安装的 PowerShell 模块的精确版本。 |
|
如果 选项
|
|
如果 如果 如果 选项
|
|
用于对私有存储库进行身份验证的用户名。 |
备注
注意
需要的 PowerShell 模块 - PowerShellGet >= 1.6.0 - PackageManagement >= 1.1.7
需要的 PowerShell 包提供程序 - NuGet >= 2.8.5.201
在 PowerShell 5.x 上,在 win_psmodule 模块的第一次运行中,将更新所需的模块和包提供程序。
在 PowerShell 3.x 和 4.x 上,您必须在使用 win_psmodule 之前安装它们。
另请参阅
另请参阅
- community.windows.win_psrepository
添加、删除或更新 Windows PowerShell 存储库。
示例
---
- name: Add a PowerShell module
community.windows.win_psmodule:
name: PowerShellModule
state: present
- name: Add an exact version of PowerShell module
community.windows.win_psmodule:
name: PowerShellModule
required_version: "4.0.2"
state: present
- name: Install or update an existing PowerShell module to the newest version
community.windows.win_psmodule:
name: PowerShellModule
state: latest
- name: Install newer version of built-in Windows module
community.windows.win_psmodule:
name: Pester
skip_publisher_check: true
state: present
- name: Add a PowerShell module and register a repository
community.windows.win_psmodule:
name: MyCustomModule
repository: MyRepository
state: present
- name: Add a PowerShell module from a specific repository
community.windows.win_psmodule:
name: PowerShellModule
repository: MyRepository
state: present
- name: Add a PowerShell module from a specific repository with credentials
win_psmodule:
name: PowerShellModule
repository: MyRepository
username: repo_username
password: repo_password
state: present
- name: Remove a PowerShell module
community.windows.win_psmodule:
name: PowerShellModule
state: absent
返回值
常见返回值已在此处记录,以下是此模块特有的字段
键 |
描述 |
---|---|
安装 NuGet 包提供程序时为 True。 返回:始终 示例: |
|
描述任务结果的消息。 返回:始终 示例: |
|
安装或移除自定义资源库时为真。 返回:始终 示例: |