Skip to content

Commit

Permalink
Add official support for CentOS/RHEL 8
Browse files Browse the repository at this point in the history
This change makes CentOS 8 and RHEL 8 as a suppotrted OS. For CentOS 8
RabbitMQ package is not available in EPEL and PackageCloud repos should
be used instead.
This change adds support for additional erlang repository so that users
can install rabbitmq correctly without missing dependencies.

[1] https://www.rabbitmq.com/install-rpm.html
  • Loading branch information
kajinamit committed Mar 13, 2022
1 parent 326a63c commit 9f132dc
Show file tree
Hide file tree
Showing 16 changed files with 123 additions and 86 deletions.
3 changes: 3 additions & 0 deletions data/family/RedHat.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
---
rabbitmq::python_package: 'python3'
rabbitmq::package_name: 'rabbitmq-server'
rabbitmq::service_name: 'rabbitmq-server'
rabbitmq::package_gpg_key: 'https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey'
rabbitmq::erlang_package_gpg_key: 'https://packagecloud.io/rabbitmq/erlang/gpgkey'
rabbitmq::rabbitmq_release_gpg_key: 'https:/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc'
13 changes: 13 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,14 @@
# 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 erlang_package_gpg_key
# RPM package GPG key to import for erlang packages. Uses source method. This is currently used by RedHat OS Family
# only and should be a file name. Set to https://packagecloud.io/rabbitmq/erlang/gpgkey for RedHat OS Faimily by
# default.
# @param rabbitmq_release_gpg_key
# Primary RabbitMQ signing key. Uses source method. This is currently used by RedHat OS Family only and should be
# a file name. Set to https:/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc
# for RedHat OS Faimily by default.
# @param package_name
# Name(s) of the package(s) to install
# @param port
Expand Down Expand Up @@ -355,6 +363,8 @@
Optional[Variant[Numeric, String]] $package_apt_pin = undef,
String $package_ensure = 'installed',
Optional[String] $package_gpg_key = undef,
Optional[String] $erlang_package_gpg_key = undef,
Optional[String] $rabbitmq_release_gpg_key = undef,
Variant[String, Array] $package_name = 'rabbitmq',
Optional[String] $package_source = undef,
Optional[String] $package_provider = undef,
Expand Down Expand Up @@ -475,6 +485,9 @@
'RedHat': {
contain rabbitmq::repo::rhel
Class['rabbitmq::repo::rhel'] -> Class['rabbitmq::install']

contain rabbitmq::repo::rhel::erlang
Class['rabbitmq::repo::rhel::erlang'] -> Class['rabbitmq::install']
}
'Debian': {
contain rabbitmq::repo::apt
Expand Down
12 changes: 9 additions & 3 deletions manifests/repo/rhel.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
#
# @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 $key_source = $rabbitmq::package_gpg_key,
String $rabbitmq_key_source = $rabbitmq::rabbitmq_release_gpg_key,
) {
yumrepo { 'rabbitmq':
ensure => present,
name => 'rabbitmq_rabbitmq-server',
baseurl => $location,
gpgkey => $key_source,
gpgkey => "${key_source} ${rabbitmq_key_source}",
enabled => 1,
gpgcheck => 1,
}
Expand All @@ -20,4 +21,9 @@
path => ['/bin','/usr/bin','/sbin','/usr/sbin'],
unless => 'rpm -q gpg-pubkey-6026dfca-573adfde 2>/dev/null',
}

