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.

2 Answers 2

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 
1
  • 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. Commented Feb 13, 2018 at 21:23
0

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

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.