0

Is there a way to get the cookbook_path (defined in either solo.rb or client.rb) from within a recipe?

I've found this bit:

run_context.cookbook_collection

Which outputs the cache path of cookbooks, but not the original cookbook_path

StephenKing
  • 36,187
  • 11
  • 83
  • 112
Just Lucky Really
  • 1,341
  • 1
  • 15
  • 38
  • What is the `cookbook_path` in your point of view? Documentation says *The sub-directory for cookbooks on the chef-client* . Do you have an example what you expect and what you get? Or are you looking for this? http://stackoverflow.com/questions/14075847/how-to-get-a-full-path-of-the-running-cookbook-in-the-rightscale-chef-recipe – slowjack2k Aug 20 '16 at 12:17
  • So, in `solo.rb` I have defined it as `/path/to/my/cookbooks`. When using `run_context.cookbook_collection` or `::Chef::Config. cookbook_path` it outputs `/etc/chef/local-mode-cache/cache/cookboo‌​ks` – Just Lucky Really Aug 20 '16 at 12:32
  • Did you have a look into `/etc/chef/client.rb` on your remote host? `cookbook_path` has every where the same name, but I think it has different meanings depending on the location (solo.rb vs. knife.rb vs. client.rb). What is your final goal? What do you try to achive? – slowjack2k Aug 20 '16 at 12:43
  • Something weird ... That depends on knowing the original `cookbook_path` ... – Just Lucky Really Aug 20 '16 at 12:57

1 Answers1

0

You can access the Chef Client's / Solo's configuration settings through Chef::Config. In your case, use:

Chef::Config[:cookbook_path]
StephenKing
  • 36,187
  • 11
  • 83
  • 112