Detect the Chef Client version in a Chef recipe

2019-07-30 08:43发布

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条回答
Evening l夕情丶
2楼-- · 2019-07-30 08:55

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.

查看更多
登录 后发表回答