【发布时间】:2017-12-07 09:04:31
【问题描述】:
我正在创建厨师食谱并尝试使用 registry_key 资源创建/更新注册表项。我如何使用正则表达式来验证注册表项的存在并仅在必要时更新
registry_key'HKLM\\Software\\Microsoft\\WindowsNT\\CurrentVersion\\Winlogon' do
values [{
name: 'SCRemoveOption',
type: :string,
data: '1', }]
# recursive true
action :create
not_if { registry_data_exists?('HKLM\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon',{ name: 'SCRemoveOption', type: :string, data: '1' } ,:x86_64) }
end
如果注册表键存在数据1或2或3,则无需更新,否则registry_key-data应更新为1。
not_if { registry_data_exists?('HKLM\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon',{ name: 'SCRemoveOption', type: :string, data: '([1-3])'} ,:x86_64) }
【问题讨论】:
标签: windows chef-infra registrykey