Juan John Mathews
Juan John Mathews

Reputation: 736

Could not find recipe from cookbook when running chef-client

I am trying to test a cookbook on standalone system by using chef-client but keep getting an error for the following command.

I am able to run default.rb by using

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

But when I run another recipe I get the error as below the following command.

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)

What am I doing wrong? Any help would be appreciated.

Upvotes: 2

Views: 4839

Answers (1)

StephenKing
StephenKing

Reputation: 37630

The recipe name does not include the file extension (.rb), thus you have to omit it when specifying the run list:

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

This assumes that there is a file recipes/reBalanceCluster.rb. To be save, I would also suggest to use lower case everywhere. That might not work at all. So better rename the file to rebalancecluster.rb and use:

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

Upvotes: 5

Related Questions