Version contraints in metadata

Hi,

I’ve got a cookbook that I’ve tested on some versions of Ubuntu but not all.

In my metadata I’m wanting to do:

supports “ubuntu”, “>= 11.04”, “< 12.10”

The docs[1] suggest this cane be done, though the example is missing.

However “knife cookbook test” doesn’t like it:

ERROR: Chef::Exceptions::ObsoleteDependencySyntax: The dependency
specification syntax you are using is no longer valid. You may not specify
more than one version constraint for a particular cookbook.

What’s the best way to constrain my cookbook so that it will only run on OS
versions that I’ve tested it on?

For reference, this is running on chef 11.4.0.

Cheers, Gavin

[1] http://docs.opscode.com/config_rb_metadata.html

I think, in this case, you'll want to just specify each version:
supports "ubuntu", "= 11.04"
supports "ubuntu", "= 11.10"
supports "ubuntu", "= 12.04"

Or
supports "ubuntu", "~>11"
supports "ubuntu", "12.04"

Or
%w(11.04 11.10 12.04).each do |v|
supports "ubuntu", "= #{v}"
end

The docs are a little incorrect, you're right. They suggest that
supports 'ubuntu', ">= 8.04"
will "...support versions of Ubuntu between 8.04 and 9.10" which is not the
case (perhaps it was when they were written?). It used to be the case that
you could specify multiple versions on one platform, but as you can see
from the error message, that's been deprecated.

Hope that helps,

Matt Moretti

On Fri, Apr 26, 2013 at 11:52 AM, Gavin Sandie beach@vicecity.co.uk wrote:

metadata.rb

On 26 April 2013 17:54, Matthew Moretti werebus@gmail.com wrote:

I think, in this case, you'll want to just specify each version:
supports "ubuntu", "= 11.04"
supports "ubuntu", "= 11.10"
supports "ubuntu", "= 12.04"

Thanks Matt sounds sensible, I'll test it out.

The docs are a little incorrect, you're right. They suggest that
supports 'ubuntu', ">= 8.04"
will "...support versions of Ubuntu between 8.04 and 9.10" which is not
the case (perhaps it was when they were written?). It used to be the case
that you could specify multiple versions on one platform, but as you can
see from the error message, that's been deprecated.

I'll stick in a PR to update the docs if the above works ok :slight_smile:

Ohai!

For what it's worth, the "supports" attribute of metadata does not do anything at this time. It exists for documentation at this time.

If you'd like to have a recipe not get executed on a node of a non-supported platform and do that through metadata, you can do that in the recipe (or as a library with a method you send in the recipe).

For example:

That doesn't support version constraint on platform_version in the #supported_platform? predicate method, so you'd have to add that logic.

Related tickets:

http://tickets.opscode.com/browse/CHEF-3871
http://tickets.opscode.com/browse/CHEF-3870

Cheers,
Joshua

On Apr 26, 2013, at 8:52 AM, Gavin Sandie beach@vicecity.co.uk wrote:

I've got a cookbook that I've tested on some versions of Ubuntu but not all.

In my metadata I'm wanting to do:

supports "ubuntu", ">= 11.04", "< 12.10"

The docs[1] suggest this cane be done, though the example is missing.

However "knife cookbook test" doesn't like it:

ERROR: Chef::Exceptions::ObsoleteDependencySyntax: The dependency specification syntax you are using is no longer valid. You may not specify more than one version constraint for a particular cookbook.

What's the best way to constrain my cookbook so that it will only run on OS versions that I've tested it on?

For reference, this is running on chef 11.4.0.