community.windows.win_hotfix 模块 – 安装和卸载 Windows 热修复程序
注意
此模块是 community.windows 集合 (版本 2.3.0) 的一部分。
如果您使用的是 ansible
软件包,则可能已安装此集合。它不包含在 ansible-core
中。要检查它是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用:ansible-galaxy collection install community.windows
。
要在 playbook 中使用它,请指定:community.windows.win_hotfix
。
概要
安装或卸载 Windows 热修复程序。
参数
参数 |
注释 |
---|---|
如 DISM 中所示的热修复程序名称,请参阅示例了解详细信息。 当 如果 展开 msu 文件后,您可以通过运行“Get-WindowsPackage -Online -PackagePath path-to-cab-in-msu”来获取标识符。 |
|
热修复程序相关的 KB 名称,请参阅示例了解详细信息。 当 如果 由于 DISM 使用标识符作为键,并且并非在所有情况下都引用 KB,因此建议使用 |
|
下载的热修复程序 .msu 文件的路径。 如果 |
|
安装或卸载热修复程序。 当 当 选项
|
备注
注意
这必须在安装了 DISM powershell 模块且 Powershell 版本 >= 4 的主机上运行。
Windows 8 和 Server 2012 及更高版本默认安装此模块。
您可以通过安装 Windows ADK https://developer.microsoft.com/en-us/windows/hardware/windows-assessment-deployment-kit 在 Windows 7 和 Server 2008 R2 上手动安装此模块,请参阅示例了解如何使用 chocolatey 执行此操作。
您可以从 https://www.catalog.update.microsoft.com/Home.aspx 下载热修复程序。
另请参见
另请参见
- ansible.windows.win_package
安装/卸载可安装软件包。
- ansible.windows.win_updates
下载并安装 Windows 更新。
示例
- name: Install Windows ADK with DISM for Server 2008 R2
chocolatey.chocolatey.win_chocolatey:
name: windows-adk
version: 8.100.26866.0
state: present
install_args: /features OptionId.DeploymentTools
- name: Install hotfix without validating the KB and Identifier
community.windows.win_hotfix:
source: C:\temp\windows8.1-kb3172729-x64_e8003822a7ef4705cbb65623b72fd3cec73fe222.msu
state: present
register: hotfix_install
- ansible.windows.win_reboot:
when: hotfix_install.reboot_required
- name: Install hotfix validating KB
community.windows.win_hotfix:
hotfix_kb: KB3172729
source: C:\temp\windows8.1-kb3172729-x64_e8003822a7ef4705cbb65623b72fd3cec73fe222.msu
state: present
register: hotfix_install
- ansible.windows.win_reboot:
when: hotfix_install.reboot_required
- name: Install hotfix validating Identifier
community.windows.win_hotfix:
hotfix_identifier: Package_for_KB3172729~31bf3856ad364e35~amd64~~6.3.1.0
source: C:\temp\windows8.1-kb3172729-x64_e8003822a7ef4705cbb65623b72fd3cec73fe222.msu
state: present
register: hotfix_install
- ansible.windows.win_reboot:
when: hotfix_install.reboot_required
- name: Uninstall hotfix with Identifier
community.windows.win_hotfix:
hotfix_identifier: Package_for_KB3172729~31bf3856ad364e35~amd64~~6.3.1.0
state: absent
register: hotfix_uninstall
- ansible.windows.win_reboot:
when: hotfix_uninstall.reboot_required
- name: Uninstall hotfix with KB (not recommended)
community.windows.win_hotfix:
hotfix_kb: KB3172729
state: absent
register: hotfix_uninstall
- ansible.windows.win_reboot:
when: hotfix_uninstall.reboot_required
返回值
常见的返回值已在 此处 记录,以下是此模块特有的字段
键 |
描述 |
---|---|
热修复程序的 DISM 标识符。 返回:成功 示例: |
|
msu 中每个热修复程序的 DISM 标识符。 返回:成功 示例: |
|
热修复程序相关的 KB。 返回:成功 示例: |
|
msu 中每个热修复程序的 KB, 返回:成功 示例: |
|
安装或卸载是否需要重新启动才能完成。 返回:成功 示例: |