在运行chef-client时无法从cookbook中找到食谱

时间:2016-10-18 10:17:45

标签: chef chef-recipe

我正在尝试使用chef-client在独立系统上测试一本食谱,但是继续收到以下命令的错误。

我可以使用

运行default.rb
sudo chef-client -z -o "recipe[kafkaSetup]"

但是当我运行另一个食谱时,我得到的错误如下面的命令。

sudo chef-client -z -o "recipe[kafkaSetup::reBalanceCluster.rb]"
[2016-10-18T06:09:33-04:00] WARN: No config file found or specified on command line, using command line options.
Starting Chef Client, version 12.12.15
[2016-10-18T06:09:37-04:00] WARN: Run List override has been provided.
[2016-10-18T06:09:37-04:00] WARN: Original Run List: []
[2016-10-18T06:09:37-04:00] WARN: Overridden Run List: [recipe[kafkaSetup::reBalanceCluster.rb]]
resolving cookbooks for run list: ["kafkaSetup::reBalanceCluster.rb"]
Synchronizing Cookbooks:
  - kafkaSetup (0.1.0)
Installing Cookbook Gems:
Compiling Cookbooks...

================================================================================
Recipe Compile Error
================================================================================

Chef::Exceptions::RecipeNotFound
--------------------------------
could not find recipe reBalanceCluster.rb for cookbook kafkaSetup

Platform:
---------
x86_64-linux


Running handlers:
[2016-10-18T06:09:37-04:00] ERROR: Running exception handlers
Running handlers complete
[2016-10-18T06:09:37-04:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 04 seconds
[2016-10-18T06:09:37-04:00] FATAL: Stacktrace dumped to /root/.chef/local-mode-cache/cache/chef-stacktrace.out
[2016-10-18T06:09:37-04:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2016-10-18T06:09:37-04:00] ERROR: could not find recipe reBalanceCluster.rb for cookbook kafkaSetup
[2016-10-18T06:09:39-04:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited
unsuccessfully (exit code 1)

我做错了什么?任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:4)

配方名称不包含文件扩展名(.rb),因此在指定运行列表时必须省略它:

sudo chef-client -z -o "recipe[kafkaSetup::reBalanceCluster]"

这假设有一个文件recipes/reBalanceCluster.rb。为了节省,我还建议到处使用小写字母。这根本不起作用。因此,最好将文件重命名为rebalancecluster.rb并使用:

sudo chef-client -z -o "recipe[kafkaSetup::rebalancecluster]"