ansible - Windows 上的 Ansible:如何更改注册表所有权
问题描述
Ansible 版本:ansible 2.9.2 我试图在配置了 WINRM 的 Windows Server 2012 R2 上的 playbook 下运行。我可以在目录上运行 win_acl 和 win_owner 模块,但是,我在使用 Ansible 更改Registry () 所有权时遇到了问题。注意:我可以通过 RDP 手动将相同的内容更改到本文中提到的服务器 https://github.com/jenkinsci/windows-slaves-plugin/blob/master/docs/troubleshooting.adoc#windows-server- 2012-64位
---
- hosts: all
gather_facts: no
tasks:
- name: Grant Ownership to Administrator user on the registry
win_acl:
path: HKLM:\SOFTWARE\Classes\Wow6432Node\CLSID\72C24DD5-D70A-438B-8A42-98424B88AFB8
user: Administrators
rights: TakeOwnership
type: allow
state: present
inherit: ContainerInherit
propagation: 'None'
Error: {"changed": false, "msg": "an exception occurred when adding the specified rule - Requested registry access is not allowed."}
解决方案
我无法用纯 ansible 做类似的事情。所以我使用了一个名为 setacl.exe https://helgeklein.com/download/#setacl的外部工具
以下示例是在生产中使用的极端方法。但它会显示您拥有的选项
- name: Copy setacl.exe to system32
win_copy:
src: files/setacl.exe
dest: C:\windows\system32\setacl.exe
- name: Change the owner for a part of the registry
tags: setacl
raw: setacl.exe -on "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum" -ot reg -rec yes -actn setowner -ownr "n:Administrator"
- name: Add administrator to reg
tags: setacl
raw: setacl.exe -on "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum" -ot reg -rec yes -actn ace -ace "n:Adminiistrator;p:full"
推荐阅读
- mongodb - 使用 _ID 作为外键的 MongoDb 3.6 查找
- c++ - 尝试对字符串向量进行排序时,C++ 程序崩溃
- python - 删除 Python REGEX 中的括号
- ios - Alamofire form-data”参数类型发布请求
- gremlin - Gremlin:如何获取来自顶点的属性“id”?
- mongodb - MongoDB 聚合 - 在文档的计数条件下获取 N 个随机文档
- javascript - javascript fetch 自动将 http 更改为 https
- html - 会员只能访问添加到购物车按钮shopify?
- c# - 如何在 DateTimeOffset 中本地化月份
- linux - 为 Splunk 转发器、索引器和搜索头设置服务器级监控和警报