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?
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.
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
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.
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?