chef-infra - Chef 执行资源 not_if 守卫返回 1;仍然跳过
问题描述
我发现这个问题非常相似,但是我正在实例上执行测试代码,根据文档,这意味着不应该应用防护。但是,它每次都在跳过。任何帮助,将不胜感激。
厨师代码:
# 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
在执行资源本身中运行以调试结果。
推荐阅读
- jquery - 在滚动引导程序上调整大小时,粘性导航栏出现故障/抖动
- powershell - 确定 PowerShell 模块的 .NET 和 CLR 要求
- socket.io - Mocha 和 socket.io 超时
- mongodb - mongoDB聚合嵌套文档一次只显示三个
- python - 处理图像和创建数据的函数
- c# - 将调试编译为 32 位并发布为 64 位 c#
- java - 在 Runnable 类中终止 Java Fx 应用程序 While 循环
- ruby-on-rails - 配置更改后资产丢失/未在 Elastic Beanstalk 上编译
- python - Django:models.py 中的 def save()
- node.js - 在 Google Cloud 中更改 sql 实例