Debug Recipes Chef client Runs — Chef Docs





Debug Recipes, Chef-client Runs — Chef Docs



The tar.gz is archived into the file_cache_path, and then extracted to cookbooks_path.



Use a directory


chef-solo will look in the solo.rb file to determine the directory in which cookbooks are located.

Use a URL for cookbook and JSON data


where -r corresponds to recipe_url and -j corresponds to json_attribs, both of which are configuration options in solo.rb.


“Hello World”

This example shows how to run chef-shell in standalone mode. (For chef-solo or chef-client modes, you would need to run chef-shell using the -s or -z command line options, and then take into consideration the necessary configuration settings.)


When the chef-client is installed using RubyGems or a package manager, chef-shell should already be installed. When the chef-client is run from a git clone, it will be located in chef/bin/chef shell. To start chef-shell, just run it without any options. You’ll see the loading message, then the banner, and then the chef-shell prompt:


(Use the help command to print a list of supported commands.) Use the recipe_mode command to switch to recipe context:


Typing is evaluated in the same context as recipes. Create a file resource:

(The previous example was formatted for presentation.) At this point, chef-shell has created the resource and put it in the run-list, but not yet created the file. To initiate the chef-client run, use the run_chef command:


chef-shell can also switch to the same context as attribute files. Set an attribute with the following syntax:


Switch back to recipe_mode context and use the attributes:

Now, run the chef-client again:


Because the first resource (file[/tmp/ohai2u_shef]) is still in the run-list, it gets executed again. And because that file already exists, the chef-client doesn’t attempt to re-create it. Finally, the files were created using the ls method:


Get Specific Nodes

To get a list of nodes using a recipe named postfix use search(:node,"recipe:postfix"). To get a list of nodes using a sub-recipe named delivery, use chef-shell. For example:


Note

Single (‘ ‘) vs. double (” “) is important. This is because a backslash () needs to be included in the string, instead of having Ruby interpret it as an escape.



Appliances
Art Supplies
Bakeware
Bath
Comforters
Cookware
Corelle
Cutlery
Dining
Furniture
Garden
Grills
Hardware
Home Stuff
Juicers
Kitchen
Knives
Meat Grinders
Microwaves
Mixers
Mixing Bowls
Pans
Plates
Pots
Pressure Cookers
Quilts
Racks
Recipes Videos
Rice Cookers
Roasters
Sauce Pans
Sheets
Skillets
Slow Cookers
Small Appliances
Steak Knives
Steamers
Tea Kettles
Throws
Toaster Ovens
Toasters
Utensils
Related