1

RE: https://docs.chef.io/knife_deps.html

With the knife deps --remote option, I can query our chef server. knife cookbook list -a will return all the cookbook versions. How can I use knife deps to query the dependencies of a particular version of a cookbook? I tried all sorts of delimiters to append the version number to the cookbook name and I have tried them as separate arguments. Tried to dig into the ruby code and found that is difficult to do - the purpose and organization of all those gems is very unclear.

Kevin Buchs
  • 353
  • 1
  • 3
  • 20

2 Answers2

0

Is it a must to use "knife deps"? because you can achieve your goal by using the "knife search" command, like so:

knife search -i 'cookbooks:your-cookbook' -a cookbooks.your-cookbook.version

This will give you output that shows the hostname and the cookbook version:

1 items found

server.name.example:
  cookbooks.cs-redis.version: 0.3.2

Another thing you can do is to use a base cookbook and set an attribute on the node with the cookbook versions.

Example:

run_context.cookbook_collection.each do |key, cookbook|
  node.set['base_cookbook']['cookbook_versions'][cookbook.name] = cookbook.version
end

Then you can query the versions used by a node like so:

knife node show <node-name> -a base_cookbook.cookbook_versions
Itai Ganot
  • 10,644
  • 29
  • 93
  • 146
  • Thanks for the suggestion. I am probably more concerned about cookbooks dependent upon other cookbooks, but you give a way to find nodes dependent upon cookbooks. – Kevin Buchs Feb 13 '18 at 21:23
0

No answer currently exists. Trying to take my bounty back!

Kevin Buchs
  • 353
  • 1
  • 3
  • 20