Skip to content

Commit 2d62deb

Browse files
committed
Add support for CentOS/RHEL 8
1 parent fd25406 commit 2d62deb

File tree

11 files changed

+159
-24
lines changed

11 files changed

+159
-24
lines changed

.github/SECURITY.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Vox Pupuli Security Policy
2+
3+
Our vulnerabilities reporting process is at https://voxpupuli.org/security/

.sync.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
- set: ubuntu1804-64
99
- set: centos6-64
1010
- set: centos7-64
11+
# RabbitMQ fails to start via systemd unless /sys/fs/cgroup is mounted through from to base host
12+
- set: centos8-64{mount_folders={sysfscgroup={host_path=/sys/fs/cgroup\,container_path=/sys/fs/cgroup\,opts=ro}}}
1113
appveyor.yml:
1214
delete: true
1315
spec/spec_helper.rb:

.travis.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
os: linux
23
dist: bionic
34
language: ruby
45
cache: bundler
@@ -7,7 +8,7 @@ before_install:
78
- bundle --version
89
script:
910
- 'bundle exec rake $CHECK'
10-
matrix:
11+
jobs:
1112
fast_finish: true
1213
include:
1314
- rvm: 2.4.4
@@ -70,6 +71,14 @@ matrix:
7071
bundler_args: --without development release
7172
env: BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_setfile=centos7-64 CHECK=beaker
7273
services: docker
74+
- rvm: 2.5.3
75+
bundler_args: --without development release
76+
env: BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_setfile=centos8-64{mount_folders={sysfscgroup={host_path=/sys/fs/cgroup\,container_path=/sys/fs/cgroup\,opts=ro}}} CHECK=beaker
77+
services: docker
78+
- rvm: 2.5.3
79+
bundler_args: --without development release
80+
env: BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_setfile=centos8-64{mount_folders={sysfscgroup={host_path=/sys/fs/cgroup\,container_path=/sys/fs/cgroup\,opts=ro}}} CHECK=beaker
81+
services: docker
7382
branches:
7483
only:
7584
- master
@@ -84,7 +93,7 @@ notifications:
8493
- "chat.freenode.org#voxpupuli-notifications"
8594
deploy:
8695
provider: puppetforge
87-
user: puppet
96+
username: puppet
8897
password:
8998
secure: "Ojc0h2mbt9Y+eCyiKD+x1iYNONOP27Me63hjo9jo2v1bSs3aiM7djlcpz/sG+jRJ7JQoUyaGzHSn+gvxwWqdagFfFgDmipMKD0OXQinq7upRaG2hR+akKo0jllq9zLjJGBDoxurioKfOzPGlt2bX3UYY5KyeJ3AIM4dwCGVtSh4="
9099
on:

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def location_for(place, fake_version = nil)
1111
end
1212

1313
group :test do
14-
gem 'voxpupuli-test', '>= 1.0.0', :require => false
14+
gem 'voxpupuli-test', '>= 1.4.0', :require => false
1515
gem 'coveralls', :require => false
1616
gem 'simplecov-console', :require => false
1717
end

