Jira (PUP-10298) Add SemVerRange support to yum package provider

0 views
Skip to first unread message

Gabriel Nagy (JIRA)

unread,
Feb 18, 2020, 7:29:04 AM2/18/20
to puppe...@googlegroups.com
Gabriel Nagy created an issue
 
Puppet / New Feature PUP-10298
Add SemVerRange support to yum package provider
Issue Type: New Feature New Feature
Assignee: Unassigned
Created: 2020/02/18 4:28 AM
Priority: Normal Normal
Reporter: Gabriel Nagy

Implement SemVerRange type support for the yum 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 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

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Mihai Buzgau (JIRA)

unread,
Feb 18, 2020, 7:44:05 AM2/18/20
to puppe...@googlegroups.com
Mihai Buzgau updated an issue
Change By: Mihai Buzgau
Component/s: Types and Providers

Mihai Buzgau (JIRA)

unread,
Feb 19, 2020, 6:12:05 AM2/19/20
to puppe...@googlegroups.com

Mihai Buzgau (JIRA)

unread,
Feb 19, 2020, 6:13:07 AM2/19/20
to puppe...@googlegroups.com
Mihai Buzgau updated an issue
Change By: Mihai Buzgau
Sprint: PR NW - Triage 2020-03-04

Mihai Buzgau (JIRA)

unread,
Feb 26, 2020, 4:22:03 AM2/26/20
to puppe...@googlegroups.com

Mihai Buzgau (Jira)

unread,
Mar 5, 2020, 3:54:04 AM3/5/20
to puppe...@googlegroups.com
Mihai Buzgau updated an issue
Change By: Mihai Buzgau
Sprint: NW - 2020-03-04 , NW - 2020-03-17
This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935)
Atlassian logo

Mihai Buzgau (Jira)

unread,
Mar 18, 2020, 4:54:04 AM3/18/20
to puppe...@googlegroups.com
Mihai Buzgau updated an issue
Change By: Mihai Buzgau
Sprint: NW - 2020-03-04, NW - 2020-03-17 , NW - 2020-04-01

Mihai Buzgau (Jira)

unread,
Apr 1, 2020, 3:51:03 AM4/1/20
to puppe...@googlegroups.com
Mihai Buzgau updated an issue
Change By: Mihai Buzgau
Sprint: NW - 2020-03-04, NW - 2020-03-17, NW - 2020-04-01 , NW - 2020-04-15

Gabriel Nagy (Jira)

unread,
Apr 23, 2020, 8:02:03 AM4/23/20
to puppe...@googlegroups.com
Gabriel Nagy updated an issue
Change By: Gabriel Nagy
Fix Version/s: PUP 6.15.0

Claire Cadman (Jira)

unread,
Apr 27, 2020, 8:31:04 AM4/27/20
to puppe...@googlegroups.com

Gheorghe Popescu (Jira)

unread,
Apr 29, 2020, 5:57:03 AM4/29/20
to puppe...@googlegroups.com
Gheorghe Popescu updated an issue
Change By: Gheorghe Popescu
Implement Version Range type support for the {{yum}} provider.


Sample manifest with a range passed for a package:

{code:title=|language=none|collapse=false}
package { 'puppet-agent':
  ensure => '>= 6.5'
}

package { 'puppet-agent':
  ensure => '< 6.4'
}

package { 'puppet-agent':
  ensure => '>6.4 <=7'
}
{code}

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:

{code:title=|language=none|collapse=false}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
{code}

Example {{yum install}} with a specific version (package name and version are joined by a dash):

{noformat}
yum install puppet-agent-6.0.4-1.el7{noformat}
 

 

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

Gheorghe Popescu (Jira)

unread,
Apr 29, 2020, 5:57:03 AM4/29/20
to puppe...@googlegroups.com
Gheorghe Popescu updated an issue
Implement SemVerRange Version Range type support for the {{yum}} provider.


Sample manifest with a range passed for a package:

{code:title=|language=none|collapse=false}
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 4 <=7 ' )
Reply all
Reply to author
Forward
0 new messages