好吧,我已经花了几天时间追逐这个。 在Windows 7 x64上的puppet代理3.7.1 x64是否存在问题,其中“除非”的exec永远不会运行该命令? 我试过做批处理的例子:
除非=>“C:/ProgramData/chocolatey/choco.exe源列表| findstr -i'巧克力[Disabled]'”,
Powershell和现在编译的AutoIT可执行文件:
exec { 'disablepublicchocolatey': command => "C:/ProgramData/chocolatey/choco.exe source disable -n=chocolatey", unless => 'c:/ProgramData/puppetfiles/checkifexists.exe repo "chocolatey [disabled]"', require => [Exec['chocolatelyinstall'],File['checkifexists.exe']], }
我的脚本返回1,如果它发现巧克力源列表(文本匹配是不区分大小写的)输出文本'巧克力[禁用] …所以…这不应该运行如果
c:\TEMP\AutoitScripts\chocolatey>choco source list Chocolatey v0.9.9.6 chocolatey [Disabled] - https://chocolatey.org/api/v2/
但它似乎总是运行…有没有一个错误? 我只是很困惑?
要使用|,必须使用在cmd.exe / C中使用的shell: https : //docs.puppetlabs.com/windows/troubleshooting.html#shell-builtins
看下面的例子:
exec { 'configure_timezone': command => "tzutil.exe /s \"${timezone}\"", unless => "cmd.exe /C tzutil.exe /g | findstr /C:\"${timezone}\"", }