【发布时间】:2018-05-22 22:04:17
【问题描述】:
如果启用了某个安全策略,我的配方中有一个 PS 脚本会导致 chef-run 失败(基本上是this 问题)。
所以我添加了一个 not_if 保护
powershell_script 'scheduled-tasks' do
guard_interpreter :powershell_script
cwd 'C:\Temp'
code <<-EOH
schtasks.exe /create ...
schtasks.exe /create ...
EOH
not_if "(get-itemproperty 'HKLM:\\System\\CurrentControlSet\\Control\\Lsa').DisableDomainCreds -eq '1'"
end
我正在使用 Test-Kitchin、VirtualBox 和 Windows VM。运行 powershell 命令 'getitemproperty...' 返回 True 表示它已启用,因此我不希望脚本运行并希望 Chef 说 'skipped due to not_if'。
但是,在终端输出中显示“动作运行”。
主厨运行没有失败,所以脚本无法运行,但为什么没有说“跳过”?
问候
【问题讨论】:
标签: powershell chef-infra