Puppet: System Administration Automated

Support

Ticket #973: fix-973.patch

File fix-973.patch, 25.0 kB (added by sdelmont, 1 year ago)
  • a/lib/puppet/provider/package.rb

    old new  
    2626        end 
    2727        @property_hash.dup 
    2828    end 
     29     
     30    def internalname 
     31      @resource[:internalname] || @resource[:name] 
     32    end 
    2933end 
  • a/lib/puppet/provider/package/appdmg.rb

    old new  
    9595    end # def self.installpkgdmg 
    9696 
    9797    def query 
    98         if FileTest.exists?("/var/db/.puppet_appdmg_installed_#{@resource[:name]}") 
    99             return {:name => @resource[:name], :ensure => :present} 
     98        if FileTest.exists?("/var/db/.puppet_appdmg_installed_#{self.internalname}") 
     99            return {:name => self.internalname, :ensure => :present} 
    100100        else 
    101101            return nil 
    102102        end 
     
    107107        unless source = @resource[:source] 
    108108            self.fail "Mac OS X PKG DMG's must specify a package source." 
    109109        end 
    110         unless name = @resource[:name] 
     110        unless name = self.internalname 
    111111            self.fail "Mac OS X PKG DMG's must specify a package name." 
    112112        end 
    113113        self.class.installpkgdmg(source,name) 
  • a/lib/puppet/provider/package/apple.rb

    old new  
    3535    end 
    3636 
    3737    def query 
    38         if FileTest.exists?("/Library/Receipts/#{@resource[:name]}.pkg") 
    39             return {:name => @resource[:name], :ensure => :present} 
     38        if FileTest.exists?("/Library/Receipts/#{self.internalname}.pkg") 
     39            return {:name => self.internalname, :ensure => :present} 
    4040        else 
    4141            return nil 
    4242        end 
  • a/lib/puppet/provider/package/apt.rb

    old new  
    4949 
    5050        checkforcdrom() 
    5151 
    52         str = @resource[:name] 
     52        str = self.internalname 
    5353        case should 
    5454        when true, false, Symbol 
    5555            # pass 
     
    7878 
    7979    # What's the latest package version available? 
    8080    def latest 
    81         output = aptcache :policy,  @resource[:name] 
     81        output = aptcache :policy,  self.internalname 
    8282 
    8383        if output =~ /Candidate:\s+(\S+)\s/ 
    8484            return $1 
     
    106106    end 
    107107 
    108108    def uninstall 
    109         aptget "-y", "-q", :remove, @resource[:name] 
     109        aptget "-y", "-q", :remove, self.internalname 
    110110    end 
    111111 
    112112    def purge 
    113         aptget '-y', '-q', 'remove', '--purge', @resource[:name] 
     113        aptget '-y', '-q', 'remove', '--purge', self.internalname 
    114114        # workaround a "bug" in apt, that already removed packages are not purged 
    115115        super 
    116116    end 
  • a/lib/puppet/provider/package/aptitude.rb

    old new  
    2525    end 
    2626 
    2727    def purge 
    28         aptitude '-y', 'purge', @resource[:name] 
     28        aptitude '-y', 'purge', self.internalname 
    2929        end 
    3030end 
    3131 
  • a/lib/puppet/provider/package/aptrpm.rb

    old new  
    2525    def install 
    2626        should = @resource.should(:ensure) 
    2727 
    28         str = @resource[:name] 
     28        str = self.internalname 
    2929        case should 
    3030        when true, false, Symbol 
    3131            # pass 
     
    4242 
    4343    # What's the latest package version available? 
    4444    def latest 
    45         output = aptcache :showpkg,  @resource[:name] 
     45        output = aptcache :showpkg,  self.internalname 
    4646 
    4747        if output =~ /Versions:\s*\n((\n|.)+)^$/ 
    4848            versions = $1 
     
    7676    end 
    7777 
    7878    def uninstall 
    79         aptget "-y", "-q", 'remove', @resource[:name] 
     79        aptget "-y", "-q", 'remove', self.internalname 
    8080    end 
    8181 
    8282    def purge 
    83         aptget '-y', '-q', 'remove', '--purge', @resource[:name] 
     83        aptget '-y', '-q', 'remove', '--purge', self.internalname 
    8484    end 
    8585end 
    8686 
  • a/lib/puppet/provider/package/blastwave.rb

    old new  
    8686    end 
    8787 
    8888    def install 
    89         pkgget "-f", :install, @resource[:name] 
     89        pkgget "-f", :install, self.internalname 
    9090    end 
    9191 
    9292    # Retrieve the version from the current package file. 
    9393    def latest 
    94         hash = self.class.blastlist(:justme => @resource[:name]
     94        hash = self.class.blastlist(:justme => self.internalname
    9595        hash[:avail] 
    9696    end 
    9797 
    9898    def query 
    99         if hash = self.class.blastlist(:justme => @resource[:name]
     99        if hash = self.class.blastlist(:justme => self.internalname
    100100            hash 
    101101        else 
    102102            {:ensure => :absent} 
     
    105105 
    106106    # Remove the old package, and install the new one 
    107107    def update 
    108         pkgget "-f", :upgrade, @resource[:name] 
     108        pkgget "-f", :upgrade, self.internalname 
    109109    end 
    110110 
    111111    def uninstall 
    112         pkgget "-f", :remove, @resource[:name] 
     112        pkgget "-f", :remove, self.internalname 
    113113    end 
    114114end 
    115115 
  • a/lib/puppet/provider/package/darwinport.rb

    old new  
    4747        should = @resource.should(:ensure) 
    4848 
    4949        # Seems like you can always say 'upgrade' 
    50         output = port "upgrade", @resource[:name] 
     50        output = port "upgrade", self.internalname 
    5151        if output =~ /^Error: No port/ 
    52             raise Puppet::ExecutionFailure, "Could not find package %s" % @resource[:name] 
     52            raise Puppet::ExecutionFailure, "Could not find package %s" % self.internalname 
    5353        end 
    5454    end 
    5555 
    5656    def query 
    5757        version = nil 
    5858        self.class.eachpkgashash do |hash| 
    59             if hash[:name] == @resource[:name] 
     59            if hash[:name] == self.internalname 
    6060                return hash 
    6161            end 
    6262        end 
     
    6565    end 
    6666 
    6767    def latest 
    68         info = port :search, "^#{@resource[:name]}$" 
     68        info = port :search, "^#{self.internalname}$" 
    6969 
    7070        if $? != 0 or info =~ /^Error/ 
    7171            return nil 
     
    7878    end 
    7979 
    8080    def uninstall 
    81         port :uninstall, @resource[:name] 
     81        port :uninstall, self.internalname 
    8282    end 
    8383 
    8484    def update 
  • a/lib/puppet/provider/package/dpkg.rb

    old new  
    6464    def latest 
    6565        output = dpkg_deb "--show", @resource[:source] 
    6666        matches = /^(\S+)\t(\S+)$/.match(output).captures 
    67         unless matches[0].match(@resource[:name]
     67        unless matches[0].match(self.internalname
    6868            Puppet.warning "source doesn't contain named package, but %s" % matches[0] 
    6969        end 
    7070        matches[1] 
     
    8080        # list out our specific package 
    8181        begin 
    8282            output = dpkgquery("-W", "--showformat", 
    83                 '${Status} ${Package} ${Version}\\n', @resource[:name] 
     83                '${Status} ${Package} ${Version}\\n', self.internalname 
    8484            ) 
    8585        rescue Puppet::ExecutionFailure 
    8686            # dpkg-query exits 1 if the package is not found. 
    8787            return {:ensure => :purged, :status => 'missing', 
    88                 :name => @resource[:name], :error => 'ok'} 
     88                :name => self.internalname, :error => 'ok'} 
    8989 
    9090        end 
    9191        # Our regex for matching dpkg-query output.  We could probably just 
     
    102102        else 
    103103            notice "Failed to handle dpkg-query line %s" % line.inspect 
    104104            return {:ensure => :absent, :status => 'missing', 
    105                 :name => @resource[:name], :error => 'ok'} 
     105                :name => self.internalname, :error => 'ok'} 
    106106        end 
    107107 
    108108        if hash[:error] != "ok" 
     
    123123    end 
    124124 
    125125    def uninstall 
    126         dpkg "-r", @resource[:name] 
     126        dpkg "-r", self.internalname 
    127127    end 
    128128 
    129129    def purge 
    130         dpkg "--purge", @resource[:name] 
     130        dpkg "--purge", self.internalname 
    131131    end 
    132132end 
    133133 
  • a/lib/puppet/provider/package/fink.rb

    old new  
    2929        end 
    3030        should = @resource.should(:ensure) 
    3131 
    32         str = @resource[:name] 
     32        str = self.internalname 
    3333        case should 
    3434        when true, false, Symbol 
    3535            # pass 
     
    4848 
    4949    # What's the latest package version available? 
    5050    def latest 
    51         output = aptcache :policy,  @resource[:name] 
     51        output = aptcache :policy,  self.internalname 
    5252 
    5353        if output =~ /Candidate:\s+(\S+)\s/ 
    5454            return $1 
     
    8080    end 
    8181 
    8282    def purge 
    83         aptget '-y', '-q', 'remove', '--purge', @resource[:name] 
     83        aptget '-y', '-q', 'remove', '--purge', self.internalname 
    8484     end 
    8585end 
    8686 
  • a/lib/puppet/provider/package/freebsd.rb

    old new  
    2222            return super 
    2323        end 
    2424 
    25         pkgadd "-r", @resource[:name] 
     25        pkgadd "-r", self.internalname 
    2626    end 
    2727 
    2828    def query 
     
    3535    end 
    3636 
    3737    def uninstall 
    38         pkgdelete "%s-%s" % [@resource[:name], @resource.should(:ensure)] 
     38        pkgdelete "%s-%s" % [self.internalname, @resource.should(:ensure)] 
    3939    end 
    4040end 
    4141 
  • a/lib/puppet/provider/package/gem.rb

    old new  
    5353                :ensure => version 
    5454            } 
    5555        else 
    56             Puppet.warning "Could not match %s" % desc 
     56            Puppet.warning "gem Could not match %s" % desc 
    5757            nil 
    5858        end 
    5959    end 
     
    7575        if source = @resource[:source] 
    7676            command << source 
    7777        else 
    78             command << @resource[:name] 
     78            command << self.internalname 
    7979        end 
    8080 
    8181        gemcmd(*command) 
     
    8383 
    8484    def latest 
    8585        # This always gets the latest version available. 
    86         hash = self.class.gemlist(:justme => @resource[:name]
     86        hash = self.class.gemlist(:justme => self.internalname
    8787 
    8888        return hash[:ensure] 
    8989    end 
    9090 
    9191    def query 
    92         self.class.gemlist(:justme => @resource[:name], :local => true) 
     92        self.class.gemlist(:justme => self.internalname, :local => true) 
    9393    end 
    9494 
    9595    def uninstall 
    96         gemcmd "uninstall", "-x", "-a", @resource[:name] 
     96        gemcmd "uninstall", "-x", "-a", self.internalname 
    9797    end 
    9898 
    9999    def update 
  • a/lib/puppet/provider/package/openbsd.rb

    old new  
    6363 
    6464    def query 
    6565        hash = {} 
    66         info = pkginfo @resource[:name] 
     66        info = pkginfo self.internalname 
    6767 
    6868        # Search for the version info 
    69         if info =~ /Information for #{@resource[:name]}-(\S+)/ 
     69        if info =~ /Information for #{self.internalname}-(\S+)/ 
    7070            hash[:ensure] = $1 
    7171        else 
    7272            return nil 
     
    8181    end 
    8282 
    8383    def uninstall 
    84         pkgdelete @resource[:name] 
     84        pkgdelete self.internalname 
    8585    end 
    8686end 
    8787 
  • a/lib/puppet/provider/package/pkgdmg.rb

    old new  
    171171    end # def self.installpkgdmg 
    172172 
    173173    def query 
    174         if FileTest.exists?("/var/db/.puppet_pkgdmg_installed_#{@resource[:name]}") 
    175             return {:name => @resource[:name], :ensure => :present} 
     174        if FileTest.exists?("/var/db/.puppet_pkgdmg_installed_#{self.internalname}") 
     175            return {:name => self.internalname, :ensure => :present} 
    176176        else 
    177177            return nil 
    178178        end 
     
    183183        unless source = @resource[:source] 
    184184            self.fail "Mac OS X PKG DMG's must specify a package source." 
    185185        end 
    186         unless name = @resource[:name] 
     186        unless name = self.internalname 
    187187            self.fail "Mac OS X PKG DMG's must specify a package name." 
    188188        end 
    189189        self.class.installpkgdmg(source,name) 
  • a/lib/puppet/provider/package/portage.rb

    old new  
    5555 
    5656    # The common package name format. 
    5757    def package_name 
    58         @resource[:category] ? "%s/%s" % [@resource[:category], @resource[:name]] : @resource[:name] 
     58        @resource[:category] ? "%s/%s" % [@resource[:category], self.internalname] : self.internalname 
    5959    end 
    6060 
    6161    def uninstall 
     
    9898 
    9999            case packages.size 
    100100                when 0 
    101                     not_found_value = "%s/%s" % [@resource[:category] ? @resource[:category] : "<unspecified category>", @resource[:name]
     101                    not_found_value = "%s/%s" % [@resource[:category] ? @resource[:category] : "<unspecified category>", self.internalname
    102102                    raise Puppet::PackageError.new("No package found with the specified name [#{not_found_value}]") 
    103103                when 1 
    104104                    return packages[0] 
  • a/lib/puppet/provider/package/ports.rb

    old new  
    1919    def install 
    2020        # -N: install if the package is missing, otherwise upgrade 
    2121        # -M: yes, we're a batch, so don't ask any questions 
    22         cmd = %w{-N -M BATCH=yes} << @resource[:name] 
     22        cmd = %w{-N -M BATCH=yes} << self.internalname 
    2323 
    2424        output = portupgrade(*cmd) 
    2525        if output =~ /\*\* No such / 
    26             raise Puppet::ExecutionFailure, "Could not find package %s" % @resource[:name] 
     26            raise Puppet::ExecutionFailure, "Could not find package %s" % self.internalname 
    2727        end 
    2828    end 
    2929 
    3030    # If there are multiple packages, we only use the last one 
    3131    def latest 
    32         cmd = ["-v", @resource[:name]
     32        cmd = ["-v", self.internalname
    3333 
    3434        begin 
    3535            output = portversion(*cmd) 
     
    8383    end 
    8484 
    8585    def uninstall 
    86         portuninstall @resource[:name] 
     86        portuninstall self.internalname 
    8787    end 
    8888 
    8989    def update 
  • a/lib/puppet/provider/package/rpm.rb

    old new  
    4444    # :ensure => version-release 
    4545    def query 
    4646        unless @property_hash[:epoch] 
    47             cmd = ["-q", @resource[:name], "--nosignature", "--nodigest", "--qf", "#{NEVRAFORMAT}\n"] 
     47            cmd = ["-q", self.internalname, "--nosignature", "--nodigest", "--qf", "#{NEVRAFORMAT}\n"] 
    4848 
    4949            begin 
    5050                output = rpm(*cmd) 
     
    100100        # installed and only the package name is specified (without the 
    101101        # arch), this will uninstall all of them on successive runs of the 
    102102        # client, one after the other 
    103         if @resource[:name][-arch.size, arch.size] == arch 
     103        if self.internalname[-arch.size, arch.size] == arch 
    104104            nvr += arch 
    105105        else 
    106106            nvr += ".#{get(:arch)}" 
  • a/lib/puppet/provider/package/rug.rb

    old new  
    1212    def install 
    1313        should = @resource.should(:ensure) 
    1414        self.debug "Ensuring => #{should}" 
    15         wanted = @resource[:name] 
     15        wanted = self.internalname 
    1616 
    1717        # XXX: We don't actually deal with epochs here. 
    1818        case should 
     
    3636        #rug can only get a list of *all* available packages? 
    3737        output = rug "list-updates" 
    3838 
    39         if output =~ /#{@resource[:name]}\s*\|\s*([0-9\.\-]+)/ 
     39        if output =~ /#{self.internalname}\s*\|\s*([0-9\.\-]+)/ 
    4040            return $1 
    4141        else 
    4242            # rug didn't find updates, pretend the current 
  • a/lib/puppet/provider/package/sun.rb

    old new  
    8585        if device 
    8686            cmd += " -d #{device}" 
    8787        end 
    88         cmd += " #{@resource[:name]}" 
     88        cmd += " #{self.internalname}" 
    8989 
    9090        begin 
    9191            # list out all of the packages 
     
    129129        end 
    130130 
    131131        cmd << "-d" << @resource[:source] 
    132         cmd << "-n" << @resource[:name] 
     132        cmd << "-n" << self.internalname 
    133133 
    134134        pkgadd cmd 
    135135    end 
     
    151151            command << "-a" << @resource[:adminfile] 
    152152        end 
    153153 
    154         command << @resource[:name] 
     154        command << self.internalname 
    155155        pkgrm command 
    156156    end 
    157157 
  • a/lib/puppet/provider/package/up2date.rb

    old new  
    99 
    1010    # Install a package using 'up2date'. 
    1111    def install 
    12         up2date "-u", @resource[:name] 
     12        up2date "-u", self.internalname 
    1313 
    1414        unless self.query 
    1515            raise Puppet::ExecutionFailure.new( 
     
    2323        #up2date can only get a list of *all* available packages? 
    2424        output = up2date "--showall" 
    2525 
    26         if output =~ /^#{@resource[:name]}-(\d+.*)\.\w+/ 
     26        if output =~ /^#{self.internalname}-(\d+.*)\.\w+/ 
    2727            return $1 
    2828        else 
    2929            # up2date didn't find updates, pretend the current 
  • a/lib/puppet/provider/package/urpmi.rb

    old new  
    1919    def install 
    2020        should = @resource.should(:ensure) 
    2121        self.debug "Ensuring => #{should}" 
    22         wanted = @resource[:name] 
     22        wanted = self.internalname 
    2323 
    2424        # XXX: We don't actually deal with epochs here. 
    2525        case should 
     
    4141 
    4242    # What's the latest package version available? 
    4343    def latest 
    44         output = urpmi "-S",  :available, @resource[:name] 
     44        output = urpmi "-S",  :available, self.internalname 
    4545 
    46         if output =~ /^#{@resource[:name]}\S+\s+(\S+)\s/ 
     46        if output =~ /^#{self.internalname}\S+\s+(\S+)\s/ 
    4747            return $1 
    4848        else 
    4949            # urpmi didn't find updates, pretend the current 
  • a/lib/puppet/provider/package/yum.rb

    old new  
    4545    def install 
    4646        should = @resource.should(:ensure) 
    4747        self.debug "Ensuring => #{should}" 
    48         wanted = @resource[:name] 
     48        wanted = self.internalname 
    4949 
    5050        # XXX: We don't actually deal with epochs here. 
    5151        case should 
     
    7373 
    7474    # What's the latest package version available? 
    7575    def latest 
    76         upd = self.class.updates[@resource[:name]
     76        upd = self.class.updates[self.internalname
    7777        unless upd.nil? 
    7878            # FIXME: there could be more than one update for a package 
    7979            # because of multiarch 
  • a/lib/puppet/type/package.rb

    old new  
    207207            isnamevar 
    208208        end 
    209209 
     210        newparam(:internalname) do 
     211            desc "The package name as it's known by the provider. 
     212             
     213            This overrides the 'name' parameter, and lets you use different 
     214            names to reference packages with the same internal name in 
     215            different providers. Otherwise, puppet would think you were 
     216            trying to redefine the same package. 
     217             
     218                package { \"mysql-yum\": 
     219                    ensure        => installed, 
     220                    internalname  => \"mysql\", 
     221                    provider      => yum; 
     222                } 
     223 
     224                package { \"mysql-gem\": 
     225                    ensure        => installed, 
     226                    internalname  => \"mysql\", 
     227                    provider      => gem; 
     228                } 
     229             
     230            " 
     231        end 
     232         
    210233        newparam(:source) do 
    211234            desc "Where to find the actual package.  This must be a local file 
    212235                (or on a network file system) or a URL that your specific