Metadata.rb is used in Chef to define several important metadata values within the Chef cookbook. Chef infra client version is one of them. The Chef version setting can be used to define the range of chef client versions supported by the cookbook.
For example, the following specifies a match for any chef client version in the16.x series. The configurations defined in Chef recipes will be applied only to servers (nodes) running chef client version 16.x
chef_version '~> 16.0'
However, even after setting the 'chef_version' for cookbook as shown in the above example, you can still customize your recipes to work with other chef client versions.
This blog explains one possible mechanism for customizing a Chef recipe to run with different versions of Chef clients.
Pre-requisites: chef workstation, chef cookbook
Let's get started.