在Chef食谱中检测Chef Client版本 [英] Detect the Chef Client version in a Chef recipe
问题描述
我正在将我的食谱从Chef版本12.11.18升级到13.6.4.某些特定于版本13的说明在Chef版本12中不起作用,反之亦然.我现有的服务器仍使用Chef Client 12,但新服务器将在同一环境中以Chef版本13启动,因此相同的Cookbook版本应在两个版本的Chef中都可以使用.
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.
我需要在配方中检测Chef Client的版本,并使用"if"语句选择特定于版本的代码.如何在厨师食谱中读取厨师客户的版本?
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?
推荐答案
如果从软件包中安装了Chef,则版本应位于node["chef_packages"]["chef"]["version"]
中.如果这不起作用,则您应该能够从配方中读取Chef::VERSION
.
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.
这篇关于在Chef食谱中检测Chef Client版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!