Details
-
New Feature
-
Status: Resolved
-
Normal
-
Resolution: Fixed
-
None
-
Night's Watch
-
5
-
NW - 2020-03-04, NW - 2020-04-15, NW - 2020-04-29
-
Enhancement
-
Add support of >, >=, <, <=, >=A <=B ranges for package version specified in :ensure for zypper provider
-
Needs Assessment
Description
Implement SemVerRange type support for the zypper provider.
Sample manifest with a range passed for a package:
package { 'puppet-agent':
|
# this will be parsed as: >= 6.0.0 < 6.1.0
|
ensure => SemVerRange('~> 6.0')
|
}
|
|
package { 'puppet-agent':
|
ensure => SemVerRange('>= 6.5')
|
}
|
|
package { 'puppet-agent':
|
ensure => SemVerRange('< 6.4')
|
}
|
|
package { 'puppet-agent':
|
# this is a valid range which we can support
|
ensure => SemVerRange('~> 6.0 || ~> 6.11')
|
}
|
The zypper 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 zypper search -s)
- 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 = `zypper -q se -s #{@resource.name} | awk '{print $6}'`.split
|
range = @resource.should(:ensure)
|
|
available.versions.any? { |version| range.include?(version.to_stable) }
|
end
|
Example zypper install with a specific version:
zypper install puppet-agent=6.0.10-1.sles15
|