Details
-
New Feature
-
Status: Resolved
-
Normal
-
Resolution: Fixed
-
None
-
Night's Watch
-
5
-
NW - 2020-03-04, NW - 2020-03-17, NW - 2020-04-01, NW - 2020-04-15
-
Enhancement
-
Add support of >, >=, <, <=, >=A <=B ranges for package version specified in :ensure for yum provider.
-
Needs Assessment
Description
Implement Version Range type support for the yum provider.
Sample manifest with a range passed for a package:
package { 'puppet-agent':
|
ensure => '>= 6.5'
|
}
|
|
package { 'puppet-agent':
|
ensure => '< 6.4'
|
}
|
|
package { 'puppet-agent':
|
ensure => '>6.4 <=7'
|
}
|
The yum provider does not support a version range passed in the install command, so we have to:
- find out the available versions for a specific package (usually with yum list --showduplicates)
- install the most recent package which respects the range.
We should also make sure we don't take additional actions if the range is already satisfied (i.e. puppet apply with a SemVerRange should be idempotent)
Sample code on how the ensure property can be treated inside the provider:
if @resource.should(:ensure).is_a?(SemanticPuppet::VersionRange)
|
# these should be sorted in descending order
|
_, *versions = `yum list -d 0 -e 1 --showduplicates #{@resource.name} | awk '{print $2}'`.split
|
range = @resource.should(:ensure)
|
|
available.versions.any? { |version| range.include?(version.to_stable) }
|
end
|
Example yum install with a specific version (package name and version are joined by a dash):
yum install puppet-agent-6.0.4-1.el7
|
Limitations of Version Ranges: YUM provider is using RPM to compare package versions and no epoch is considered `zero` epoch. As a consequence to this we need to specify also the epoch if we don't want the default behaviour
For example:
- >1 <2 will search in (0:1, 0:2) interval
- >1 <1:2 will search in (0:1, 1:2) interval, eligible versions will be searched in bot 0 and 1 epoch
- >1 will consider any version form epoch 0, greater that 1 and any version with epoch > 0