ensure_resource('exec', "rpm --import ${rabbitmq_key_source}", {
'path' => ['/bin','/usr/bin','/sbin','/usr/sbin'],
'unless'=> 'rpm -q gpg-pubkey-6026dfca-573adfde 2>/dev/null',
})
}
29 changes: 29 additions & 0 deletions manifests/repo/rhel/erlang.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Makes sure that the Packagecloud repo for erlang is installed
#
# @api private
class rabbitmq::repo::rhel::erlang (
$location = "https://packagecloud.io/rabbitmq/erlang/el/${facts['os'][release][major]}/\$basearch",
String $key_source = $rabbitmq::erlang_package_gpg_key,
String $rabbitmq_key_source = $rabbitmq::rabbitmq_release_gpg_key,
) {
yumrepo { 'rabbitmq-erlang':
ensure => present,
name => 'rabbitmq_rabbitmq-erlang',
baseurl => $location,
gpgkey => "${key_source} ${rabbitmq_key_source}",
enabled => 1,
gpgcheck => 1,
}

# This may still be needed to prevent warnings
# packagecloud key is gpg-pubkey-df309a0b-5bbb8d6e
exec { "rpm --import ${key_source}":
path => ['/bin','/usr/bin','/sbin','/usr/sbin'],
unless => 'rpm -q gpg-pubkey-df309a0b-5bbb8d6e 2>/dev/null',
}

ensure_resource('exec', "rpm --import ${rabbitmq_key_source}", {
'path' => ['/bin','/usr/bin','/sbin','/usr/sbin'],
'unless'=> 'rpm -q gpg-pubkey-6026dfca-573adfde 2>/dev/null',
})
}
6 changes: 4 additions & 2 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"7"
"7",
"8"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"7"
"7",
"8"
]
},
{
Expand Down
30 changes: 13 additions & 17 deletions spec/acceptance/class_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
service_name = 'rabbitmq'
end

repos_ensure = (fact('os.family') == 'RedHat')

context 'default class inclusion' do
let(:pp) do
<<-EOS
class { 'rabbitmq': }
if $facts['os']['family'] == 'RedHat' {
class { 'erlang': epel_enable => true}
Class['erlang'] -> Class['rabbitmq']
class { 'rabbitmq':
repos_ensure => #{repos_ensure},
}
EOS
end
Expand Down Expand Up @@ -56,12 +56,9 @@ class { 'erlang': epel_enable => true}
let(:pp) do
<<-EOS
class { 'rabbitmq':
repos_ensure => #{repos_ensure},
service_ensure => 'stopped',
}
if $facts['os']['family'] == 'RedHat' {
class { 'erlang': epel_enable => true}
Class['erlang'] -> Class['rabbitmq']
}
EOS
end

Expand All @@ -76,21 +73,16 @@ class { 'erlang': epel_enable => true}
context 'service is unmanaged' do
it 'runs successfully' do
pp_pre = <<-EOS
class { 'rabbitmq': }
if $facts['os']['family'] == 'RedHat' {
class { 'erlang': epel_enable => true}
Class['erlang'] -> Class['rabbitmq']
class { 'rabbitmq':
repos_ensure => #{repos_ensure},
}
EOS

pp = <<-EOS
class { 'rabbitmq':
repos_ensure => #{repos_ensure},
service_manage => false,
service_ensure => 'stopped',
}
if $facts['os']['family'] == 'RedHat' {
class { 'erlang': epel_enable => true}
Class['erlang'] -> Class['rabbitmq']
service_ensure => 'stopped',
}
EOS

Expand All @@ -108,6 +100,7 @@ class { 'erlang': epel_enable => true}
let(:pp) do
<<-EOS
class { 'rabbitmq':
repos_ensure => #{repos_ensure},
service_manage => true,
port => 5672,
admin_enable => true,
Expand Down Expand Up @@ -138,6 +131,7 @@ class { 'rabbitmq':
let(:pp) do
<<-EOS
class { 'rabbitmq':
repos_ensure => #{repos_ensure},
service_manage => true,
port => 5672,
admin_enable => true,
Expand Down Expand Up @@ -169,6 +163,7 @@ class { 'rabbitmq':
let(:pp) do
<<-EOS
class { 'rabbitmq':
repos_ensure => #{repos_ensure},
service_manage => true,
admin_enable => true,
node_ip_address => '0.0.0.0',
Expand Down Expand Up @@ -198,6 +193,7 @@ class { 'rabbitmq':
let(:pp) do
<<-EOS
class { 'rabbitmq':
repos_ensure => #{repos_ensure},
service_manage => true,
port => 5672,
admin_enable => true,
Expand Down
12 changes: 4 additions & 8 deletions spec/acceptance/clustering_spec.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
require 'spec_helper_acceptance'

describe 'rabbitmq clustering' do
repos_ensure = (fact('os.family') == 'RedHat')

context 'rabbitmq::wipe_db_on_cookie_change => false' do
it 'runs successfully' do
pp = <<-EOS
class { 'rabbitmq':
repos_ensure => #{repos_ensure},
cluster => { 'name' => 'rabbit_cluster', 'init_node' => $facts['fqdn'] },
config_cluster => true,
cluster_nodes => ['rabbit1', 'rabbit2'],
Expand All @@ -13,10 +16,6 @@ class { 'rabbitmq':
erlang_cookie => 'TESTCOOKIE',
wipe_db_on_cookie_change => false,
}
if $facts['os']['family'] == 'RedHat' {
class { 'erlang': epel_enable => true}
Class['erlang'] -> Class['rabbitmq']
}
EOS

apply_manifest(pp, expect_failures: true)
Expand All @@ -30,6 +29,7 @@ class { 'erlang': epel_enable => true}
it 'runs successfully' do
pp = <<-EOS
class { 'rabbitmq':
repos_ensure => #{repos_ensure},
cluster => { 'name' => 'rabbit_cluster', 'init_node' => $facts['fqdn'] },
config_cluster => true,
cluster_nodes => ['rabbit1', 'rabbit2'],
Expand All @@ -38,10 +38,6 @@ class { 'rabbitmq':
erlang_cookie => 'TESTCOOKIE',
wipe_db_on_cookie_change => true,
}
if $facts['os']['family'] == 'RedHat' {
class { 'erlang': epel_enable => true}
Class['erlang'] -> Class['rabbitmq']
}
EOS

apply_manifest(pp, catch_failures: true)
Expand Down
7 changes: 3 additions & 4 deletions spec/acceptance/delete_guest_user_spec.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
require 'spec_helper_acceptance'

describe 'rabbitmq with delete_guest_user' do
repos_ensure = (fact('os.family') == 'RedHat')

context 'delete_guest_user' do
it 'runs successfully' do
pp = <<-EOS
class { 'rabbitmq':
repos_ensure => #{repos_ensure},
port => 5672,
delete_guest_user => true,
}
if $facts['os']['family'] == 'RedHat' {
class { 'erlang': epel_enable => true}
Class['erlang'] -> Class['rabbitmq']
}
EOS

apply_manifest(pp, catch_failures: true)
Expand Down
7 changes: 3 additions & 4 deletions spec/acceptance/parameter_spec.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
require 'spec_helper_acceptance'

describe 'rabbitmq parameter on a vhost:' do
repos_ensure = (fact('os.family') == 'RedHat')

context 'create parameter resource' do
it 'runs successfully' do
pp = <<-EOS
if $facts['os']['family'] == 'RedHat' {
class { 'erlang': epel_enable => true }
Class['erlang'] -> Class['rabbitmq']
}
class { 'rabbitmq':
repos_ensure => #{repos_ensure},
service_manage => true,
port => 5672,
delete_guest_user => true,
Expand Down
7 changes: 3 additions & 4 deletions spec/acceptance/policy_spec.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
require 'spec_helper_acceptance'

describe 'rabbitmq policy on a vhost:' do
repos_ensure = (fact('os.family') == 'RedHat')

context 'create policy resource' do
it 'runs successfully' do
pp = <<-EOS
if $facts['os']['family'] == 'RedHat' {
class { 'erlang': epel_enable => true }
Class['erlang'] -> Class['rabbitmq']
}
class { 'rabbitmq':
repos_ensure => #{repos_ensure},
service_manage => true,
port => 5672,
delete_guest_user => true,
Expand Down
17 changes: 5 additions & 12 deletions spec/acceptance/queue_spec.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
require 'spec_helper_acceptance'

describe 'rabbitmq binding:' do
repos_ensure = (fact('os.family') == 'RedHat')

context 'create binding and queue resources when using default management port' do
it 'runs successfully' do
pp = <<-EOS
if $facts['os']['family'] == 'RedHat' {
class { 'erlang': epel_enable => true }
Class['erlang'] -> Class['rabbitmq']
}
class { 'rabbitmq':
repos_ensure => #{repos_ensure},
service_manage => true,
port => 5672,
delete_guest_user => true,
Expand Down Expand Up @@ -78,11 +77,8 @@ class { 'rabbitmq':
context 'create multiple bindings when same source / destination / vhost but different routing keys' do
it 'runs successfully' do
pp = <<-EOS
if $facts['os']['family'] == 'RedHat' {
class { 'erlang': epel_enable => true }
Class['erlang'] -> Class['rabbitmq']
}
class { 'rabbitmq':
repos_ensure => #{repos_ensure},
service_manage => true,
port => 5672,
delete_guest_user => true,
Expand Down Expand Up @@ -166,11 +162,8 @@ class { 'rabbitmq':
context 'create binding and queue resources when using a non-default management port' do
it 'runs successfully' do
pp = <<-EOS
if $facts['os']['family'] == 'RedHat' {
class { 'erlang': epel_enable => true }
Class['erlang'] -> Class['rabbitmq']
}
class { 'rabbitmq':
repos_ensure => #{repos_ensure},
service_manage => true,
port => 5672,
management_port => 11111,
Expand Down
Loading

0 comments on commit 9f132dc

Please sign in to comment.