Is there a way to use “knife search node” or “knife show node” that will tell you the cookbook/recipe version being used?

这一生的挚爱 提交于 2019-12-10 11:55:26

问题


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\:\:default@0.3.1' does not.


回答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.



来源:https://stackoverflow.com/questions/31012767/is-there-a-way-to-use-knife-search-node-or-knife-show-node-that-will-tell-yo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!