Skip to content

Commit 4686d02

Browse files
authored
Merge pull request #932 from wyardley/wyardley/freebsd
Support FreeBSD 12 and 13
2 parents 21d5562 + 8f5421a commit 4686d02

File tree

2 files changed

+51
-35
lines changed

2 files changed

+51
-35
lines changed

metadata.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@
3939
]
4040
},
4141
{
42-
"operatingsystem": "FreeBSD"
42+
"operatingsystem": "FreeBSD",
43+
"operatingsystemrelease": [
44+
"12",
45+
"13"
46+
]
4347
},
4448
{
4549
"operatingsystem": "OpenBSD"

spec/classes/rabbitmq_spec.rb

Lines changed: 46 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,34 @@
66
require 'spec_helper'
77

88
describe 'rabbitmq' do
9-
on_supported_os.each do |os, facts|
9+
on_supported_os.each do |os, os_facts|
1010
context "on #{os}" do
1111
let :facts do
12-
facts
12+
os_facts
1313
end
1414

15-
name = case facts[:osfamily]
15+
name = case os_facts[:osfamily]
1616
when 'Archlinux', 'OpenBSD', 'FreeBSD'
1717
'rabbitmq'
1818
else
1919
'rabbitmq-server'
2020
end
2121

22+
rabbitmq_home = case os_facts[:osfamily]
23+
when 'FreeBSD'
24+
'/var/db/rabbitmq'
25+
else
26+
'/var/lib/rabbitmq'
27+
end
28+
2229
it { is_expected.to compile.with_all_deps }
2330
it { is_expected.to contain_class('rabbitmq::install') }
2431
it { is_expected.to contain_class('rabbitmq::config').that_notifies('Class[rabbitmq::service]') }
2532
it { is_expected.to contain_class('rabbitmq::service') }
2633

2734
it { is_expected.to contain_package(name).with_ensure('installed').with_name(name) }
2835

29-
it { is_expected.to contain_package('rabbitmq-server-plugins') } if facts[:os]['family'] == 'Suse'
36+
it { is_expected.to contain_package('rabbitmq-server-plugins') } if os_facts[:os]['family'] == 'Suse'
3037

3138
context 'with default params' do
3239
it { is_expected.not_to contain_class('rabbitmq::repo::apt') }
@@ -44,7 +51,7 @@
4451
context 'with repos_ensure => true' do
4552
let(:params) { { repos_ensure: true } }
4653

47-
if facts[:os]['family'] == 'Debian'
54+
if os_facts[:os]['family'] == 'Debian'
4855
it 'includes rabbitmq::repo::apt' do
4956
is_expected.to contain_class('rabbitmq::repo::apt').
5057
with_key_source('https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey').
@@ -54,7 +61,7 @@
5461
it 'adds a repo with default values' do
5562
is_expected.to contain_apt__source('rabbitmq').
5663
with_ensure('present').
57-
with_location("https://packagecloud.io/rabbitmq/rabbitmq-server/#{facts[:os]['name'].downcase}").
64+
with_location("https://packagecloud.io/rabbitmq/rabbitmq-server/#{os_facts[:os]['name'].downcase}").
5865
with_release(nil).
5966
with_repos('main')
6067
end
@@ -63,7 +70,7 @@
6370
it { is_expected.not_to contain_apt__souce('rabbitmq') }
6471
end
6572

66-
if facts[:os]['family'] == 'RedHat'
73+
if os_facts[:os]['family'] == 'RedHat'
6774
it { is_expected.to contain_class('rabbitmq::repo::rhel') }
6875

6976
it 'the repo should be present, and contain the expected values' do
@@ -78,27 +85,27 @@
7885
end
7986
end
8087

81-
context 'with no pin', if: facts[:os]['family'] == 'Debian' do
88+
context 'with no pin', if: os_facts[:os]['family'] == 'Debian' do
8289
let(:params) { { repos_ensure: true, package_apt_pin: '' } }
8390

8491
describe 'it sets up an apt::source' do
8592
it {
8693
is_expected.to contain_apt__source('rabbitmq').with(
87-
'location' => "https://packagecloud.io/rabbitmq/rabbitmq-server/#{facts[:os]['name'].downcase}",
94+
'location' => "https://packagecloud.io/rabbitmq/rabbitmq-server/#{os_facts[:os]['name'].downcase}",
8895
'repos' => 'main',
8996
'key' => '{"id"=>"8C695B0219AFDEB04A058ED8F4E789204D206F89", "source"=>"https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey", "content"=>nil}'
9097
)
9198
}
9299
end
93100
end
94101

95-
context 'with pin', if: facts[:os]['family'] == 'Debian' do
102+
context 'with pin', if: os_facts[:os]['family'] == 'Debian' do
96103
let(:params) { { repos_ensure: true, package_apt_pin: '700' } }
97104

98105
describe 'it sets up an apt::source and pin' do
99106
it {
100107
is_expected.to contain_apt__source('rabbitmq').with(
101-
'location' => "https://packagecloud.io/rabbitmq/rabbitmq-server/#{facts[:os]['name'].downcase}",
108+
'location' => "https://packagecloud.io/rabbitmq/rabbitmq-server/#{os_facts[:os]['name'].downcase}",
102109
'repos' => 'main',
103110
'key' => '{"id"=>"8C695B0219AFDEB04A058ED8F4E789204D206F89", "source"=>"https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey", "content"=>nil}'
104111
)
@@ -118,7 +125,7 @@
118125
context "with file_limit => '#{value}'" do
119126
let(:params) { { file_limit: value } }
120127

121-
if facts[:os]['family'] == 'RedHat'
128+
if os_facts[:os]['family'] == 'RedHat'
122129
it do
123130
is_expected.to contain_file('/etc/security/limits.d/rabbitmq-server.conf').
124131
with_owner('0').
@@ -131,14 +138,14 @@
131138
it { is_expected.not_to contain_file('/etc/security/limits.d/rabbitmq-server.conf') }
132139
end
133140

134-
if facts[:os]['family'] == 'Debian'
141+
if os_facts[:os]['family'] == 'Debian'
135142
it { is_expected.to contain_file('/etc/default/rabbitmq-server').with_content(%r{ulimit -n #{value}}) }
136143
else
137144
it { is_expected.not_to contain_file('/etc/default/rabbitmq-server') }
138145
end
139146

140-
if facts[:systemd]
141-
selinux_ignore_defaults = facts[:os]['family'] == 'RedHat'
147+
if os_facts[:systemd]
148+
selinux_ignore_defaults = os_facts[:os]['family'] == 'RedHat'
142149

143150
it do
144151
is_expected.to contain_systemd__service_limits("#{name}.service").
@@ -166,13 +173,13 @@
166173
context "with oom_score_adj => '#{value}'" do
167174
let(:params) { { oom_score_adj: value } }
168175

169-
if facts[:os]['family'] == 'Debian'
176+
if os_facts[:os]['family'] == 'Debian'
170177
it { is_expected.to contain_file('/etc/default/rabbitmq-server').with_content(%r{^echo #{value} > /proc/\$\$/oom_score_adj$}) }
171178
else
172179
it { is_expected.not_to contain_file('/etc/default/rabbitmq-server') }
173180
end
174181

175-
if facts[:systemd]
182+
if os_facts[:systemd]
176183
it do
177184
is_expected.to contain_systemd__service_limits("#{name}.service").
178185
with_limits('OOMScoreAdjust' => value).
@@ -194,14 +201,14 @@
194201
end
195202
end
196203

197-
context 'on systems with systemd', if: facts[:systemd] do
204+
context 'on systems with systemd', if: os_facts[:systemd] do
198205
it do
199206
is_expected.to contain_systemd__service_limits("#{name}.service").
200207
with_restart_service(false)
201208
end
202209
end
203210

204-
context 'on systems without systemd', unless: facts[:systemd] do
211+
context 'on systems without systemd', unless: os_facts[:systemd] do
205212
it { is_expected.not_to contain_systemd__service_limits("#{name}.service") }
206213
end
207214

@@ -227,8 +234,8 @@
227234
is_expected.to contain_archive('rabbitmqadmin').with_source('http://1.1.1.1:15672/cli/rabbitmqadmin')
228235
end
229236

230-
it { is_expected.to contain_package('python') } if %w[RedHat Debian SUSE Archlinux].include?(facts[:os]['family'])
231-
it { is_expected.to contain_package('python2') } if %w[FreeBSD OpenBSD].include?(facts[:os]['family'])
237+
it { is_expected.to contain_package('python') } if %w[RedHat Debian SUSE Archlinux].include?(os_facts[:os]['family'])
238+
it { is_expected.to contain_package('python38') } if %w[FreeBSD].include?(os_facts[:os]['family'])
232239
end
233240

234241
context 'with manage_python false' do
@@ -241,7 +248,7 @@
241248
end
242249
end
243250

244-
context 'with $management_ip_address undef and service_manage set to true', unless: facts[:osfamily] == 'Archlinux' do
251+
context 'with $management_ip_address undef and service_manage set to true', unless: os_facts[:osfamily] == 'Archlinux' do
245252
let(:params) { { admin_enable: true, management_ip_address: :undef } }
246253

247254
it 'we enable the admin interface by default' do
@@ -253,7 +260,7 @@
253260
end
254261
end
255262

256-
context 'with service_manage set to true, node_ip_address = undef, and default user/pass specified', unless: facts[:osfamily] == 'Archlinux' do
263+
context 'with service_manage set to true, node_ip_address = undef, and default user/pass specified', unless: os_facts[:osfamily] == 'Archlinux' do
257264
let(:params) { { admin_enable: true, default_user: 'foobar', default_pass: 'hunter2', node_ip_address: :undef } }
258265

259266
it 'we use the correct URL to rabbitmqadmin' do
@@ -265,7 +272,7 @@
265272
end
266273
end
267274

268-
context 'with service_manage set to true and default user/pass specified', unless: facts[:osfamily] == 'Archlinux' do
275+
context 'with service_manage set to true and default user/pass specified', unless: os_facts[:osfamily] == 'Archlinux' do
269276
let(:params) { { admin_enable: true, default_user: 'foobar', default_pass: 'hunter2', management_ip_address: '1.1.1.1' } }
270277

271278
it 'we use the correct URL to rabbitmqadmin' do
@@ -277,7 +284,7 @@
277284
end
278285
end
279286

280-
context 'with service_manage set to true and archive_options set', unless: facts[:osfamily] == 'Archlinux' do
287+
context 'with service_manage set to true and archive_options set', unless: os_facts[:osfamily] == 'Archlinux' do
281288
let(:params) do
282289
{
283290
admin_enable: true,
@@ -294,7 +301,7 @@
294301
end
295302
end
296303

297-
context 'with service_manage set to true and management port specified', unless: facts[:osfamily] == 'Archlinux' do
304+
context 'with service_manage set to true and management port specified', unless: os_facts[:osfamily] == 'Archlinux' do
298305
# NOTE: that the 2.x management port is 55672 not 15672
299306
let(:params) { { admin_enable: true, management_port: 55_672, management_ip_address: '1.1.1.1' } }
300307

@@ -307,7 +314,7 @@
307314
end
308315
end
309316

310-
context 'with ipv6, service_manage set to true and management port specified', unless: facts[:osfamily] == 'Archlinux' do
317+
context 'with ipv6, service_manage set to true and management port specified', unless: os_facts[:osfamily] == 'Archlinux' do
311318
# NOTE: that the 2.x management port is 55672 not 15672
312319
let(:params) { { admin_enable: true, management_port: 55_672, management_ip_address: '::1' } }
313320

@@ -404,7 +411,7 @@
404411
end
405412

406413
it 'contains the rabbitmq_erlang_cookie' do
407-
is_expected.to contain_rabbitmq_erlang_cookie('/var/lib/rabbitmq/.erlang.cookie')
414+
is_expected.to contain_rabbitmq_erlang_cookie("#{rabbitmq_home}/.erlang.cookie")
408415
end
409416
end
410417

@@ -417,7 +424,7 @@
417424
end
418425

419426
it 'contains the rabbitmq_erlang_cookie' do
420-
is_expected.to contain_rabbitmq_erlang_cookie('/var/lib/rabbitmq/.erlang.cookie')
427+
is_expected.to contain_rabbitmq_erlang_cookie("#{rabbitmq_home}/.erlang.cookie")
421428
end
422429
end
423430

@@ -428,8 +435,8 @@
428435
}
429436
end
430437

431-
it 'contains the rabbitmq_erlang_cookie' do
432-
is_expected.not_to contain_rabbitmq_erlang_cookie('/var/lib/rabbitmq/.erlang.cookie')
438+
it 'does not contains the rabbitmq_erlang_cookie' do
439+
is_expected.not_to contain_rabbitmq_erlang_cookie("#{rabbitmq_home}/.erlang.cookie")
433440
end
434441
end
435442

@@ -453,8 +460,13 @@
453460
describe 'rabbitmq-env configuration' do
454461
context 'with default params' do
455462
it 'sets environment variables' do
456-
is_expected.to contain_file('rabbitmq-env.config'). \
457-
with_content(%r{ERL_INETRC=/etc/rabbitmq/inetrc})
463+
if %w[FreeBSD OpenBSD].include?(os_facts[:os]['family'])
464+
is_expected.to contain_file('rabbitmq-env.config'). \
465+
with_content(%r{ERL_INETRC=/usr/local/etc/rabbitmq/inetrc})
466+
else
467+
is_expected.to contain_file('rabbitmq-env.config'). \
468+
with_content(%r{ERL_INETRC=/etc/rabbitmq/inetrc})
469+
end
458470
end
459471
end
460472

@@ -1764,7 +1776,7 @@
17641776
}
17651777
end
17661778

1767-
context 'on systems with systemd', if: facts[:systemd] do
1779+
context 'on systems with systemd', if: os_facts[:systemd] do
17681780
it do
17691781
is_expected.to contain_service('rabbitmq-server').
17701782
that_requires('Class[systemd::systemctl::daemon_reload]')

0 commit comments

Comments
 (0)