Chef执行资源not_if防护返回1;仍然跳过

问题描述 投票:1回答:1

我发现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
chef
1个回答
0
投票

akamai cli是否依赖于特定的环境变量或shell初始化?除非您指定它们,否则可能都不会出现在not_if中。参见https://docs.chef.io/resource_common/#arguments

我建议在执行资源本身中运行akamai list | grep dns以调试结果。

© www.soinside.com 2019 - 2024. All rights reserved.