README.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
4. [Usage - Configuration options and additional functionality](#usage)
1919
5. [Reference - An under-the-hood peek at what the module is doing and how](#reference)
2020
5. [Limitations - OS compatibility, etc.](#limitations)
21-
* [RedHat module dependencies](#redhat-module-dependecies)
2221
6. [Development - Guide for contributing to the module](#development)
2322

2423
## Overview
@@ -54,6 +53,38 @@ You can view example usage in [REFERENCE](REFERENCE.md).
5453

5554
See [REFERENCE](REFERENCE.md).
5655

56+
## Limitations
57+
58+
If running CentOS/RHEL, ensure the `epel` repo, or another repo containing a
59+
suitable Erlang version, is present. On Debian systems, puppetlabs/apt
60+
(>=2.0.0 < 5.0.0) is a soft dependency.
61+
62+
To have a suitable erlang version installed on RedHat and Debian systems,
63+
you have to install another puppet module from https://forge.puppetlabs.com/garethr/erlang with:
64+
65+
puppet module install garethr-erlang
66+
67+
This module handles the packages for erlang.
68+
To use the module, add the following snippet to your site.pp or an appropriate profile class:
69+
70+
For RedHat systems:
71+
```puppet
72+
include 'erlang'
73+
class { 'erlang':
74+
epel_enable => true,
75+
}
76+
```
77+
78+
For Debian systems:
79+
```puppet
80+
include 'erlang'
81+
package { 'erlang-base':
82+
ensure => 'latest',
83+
}
84+
```
85+
86+
This module also depends on voxpupuli/archive to install rabbitmqadmin.
87+
5788
## Development
5889

5990
This module is maintained by [Vox Pupuli](https://voxpupuli.org/). Voxpupuli

data/family/RedHat-8.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
rabbitmq::python_package: 'python3'
3+
rabbitmq::repos_ensure: true

hiera.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ hierarchy:
1010
path: "os/%{facts.os.name}-%{facts.os.release.major}.yaml"
1111
- name: 'Distribution Name'
1212
path: "os/%{facts.os.name}.yaml"
13+
- name: 'Operating System Family Version'
14+
path: "family/%{facts.os.family}-%{facts.os.release.major}.yaml"
1315
- name: 'Operating System Family'
1416
path: "family/%{facts.os.family}.yaml"
1517
- name: 'Common'

lib/puppet/provider/rabbitmq_plugin/rabbitmqplugins.rb

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,30 @@
44
Puppet::Type.type(:rabbitmq_plugin).provide(:rabbitmqplugins, parent: Puppet::Provider::RabbitmqCli) do
55
confine feature: :posix
66

7-
def self.instances
8-
plugin_list = run_with_retries do
9-
rabbitmqplugins('list', '-E', '-m')
7+
def self.plugin_list
8+
list_str = run_with_retries do
9+
# Pass in -e to list both implicitly and explicitly enabled plugins.
10+
# If you pass in -E instead, then only explicitly enabled plugins are listed.
11+
# Implicitly enabled plugins are those that were enabled as a dependency of another plugin/
12+
# If we do not pass in -e then the order if plugin installation matters within the puppet
13+
# code. Example, if Plugin A depends on Plugin B and we install Plugin B first it will
14+
# implicitly enable Plugin A. Then when we go to run Puppet a second time without the
15+
# -e parameter, we won't see Plugin A as being enabled so we'll try to install it again.
16+
# To preserve idempotency we should get all enabled plugins regardless of implicitly or
17+
# explicitly enabled.
18+
rabbitmqplugins('list', '-e', '-m')
1019
end
20+
# Split by newline.
21+
lines = list_str.split(%r{\n})
22+
# Return only lines that are single words because sometimes RabbitMQ likes to output
23+
# information messages. Suppressing those messages via CLI flags is inconsistent between
24+
# versions, so this this regex removes those message without having to use painful
25+
# version switches.
26+
lines.select { |line| line =~ %r{^(\S+)$} }
27+
end
1128

12-
plugin_list.split(%r{\n}).map do |line|
29+
def self.instances
30+
plugin_list.map do |line|
1331
raise Puppet::Error, "Cannot parse invalid plugins line: #{line}" unless line =~ %r{^(\S+)$}
1432
new(name: Regexp.last_match(1))
1533
end
@@ -32,6 +50,6 @@ def destroy
3250
end
3351

3452
def exists?
35-
run_with_retries { rabbitmqplugins('list', '-E', '-m') }.split(%r{\n}).include? resource[:name]
53+
self.class.plugin_list.include? resource[:name]
3654
end
3755
end

metadata.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,16 @@
1212
"operatingsystem": "RedHat",
1313
"operatingsystemrelease": [
1414
"6",
15-
"7"
15+
"7",
16+
"8"
1617
]
1718
},
1819
{
1920
"operatingsystem": "CentOS",
2021
"operatingsystemrelease": [
2122
"6",
22-
"7"
23+
"7",
24+
"8"
2325
]
2426
},
2527
{

spec/classes/rabbitmq_spec.rb

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,13 @@
2929
context 'with default params' do
3030
it { is_expected.not_to contain_class('rabbitmq::repo::apt') }
3131
it { is_expected.not_to contain_apt__source('rabbitmq') }
32-
it { is_expected.not_to contain_class('rabbitmq::repo::rhel') }
33-
it { is_expected.not_to contain_yumrepo('rabbitmq') }
32+
if facts[:os]['family'] == 'RedHat' && facts[:os]['release']['major'] == '8'
33+
it { is_expected.to contain_class('rabbitmq::repo::rhel') }
34+
it { is_expected.to contain_yumrepo('rabbitmq') }
35+
else
36+
it { is_expected.not_to contain_class('rabbitmq::repo::rhel') }
37+
it { is_expected.not_to contain_yumrepo('rabbitmq') }
38+
end
3439
end
3540

3641
context 'with service_restart => false' do
@@ -185,6 +190,19 @@
185190

186191
context 'with service_manage set to true' do
187192
let(:params) { { admin_enable: true, management_ip_address: '1.1.1.1', service_manage: true } }
193+
let(:python_package) do
194+
if %w[Debian SUSE].include?(facts[:os]['family'])
195+
'python'
196+
elsif %w[FreeBSD OpenBSD].include?(facts[:os]['family'])
197+
'python2'
198+
elsif facts[:os]['family'] == 'RedHat'
199+
if facts[:os]['release']['major'] == '8'
200+
'python3'
201+
else
202+
'python'
203+
end
204+
end
205+
end
188206

189207
context 'with rabbitmqadmin_package set to blub' do
190208
let(:params) { { rabbitmqadmin_package: 'blub' } }
@@ -206,12 +224,7 @@
206224
is_expected.to contain_archive('rabbitmqadmin').with_source('http://1.1.1.1:15672/cli/rabbitmqadmin')
207225
end
208226
end
209-
if %w[RedHat Debian SUSE].include?(facts[:os]['family'])
210-
it { is_expected.to contain_package('python') }
211-
end
212-
if %w[FreeBSD OpenBSD].include?(facts[:os]['family'])
213-
it { is_expected.to contain_package('python2') }
214-
end
227+
it { is_expected.to contain_package(python_package) if python_package }
215228
end
216229
context 'with manage_python false' do
217230
let(:params) { { manage_python: false } }
@@ -220,6 +233,7 @@
220233
is_expected.to contain_class('rabbitmq::install::rabbitmqadmin')
221234
is_expected.not_to contain_package('python')
222235
is_expected.not_to contain_package('python2')
236+
is_expected.not_to contain_package('python3')
223237
end
224238
end
225239

0 commit comments

Comments
 (0)