Puppet: System Administration Automated

Support

Ticket #265: yum_query_provider.patch

File yum_query_provider.patch, 1.1 kB (added by abnormaliti, 2 years ago)

adds a query function the yum provider to support arch's in package names.

  • ./lib/puppet/provider/package/yum.rb

    old new  
    4949    def versionable? 
    5050       true 
    5151    end 
     52 
     53    # Find the fully versioned package name and the version alone. Returns 
     54    # a hash with entries :instance => fully versioned package name, and  
     55    # :ensure => version-release 
     56    def query 
     57        output = yum "-d", "0", "-e", "0", :list, :installed, @model[:name] 
     58         
     59        # if yum returns nothing it mean it is not installed. 
     60        if output == "" 
     61            return nil 
     62        end 
     63 
     64        regex = /^(#{@model[:name]}\S{0,})\s+(\S+)\s/ 
     65        fields = [:instance, :ensure] 
     66        hash = {} 
     67        if match = regex.match(output) 
     68            fields.zip(match.captures) { |field,value| 
     69                hash[field] = value 
     70            } 
     71        else 
     72            raise Puppet::DevError, 
     73                "Failed to match yum output '%s'" % 
     74                output 
     75        end 
     76 
     77        @nvr = hash[:instance] 
     78 
     79        return hash 
     80    end 
    5281end 
    5382 
    5483# $Id: yum.rb 2235 2007-02-27 23:18:52Z luke $