Skip to content

Commit

Permalink
Fixing RHEL packagecloud repo to check gpg keys for both the repo and…
Browse files Browse the repository at this point in the history
… the package.
  • Loading branch information
bishopbm1 committed May 23, 2022
1 parent d2dce6e commit 6533503
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 13 deletions.
1 change: 1 addition & 0 deletions data/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ rabbitmq::node_ip_address: ~
rabbitmq::package_apt_pin: ~
rabbitmq::package_ensure: 'installed'
rabbitmq::package_gpg_key: ~
rabbitmq::repo_gpg_key: ~
rabbitmq::package_name: 'rabbitmq'
rabbitmq::package_source: ~
rabbitmq::package_provider: ~
Expand Down
3 changes: 2 additions & 1 deletion data/family/RedHat.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
rabbitmq::package_name: 'rabbitmq-server'
rabbitmq::service_name: 'rabbitmq-server'
rabbitmq::package_gpg_key: 'https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey'
rabbitmq::package_gpg_key: 'https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc'
rabbitmq::repo_gpg_key: 'https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey'
16 changes: 16 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@
# package_gpg_key => 'http://www.some_site.some_domain/some_key.pub.key',
# }
#
# @example Offline installation from local mirror:
# class { 'rabbitmq':
# key_content => template('openstack/rabbit.pub.key'),
# repo_gpg_key => '/tmp/rabbit.pub.key',
# }
#
# @example Use external package key source for any (apt/rpm) package provider:
# class { 'rabbitmq':
# repo_gpg_key => 'http://www.some_site.some_domain/some_key.pub.key',
# }
#
# @example To use RabbitMQ Environment Variables, use the parameters `environment_variables` e.g.:
# class { 'rabbitmq':
# port => '5672',
Expand Down Expand Up @@ -211,6 +222,10 @@
# Determines the ensure state of the package. Set to installed by default, but could be changed to latest.
# @param package_gpg_key
# RPM package GPG key to import. Uses source method. Should be a URL for Debian/RedHat OS family, or a file name for
# RedHat OS family. Set to https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc
# for Debian/RedHat OS Family by default.
# @param repo_gpg_key
# RPM package GPG key to import. Uses source method. Should be a URL for Debian/RedHat OS family, or a file name for
# RedHat OS family. Set to https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey for Debian/RedHat OS Family by
# default. Note, that `key_content`, if specified, would override this parameter for Debian OS family.
# @param package_name
Expand Down Expand Up @@ -355,6 +370,7 @@
Optional[Variant[Numeric, String]] $package_apt_pin = undef,
String $package_ensure = 'installed',
Optional[String] $package_gpg_key = undef,
Optional[String] $repo_gpg_key = undef,
Variant[String, Array] $package_name = 'rabbitmq',
Optional[String] $package_source = undef,
Optional[String] $package_provider = undef,
Expand Down
36 changes: 24 additions & 12 deletions manifests/repo/rhel.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,34 @@
#
# @api private
class rabbitmq::repo::rhel (
$location = "https://packagecloud.io/rabbitmq/rabbitmq-server/el/${facts['os'][release][major]}/\$basearch",
String $key_source = $rabbitmq::package_gpg_key,
$location = "https://packagecloud.io/rabbitmq/rabbitmq-server/el/${facts['os'][release][major]}/\$basearch",
String $repo_key_source = $rabbitmq::repo_gpg_key,
String $package_key_source = $rabbitmq::package_gpg_key,
) {
# Import package key from rabbitmq to be able to
# sign the package and the repo.
# rabbitmq key is gpg-pubkey-6026dfca-573adfde
exec { "rpm --import ${package_key_source}":
path => ['/bin','/usr/bin','/sbin','/usr/sbin'],
unless => 'rpm -q gpg-pubkey-6026dfca-573adfde 2>/dev/null',
before => YumRepo['rabbitmq'],
}

yumrepo { 'rabbitmq':
ensure => present,
name => 'rabbitmq_rabbitmq-server',
baseurl => $location,
gpgkey => $key_source,
enabled => 1,
gpgcheck => 1,
ensure => present,
name => 'rabbitmq_rabbitmq-server',
baseurl => $location,
gpgkey => $repo_key_source,
enabled => 1,
gpgcheck => 1,
repo_gpgcheck => 1,
}

# This may still be needed to prevent warnings
# packagecloud key is gpg-pubkey-d59097ab-52d46e88
exec { "rpm --import ${key_source}":
path => ['/bin','/usr/bin','/sbin','/usr/sbin'],
unless => 'rpm -q gpg-pubkey-6026dfca-573adfde 2>/dev/null',
# packagecloud key is gpg-pubkey-4d206f89-5bbb8d59
exec { "rpm --import ${repo_key_source}":
path => ['/bin','/usr/bin','/sbin','/usr/sbin'],
unless => 'rpm -q gpg-pubkey-4d206f89-5bbb8d59 2>/dev/null',
require => YumRepo['rabbitmq'],
}
}

0 comments on commit 6533503

Please sign in to comment.