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 热修复程序。

参数

参数

注释

hotfix_identifier

字符串

如 DISM 中所示的热修复程序名称,请参阅示例了解详细信息。

state=absent 时,必须设置此参数或 hotfix_kb

如果 state=present,则将根据此值验证 source 中的热修复程序,如果不匹配,则会发生错误。

展开 msu 文件后,您可以通过运行“Get-WindowsPackage -Online -PackagePath path-to-cab-in-msu”来获取标识符。

hotfix_kb

字符串

热修复程序相关的 KB 名称,请参阅示例了解详细信息。

state=absent 时,必须设置此参数或 hotfix_identifier

如果 state=present,则将根据此值验证 source 中的热修复程序,如果不匹配,则会发生错误。

由于 DISM 使用标识符作为键,并且并非在所有情况下都引用 KB,因此建议使用 hotfix_identifier

source

路径

下载的热修复程序 .msu 文件的路径。

如果 state=present,则必须设置此参数,并且必须是 .msu 热修复程序文件。

state

字符串

安装或卸载热修复程序。

present 时,必须设置 source

absent 时,必须设置 hotfix_identifierhotfix_kb

选项

  • "absent"

  • "present" ← (默认)

备注

注意

另请参见

另请参见

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

返回值

常见的返回值已在 此处 记录,以下是此模块特有的字段

描述

identifier

字符串

热修复程序的 DISM 标识符。

返回:成功

示例:"Package_for_KB3172729~31bf3856ad364e35~amd64~~6.3.1.0"

identifiers

列表 / 元素=字符串

在 community.windows 1.10.0 中添加

msu 中每个热修复程序的 DISM 标识符。

返回:成功

示例:["Package_for_KB3172729~31bf3856ad364e35~amd64~~6.3.1.0"]

kb

字符串

热修复程序相关的 KB。

返回:成功

示例:"KB3172729"

kbs

列表 / 元素=字符串

在 community.windows 1.10.0 中添加

msu 中每个热修复程序的 KB,

返回:成功

示例:["KB3172729"]

reboot_required

字符串

安装或卸载是否需要重新启动才能完成。

返回:成功

示例:"True"

作者

  • Jordan Borean (@jborean93)