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
-
Enhancement
-
-
Needs Assessment
Description
Implement SemVerRange type support for the apt 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 apt 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 apt-cache policy)
- 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
|
available_versions = `apt-cache -a show #{@resource.name} | grep Version | awk '{print $2}'`.split
|
range = @resource.should(:ensure)
|
|
available.versions.any? { |version| range.include?(version.to_stable) }
|
end
|
Example apt-get install with a specific version:
apt-get install puppet-agent=6.3.0-1jessie
|