Ansible上win_regedit路径中的转义斜杠

Ansible上win_regedit路径中的转义斜杠,ansible,Ansible,我在Ansible 2.3.0.0的剧本中有以下内容: - name: Disable SSL2, SSL3, RC4. Activate TLS win_regedit: path: 'HKLM:\System\CurrentControlSet\Control\SecurityProviders\SCHANNEL\{{ item.path }}' name: "{{ item.name }}" data: "{{ item.data }}" type: d

我在Ansible 2.3.0.0的剧本中有以下内容:

- name: Disable SSL2, SSL3, RC4. Activate TLS
  win_regedit:
    path: 'HKLM:\System\CurrentControlSet\Control\SecurityProviders\SCHANNEL\{{ item.path }}'
    name: "{{ item.name }}"
    data: "{{ item.data }}"
    type: dword
  with_items:
    # more items working correctly 
    - { path: "Ciphers\\RC4 128/128", name: 'Enabled', data: 0 }
    - { path: "Ciphers\\RC4 40/128", name: 'Enabled', data: 0 }
    - { path: "Ciphers\\RC4 56/128", name: 'Enabled', data: 0 }
我尝试了所有我能想到的引号和斜杠的组合来逃避
/
,但仍然抛出语法错误,或者将最后一个
128
视为注册表路径的另一个文件夹,而不是键本身的一部分


Ansible有什么办法可以将该
128/128
从字面上理解,而不是作为路径的一部分吗?

对不起,您使用
win\u regedit
和正斜杠运气不佳

win\u regedit
使用PowerShell,与朋友一起在引擎盖下。
无论是否转义,PowerShell都将正斜杠字符视为级别分隔符。
您可以在PowerShell(,)中搜索一些克服此问题的方法

但是使用
win\u regedit
Ansible模块,您不能使用这些技巧


因此,您可以使用上述文章中的技巧编写自己的PowerShell脚本并使用
脚本
模块,或者准备注册表模板并使用
win\u regmerge
模块(它在引擎盖下使用
reg.exe
)导入所需的设置。

多亏@KonstantinSuvorov,我已经完成了一个解决方案,尽管很难看,但效果很好。执行此步骤以在
win\u regedit
之前直接使用PowerShell创建注册表项:

- win_shell: $path=new-item -path 'HKLM:\System\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Ciphers';$key = (get-item HKLM:\).OpenSubKey("System\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Ciphers", $true);$key.CreateSubKey('RC4 128/128');$key.CreateSubKey('RC4 40/128');$key.CreateSubKey('RC4 56/128');$key.Close()

一小时前,我测试了PowerShell,它在一个包含正斜杠的路径中创建了属性,没有任何技巧:
newitemproperty-path$registryPath-Name$Name-Value$Value-PropertyType DWORD-Force | Out Null
where
$registryPath=“HKLM:\System\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Ciphers\\RC4 128/128”
我很困惑。
Get ItemProperty
是否需要它们,而不是
New ItemProperty
?请尝试
New Item-Path“HKLM:\\SOFTWARE\\Ansible\u Test\\RC4 128/128”-Type directory-Force
–这就是Ansible创建不存在的路径的方式。谢谢@KonstantinSuvorov!知道了这一点,我已经使用Ansible为创建密钥和填充密钥准备了一个变通方法:)