Defined Type: yum::rpm_gpg_key

Defined in:
manifests/rpm_gpg_key.pp

Summary

Downloads a public gpg key for a yum repo and installs the key Uses wget and rpimport commands

Overview

Parameters:

  • gpgkey_url (Stdlib::Httpurl)

    Specify the source URL for the GPG key to download from.

  • gpgkey (Stdlib::Absolutepath)

    Specify the fully qualified destination file name for the GPG key to save to.

  • wget_path (String) (defaults to: '/bin:/usr/bin:/sbin:/usr/sbin')

    Specify the path parameter to be used for the wget command.

  • rpm_path (String) (defaults to: '/bin:/usr/bin:/sbin:/usr/sbin')

    Specify the path parameter to be used for the rpm command.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'manifests/rpm_gpg_key.pp', line 16

define yum::rpm_gpg_key (
  Stdlib::Httpurl $gpgkey_url,
  Stdlib::Absolutepath $gpgkey,
  String $wget_path = '/bin:/usr/bin:/sbin:/usr/sbin',
  String $rpm_path  = '/bin:/usr/bin:/sbin:/usr/sbin',
) {

  # wget -O in the yum_wget_gpgkey_for_${name}_repo exec will leave an empty
  # file if it does not download one, which causes problems. This exec will
  # remove the key if it exists, but is empty.
  exec { "remove_if_empty-${gpgkey}":
    command => "rm -f ${gpgkey}",
    unless  => "test -f ${gpgkey}; if [ $? == '0' ]; then test -s ${gpgkey}; fi",
    path    => '/bin:/usr/bin:/sbin:/usr/sbin',
  }

  # ie: wget http://yum.domain.tld/keys/RPM-GPG-KEY-CUSTOMREPO-5-8 -O /etc/pki/rpm-gpg/RPM-GPG-KEY-CUSTOMREPO-5-8
  exec { "yum_wget_gpgkey_for_${name}_repo":
    command => "wget ${gpgkey_url} -O ${gpgkey}",
    creates => $gpgkey,
    path    => $wget_path,
    notify  => Exec["yum_rpm_import_${name}_gpgkey"],
    require => Exec["remove_if_empty-${gpgkey}"],
  }

  # import GPG key
  exec { "yum_rpm_import_${name}_gpgkey":
    command     => "rpm --import ${gpgkey}",
    refreshonly => true,
    path        => $rpm_path,
  }
}