Skip to content

Instantly share code, notes, and snippets.

@jtimberman
Created June 7, 2010 14:47
Show Gist options
  • Save jtimberman/428751 to your computer and use it in GitHub Desktop.
Save jtimberman/428751 to your computer and use it in GitHub Desktop.
Chef version checking in recipes
# access chef's version constant directly
if Chef::VERSION.to_f >= 0.8
# 0.8+ only features here
end
# node attribute, requires ohai version 0.5.4:
if node.chef_packages.chef.version.to_f >= 0.8
# 0.8+ only features here
end
@lamont-granquist
Copy link

Gem::Requirement.new(">= 0.8").satisfied_by?(Gem::Version.new(Chef::VERSION))

@lamont-granquist
Copy link

or Chef::VERSION >= 13.0 in recent enough chef-client where Chef::VERSION is a Chef::VersionString object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment