我发现this question非常相似,但是我正在执行实例中的测试代码,根据the documentation,这意味着不应应用防护。但是,每次都跳过。任何帮助,将不胜感激。
厨师代码:
# Install the DNS plugin for the CLI
execute 'Install-DNS-plugin' do
command 'akamai install dns --force'
not_if 'akamai list | grep dns'
end
总是导致跳过:
==> default: * execute[Install-DNS-plugin] action run
==> default: (skipped due to not_if)
尽管在实例上,保护代码返回1:
[root@vagrant ~] $ akamai list | grep dns
[root@vagrant ~] $ echo $?
1
akamai cli是否依赖于特定的环境变量或shell初始化?除非您指定它们,否则可能都不会出现在not_if
中。参见https://docs.chef.io/resource_common/#arguments
我建议在执行资源本身中运行akamai list | grep dns
以调试结果。