How to check if the chef version meets the gem requirement from the inside of the recipe?

Chef :: Version contains the chef's gem version number, and I want to check if it matches the gem requirements ~> 10.14inside the recipe.

+4
source share
1 answer

Use Gem::Requirementand Gem::Version:

Gem::Requirement.new("~> 10.14").satisfied_by?(Gem::Version.new(Chef::VERSION))

Returns a boolean value - true if Chef::VERSIONsatisfied ~> 10.14.

+4
source

All Articles