【问题标题】:Chef execute resource not_if guard returns 1; still skipsChef 执行资源 not_if 守卫返回 1;仍然跳过
【发布时间】:2020-03-27 18:45:39
【问题描述】:

我找到了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-infra


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2018-05-22
      • 1970-01-01
      • 2016-02-21
      • 1970-01-01
      • 1970-01-01
      • 2010-12-04
      • 1970-01-01
      • 1970-01-01
      • 2015-10-02
      相关资源
      最近更新 更多