voxpupuli / puppet-yum

Puppet module for Yum
https://forge.puppet.com/puppet/yum
MIT License
16 stars 101 forks source link

Please add support for repos with multiple gpgkeys #187

Open anselmic opened 4 years ago

anselmic commented 4 years ago

Hello,

I have currently installed version 4.1.0. Some repos like atomic or occasionally puppet come with multiple keys. In the current module, it is possible to specify more than one gpgkey for a repo, but then the keys are not automatically included. It is possible that I missed the correct way of specifying the keys, but after several attempts with Foreman, I locally solved the problem by a slight modification of the code (see hereafter).

I hope this helps. C

diff init.pp init.pp.sav 145,158c145,155 < $matches0 = split ($attributes['gpgkey'], ' ') < $matches0.each |String $attr| { < $matches = $attr.match('^file://(.)$') < if $matches { < $gpgkey = $matches[1] < if $gpgkey =~ Stdlib::AbsolutePath and $gpgkey in $gpgkeys { < if !defined(Yum::Gpgkey[$gpgkey]) { < yum::gpgkey { $gpgkey: < => $gpgkeys[$gpgkey], < } < } # end if Yum::Gpgkey[$gpgkey] is not defined < } # end if $gpgkey exists in gpgkeys < } # end if gpgkey is a file:// resource < }

      $matches = $attributes['gpgkey'].match('^file://(.*)$')
      if $matches {
        $gpgkey = $matches[1]
        if $gpgkey =~ Stdlib::AbsolutePath and $gpgkey in $gpgkeys {
          if !defined(Yum::Gpgkey[$gpgkey]) {
            yum::gpgkey { $gpgkey:
              * => $gpgkeys[$gpgkey],
            }
          } # end if Yum::Gpgkey[$gpgkey] is not defined
        } # end if $gpgkey exists in gpgkeys
      } # end if gpgkey is a file:// resource
Legends0 commented 3 years ago

Even the puppet release repo has multiple gpgkeys in it. So this is a sensible request.

Example /etc/yum.repos.d/puppet.repo

[puppet]
name=Puppet Repository el 7 - $basearch
baseurl=http://yum.puppetlabs.com/puppet/el/7/$basearch
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-puppet-release
       file:///etc/pki/rpm-gpg/RPM-GPG-KEY-2025-04-06-puppet-release
enabled=1
gpgcheck=1
Legends0 commented 3 years ago

This issue is a duplicate of #131.