Run cookbook specifying only major version


We are planning to have two version series of the cookbooks for branching.
We would like to call the specific major version of the cookbook wherever required.

When i specify the exact version of the cookbook, it works fine. However, at any point of time, we will not know the current version of the cookbook unless we list the latest versions and get the number.

Is there anyway to call the latest version of the cookbook specifying only the major version ?

For example, if the metadata.version is 17.1.1 on Monday and it is 17.1.8 on Friday, i would like to invoke whatever is the latest number in 17 series.

Any help would be much appreciated.

Thank you

Using pessimistic version constraint: 'cookbook', '~> 17' for example in another cookbook metadata’s depends line.


Thank you, I tried using this in Environment.json and invoked recipe specific to environment.

Otherwise, Is there a direct way of running the recipe with operators ? I tried called the specific version and that works, however <, > ,= don’t work on the the command.

Not that I’m aware of, you specify a runlist of cookbooks, but not of specific version.

One workaround could be to use wrapper cookbooks just depending on your cookbook with a pessimistic limitation and named over the major you’re targeting. This way you can take advantage of the syntax in the metatdata.rb and chose on command line which cookbook you use for the run.

Sorry for mentioning the word recipe there. I meant invoking cookbook with major version.

Thanks, idea of wrapper cookbook is nice. That will help to run the desired versions without the dependency of environment and roles.

Well to be “pedantic” when you add in runlist a ‘cookbook’ entry it resolve to the recipe ‘cookbook::default’ so that’s ok :slight_smile:

The wrapper is the only way I’m aware of which can solve what you’re after. Maybe policyfiles can also, but I didn’t dig into them.