Is there a way to use "knife search node" or "knife show node" that will tell you the cookbook/recipe version being used?
Asked Answered
D

2

0

knife node show my_chef_node will give you information like the recipes, roles, etc. but ideally what I want is to be able to see the version of those cookbook recipes as well.

knife search node 'recipes:my_cookbook\:\:default' returns nodes but knife search node 'recipes:my_cookbook\:\:[email protected]' does not.

Dorise answered 23/6, 2015 at 20:22 Comment(1)
There is nothing out of the box for this, but you can set it up fairly easily. See my answer hereAlbum
B
1

Unless you constrain the runlist it will be calculated at runtime. Determining this just by looking at the cookbook versions loaded into the server is very hard.

How does one constrain the runlist? One mechanism is to set the version explicitly on the run-list, but this will only partially help as it won't lock the versions of dependencies (unless you've added constraints in your cookbook metadata).

The best approach is to setup Chef environments and associate this with your managed nodes. Use tools to set the cookbook constraints when loading cookbooks. For example using Berkshelf

berks upload
berks apply my-special-runtime-env

Another lessor known approach is using the knife cookbook upload command

knife cookbook upload --all --force --environment my-special-runtime-env

Finally there the option of using the new chef policy file functionality. I have not personally used it, but include it for completeness.

Boyle answered 24/6, 2015 at 1:12 Comment(0)
H
0

Use -a cookbooks . And it works for me:

knife search node 'node-*' -a cookbooks
node-123.server.example.com:
  cookbooks:
    ack:
      version: 7.5.17
    brk:
      version: 6.0.27
...
Hagiocracy answered 22/2 at 0:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.