Skip to content

Commit

Permalink
post-merge fixes for RPM repo, refs #14
Browse files Browse the repository at this point in the history
* allow "CentOS" repos to be used for other RHEL-flavors
* do not limit to x86_64 architecture
* replace legacy facts
* do not manually import GPG key (dnf/yum does this automatically)
  • Loading branch information
Frank Wall committed May 16, 2023
1 parent 522f24d commit a6d2df6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 26 deletions.
8 changes: 4 additions & 4 deletions manifests/repo/apt_stable.pp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Class: rspamd::repo::apt_stable
# =============
# @summary Includes the rspamd.com/apt-stable APT repository
# This replicates the instructions on the rspamd site:
# https://rspamd.com/downloads.html
#
# @summary includes the rspamd.com/apt-stable apt repo
# @note PRIVATE CLASS: do not use directly
# @see rspamd::repo
#
# @api private
class rspamd::repo::apt_stable {
assert_private()
include rspamd
Expand Down
35 changes: 13 additions & 22 deletions manifests/repo/rpm_stable.pp
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
# Class: rspamd::repo::rpm_stable
# =============
# @summary Includes the rspamd.com/rpm-stable RPM repository
#
# This replicates the instructions on the rspamd site:
# https://rspamd.com/downloads.html
#
# @summary includes the rspamd.com/rpm-stable rpm repo
# @note PRIVATE CLASS: do not use directly
# @see rspamd::repo
#
class rspamd::repo::rpm_stable inherits rspamd::repo {
# Here we have tried to replicate the instructions on the rspamd site:
#
# https://rspamd.com/downloads.html
#
# @api private
class rspamd::repo::rpm_stable {
assert_private()
include rspamd

if $::operatingsystem in ['CentOS', 'Fedora'] {
$_osname = downcase($::operatingsystem)
$default_baseurl = "http://rspamd.com/rpm-stable/${_osname}-${::operatingsystemmajrelease}/x86_64/"
if ($facts['os']['distro']['id'] == 'Fedora') {
$_osname = downcase($facts['os']['distro']['id'])
} else {
fail("Unsupported managed repository for osfamily: ${::osfamily}, operatingsystem: ${::operatingsystem}, module ${module_name} currently only supports managing repos for operatingsystem Fedora and CentOS")
$_osname = 'centos'
}
$default_baseurl = "http://rspamd.com/rpm-stable/${_osname}-${facts['os']['release']['major']}/{facts['os']['hardware']}/"

$_baseurl = pick($rspamd::repo_baseurl, $default_baseurl)

Expand All @@ -29,13 +28,5 @@
repo_gpgcheck => '1',
}

exec { 'import rspamd gpg key':
path => '/bin:/usr/bin:/sbin:/usr/sbin',
command => 'rpm --import https://rspamd.com/rpm-stable/gpg.key',
unless => 'rpm -q gpg-pubkey-`curl -s https://rspamd.com/rpm-stable/gpg.key | gpg --throw-keyids | cut --characters=12-19 | tr [A-Z] [a-z] | head -n 1`',
logoutput => 'on_failure',
}

Yumrepo['rspamd'] -> Exec['import rspamd gpg key'] -> Package<|tag == 'rspamd'|>

Yumrepo['rspamd'] -> Package<|tag == 'rspamd'|>
}

0 comments on commit a6d2df6

Please sign in to comment.