Detect the Chef Client version in a Chef recipe

故事扮演 提交于 2019-12-11 04:28:23

问题


I am upgrading my cookbooks from Chef version 12.11.18 to 13.6.4. Some version 13 specific instructions do not work in Chef version 12 and vice versa. My existing servers still use Chef Client 12, but the new servers will launch with Chef version 13 in the same environment, so the same cookbook version should work with both versions of Chef.

I need to detect the version of the Chef Client in a recipe and select the version specific code with an "if" statement. How can I read the version of the Chef Client in a Chef recipe?


回答1:


If you have Chef installed from the package version should be in node["chef_packages"]["chef"]["version"]. If this does not work, you should be able to read Chef::VERSION from recipe.



来源:https://stackoverflow.com/questions/49462061/detect-the-chef-client-version-in-a-chef-recipe

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