Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-10299

Add SemVerRange support to zypper package provider

    XMLWordPrintable

    Details

    • Template:
    • Team:
      Night's Watch
    • Story Points:
      5
    • Sprint:
      NW - 2020-03-04, NW - 2020-04-15, NW - 2020-04-29
    • Release Notes:
      Enhancement
    • Release Notes Summary:
      Add support of >, >=, <, <=, >=A <=B ranges for package version specified in :ensure for zypper provider
    • QA Risk Assessment:
      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

        Attachments

          Activity

            People

            Assignee:
            ciprian.badescu Ciprian Badescu
            Reporter:
            gabriel.nagy Gabriel Nagy
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Zendesk Support