Run_list while running chef-client --local-mode


I am trying to execute recipes in order to configure server. despite of directing chef to the json file, it always says "missing cookbook". I have all my recipes in the cookbook\recipes folder.

I am running below command from the cookbook folder so chef-local mode assume the current directory as cookbook folder:

chef-client --local-mode -j c:\chef\cookbooks

I have a json content as below:

"run_list": [ "recipe[mainrecipe]" ]


[2019-03-06T21:26:39+00:00] WARN: No config file found or specified on command line, using command line options.
[2019-03-06T21:26:39+00:00] WARN: No cookbooks directory found at or above current directory. Assuming C:/chef/c

Starting Chef Client, version 14.10.9←[0m

resolving cookbooks for run list: ["mainrecipe"]←[0m
←[31mError Resolving Cookbooks for Run List:←[0m

←[0mMissing Cookbooks:←[0m
No such cookbook: mainrecipe←[0m

←[0mExpanded Run List:←[0m

  • configureservice←[0m

←[0mSystem Info:←[0m
←[0mruby=ruby 2.5.3p105 (2018-10-18 revision 65156) [x64-mingw32]

Running handlers:←[0m
[2019-03-06T21:26:58+00:00] ERROR: Running exception handlers
Running handlers complete
←[0m[2019-03-06T21:26:58+00:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 1
7 seconds←[0m
[2019-03-06T21:26:58+00:00] FATAL: Stacktrace dumped to C:/Users/Administrator/.chef/local-mode-cache/cache/chef-stackt
[2019-03-06T21:26:58+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2019-03-06T21:26:58+00:00] FATAL: Net::HTTPServerException: 412 "Precondition Failed"

I think the problem you are having is normally you have a cookbook under your cookbooks folder. Is your cookbook called mainrecipe? so you have like ..\cookbooks\mainrecipe\recipes\default.rb?

1 Like

mainrecipe is a recipe within c:\chef\cookbooks\recipes folder which I want to execute. I have also tried below, but same error

"run_list": [ "recipe[cookbooks::mainrecipe]" ]

structure is: c:\chef\cookbooks\recipes\default.rb

This(c:\chef\cookbooks\recipes\default.rb) way of creating cookbooks is not right and you will get into troubles when you had to upload them to chef server.
Firstly being in c:\chef\cookbooks\ with chef-dk installed you had to issue command chef generate cookbook appconf (appconf will be your cookbook name.)
Secondly to test recipes you can directly pass recipe to the command. With the above example its chef-client --local-mode c:\chef\cookbooks\appconf\recipes\default.rb or being in c:\chef\ you can run chef-client -z appconf to test cookbooks.

what I am doing is calling multiple recipes (run_list) from a cookbook by referring to json passing chef-client --local-mode -j and following is the content of json:

"run_list": [ "recipe[cookbooks::recipe1],recipe[cookbooks::recipe2]" ]

json is not really used for passing runlist in local mode. Json can have defined attributes, tags for cookbooks and bootstrap.

To test cookbooks in local-mode you can refer this