community.windows.win_regmerge 模块 – 将注册表文件的内容合并到 Windows 注册表中
注意
此模块是 community.windows 集合 (版本 2.3.0) 的一部分。
如果您使用的是 ansible
包,则可能已安装此集合。它不包含在 ansible-core
中。要检查它是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用:ansible-galaxy collection install community.windows
。
要在 playbook 中使用它,请指定:community.windows.win_regmerge
。
概要
包装 reg.exe 命令以导入注册表文件的内容。
适用于与使用 ansible.windows.win_template 创建的注册表文件一起使用。
Windows 注册表文件具有特定的格式,必须使用回车符和换行符行尾正确构造,否则将无法合并。
导出的注册表文件通常以字节顺序标记开头,如果要使用 ansible.windows.win_template 模板化该文件,则必须删除该标记。
注册表文件格式在 https://support.microsoft.com/en-us/kb/310516 中描述
另请参阅 ansible.windows.win_template,ansible.windows.win_regedit
参数
参数 |
注释 |
---|---|
比较注册表内容与文件内容时使用的父密钥。需要在注册表的 HKLM 或 HKCU 部分中。使用 PS-Drive 样式路径,例如 HKLM:\SOFTWARE,而不是 HKEY_LOCAL_MACHINE\SOFTWARE。如果未提供或未找到注册表项,则不会进行比较,模块将报告已更改。 |
|
当与 |
|
要合并的远程计算机上注册表文件的完整路径(包括文件名) |
备注
注意
如果您想使用 compare_to 功能,请组织您的注册表文件,使其包含单个根注册表项。
此模块不会强制注册表设置处于文件中描述的状态。如果注册表设置已在外部修改,则模块将合并文件的内容,但在后续运行中继续报告差异。
要强制更改注册表,请在使用
community.windows.win_regmerge
之前,使用 ansible.windows.win_regedit 并设置state=absent
。
另请参阅
另请参阅
- ansible.windows.win_reg_stat
获取有关 Windows 注册表项的信息。
- ansible.windows.win_regedit
添加、更改或删除注册表项和值。
示例
- name: Merge in a registry file without comparing to current registry
community.windows.win_regmerge:
path: C:\autodeploy\myCompany-settings.reg
- name: Compare and merge registry file
community.windows.win_regmerge:
path: C:\autodeploy\myCompany-settings.reg
compare_to: HKLM:\SOFTWARE\myCompany
- name: Merge in a registry file specified as content without comparing to current registry
community.windows.win_regmerge:
content: |
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\myCompany]
"ExampleKey"=dword:00000001
- name: Compare and merge registry file specified as content
community.windows.win_regmerge:
content: |
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\myCompany]
"ExampleKey"=dword:00000001
compare_to: HKLM:\SOFTWARE\myCompany
返回值
常见的返回值已在此处记录,以下是此模块特有的字段
键 |
描述 |
---|---|
是否已找到用于比较的父注册表项 返回:当在注册表中找不到比较键时 示例: |
|
是否已在注册表和文件之间进行了比较 返回:当提供比较键并尝试进行比较时 示例: |
|
注册表和文件之间差异的数量 返回:已更改 示例: |