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 Jan 18, 2023
1 parent aa675b8 commit 425cb54
Show file tree
Hide file tree
Showing 15 changed files with 94 additions and 79 deletions.
4 changes: 3 additions & 1 deletion data/family/RedHat.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
rabbitmq::python_package: 'python3'
rabbitmq::package_name: 'rabbitmq-server'
rabbitmq::service_name: 'rabbitmq-server'
rabbitmq::package_gpg_key: 'https:/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc'
rabbitmq::repo_gpg_key: 'https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey'
rabbitmq::repo_gpg_key: 'https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey'
rabbitmq::erlang_repo_gpg_key: 'https://packagecloud.io/rabbitmq/erlang/gpgkey'
8 changes: 8 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@
# 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_repo_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 package_name
# Name(s) of the package(s) to install
# @param port
Expand Down Expand Up @@ -374,6 +378,7 @@
String $package_ensure = 'installed',
Optional[String] $package_gpg_key = undef,
Optional[String] $repo_gpg_key = undef,
Optional[String] $erlang_repo_gpg_key = undef,
Variant[String, Array] $package_name = 'rabbitmq',
Optional[String] $package_source = undef,
Optional[String] $package_provider = undef,
Expand Down Expand Up @@ -494,6 +499,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
23 changes: 23 additions & 0 deletions manifests/repo/rhel/erlang.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 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 $repo_key_source = $rabbitmq::erlang_repo_gpg_key,
) {
yumrepo { 'rabbitmq-erlang':
ensure => present,
name => 'rabbitmq_rabbitmq-erlang',
baseurl => $location,
gpgkey => $repo_key_source,
enabled => 1,
gpgcheck => 1,
}

# This may still be needed to prevent warnings
# packagecloud key is gpg-pubkey-df309a0b-5bbb8d6e
exec { "rpm --import ${repo_key_source}":
path => ['/bin','/usr/bin','/sbin','/usr/sbin'],
unless => 'rpm -q gpg-pubkey-df309a0b-5bbb8d6e 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 @@ -12,13 +12,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 @@ -52,12 +52,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 @@ -72,21 +69,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 @@ -104,6 +96,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 @@ -137,6 +130,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 @@ -172,6 +166,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 @@ -203,6 +198,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
Expand Up @@ -3,10 +3,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 @@ -15,10 +18,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 @@ -33,6 +32,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 @@ -41,10 +41,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
Expand Up @@ -3,17 +3,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
Expand Up @@ -3,14 +3,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
Expand Up @@ -3,14 +3,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
Expand Up @@ -3,14 +3,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 @@ -80,11 +79,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 @@ -168,11 +164,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
22 changes: 6 additions & 16 deletions spec/acceptance/rabbitmqadmin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
require 'spec_helper_acceptance'

describe 'rabbitmq::install::rabbitmqadmin class' do
repos_ensure = (fact('os.family') == 'RedHat')

context 'downloads the cli tools' do
it 'runs successfully' do
pp = <<-EOS
class { 'rabbitmq':
repos_ensure => #{repos_ensure},
admin_enable => true,
service_manage => true,
}
if $facts['os']['family'] == 'RedHat' {
class { 'erlang': epel_enable => true}
Class['erlang'] -> Class['rabbitmq']
}
EOS

apply_manifest(pp, catch_failures: true)
Expand All @@ -28,13 +27,10 @@ class { 'erlang': epel_enable => true}
it 'runs successfully' do
pp = <<-EOS
class { 'rabbitmq':
repos_ensure => #{repos_ensure},
admin_enable => true,
service_manage => false,
}
if $facts['os']['family'] == 'RedHat' {
class { 'erlang': epel_enable => true}
Class['erlang'] -> Class['rabbitmq']
}
EOS

shell('rm -f /var/lib/rabbitmq/rabbitmqadmin')
Expand All @@ -51,27 +47,21 @@ class { 'erlang': epel_enable => true}
# make sure credential change takes effect before admin_enable
pp_pre = <<-EOS
class { 'rabbitmq':
repos_ensure => #{repos_ensure},
service_manage => true,
default_user => 'foobar',
default_pass => 'bazblam',
}
if $facts['os']['family'] == 'RedHat' {
class { 'erlang': epel_enable => true}
Class['erlang'] -> Class['rabbitmq']
}
EOS

pp = <<-EOS
class { 'rabbitmq':
repos_ensure => #{repos_ensure},
admin_enable => true,
service_manage => true,
default_user => 'foobar',
default_pass => 'bazblam',
}
if $facts['os']['family'] == 'RedHat' {
class { 'erlang': epel_enable => true}
Class['erlang'] -> Class['rabbitmq']
}
EOS

shell('rm -f /var/lib/rabbitmq/rabbitmqadmin')
Expand Down
7 changes: 3 additions & 4 deletions spec/acceptance/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
require 'spec_helper_acceptance'

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

context 'create user 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
Loading

0 comments on commit 425cb54

Please sign in to comment.