Skip to content

Commit 7f3da85

Browse files
authored
Merge pull request #981 from bastelfreak/cleanup
Remove leftovers from Linux systems without systemd
2 parents b1e4eb1 + 8c318e0 commit 7f3da85

File tree

5 files changed

+14
-82
lines changed

5 files changed

+14
-82
lines changed

REFERENCE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ Default value: `undef`
536536

537537
Data type: `Variant[Integer[-1],Enum['unlimited'],Pattern[/^(infinity|\d+(:(infinity|\d+))?)$/]]`
538538

539-
Set rabbitmq file ulimit. Defaults to 16384. Only available on systems with `$::osfamily == 'Debian'` or `$::osfamily == 'RedHat'`.
539+
Set rabbitmq file ulimit. Defaults to 16384. Only available on systems with systemd
540540

541541
Default value: `16384`
542542

manifests/config.pp

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -220,27 +220,6 @@
220220
}
221221
}
222222
223-
case $facts['os']['family'] {
224-
'Debian': {
225-
file { '/etc/default/rabbitmq-server':
226-
ensure => file,
227-
content => epp('rabbitmq/default.epp'),
228-
mode => '0644',
229-
owner => '0',
230-
group => '0',
231-
}
232-
}
233-
'RedHat': {
234-
file { '/etc/security/limits.d/rabbitmq-server.conf':
235-
content => template('rabbitmq/limits.conf'),
236-
owner => '0',
237-
group => '0',
238-
mode => '0644',
239-
}
240-
}
241-
default: {}
242-
}
243-
244223
if $facts['systemd'] { # systemd fact provided by systemd module
245224
systemd::service_limits { "${service_name}.service":
246225
selinux_ignore_defaults => ($facts['os']['family'] == 'RedHat'),

manifests/init.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@
170170
# set explicitly if using clustering. If you run Pacemaker and you don't want to use RabbitMQ buildin cluster, you can set config_cluster
171171
# to 'False' and set 'erlang_cookie'.
172172
# @param file_limit
173-
# Set rabbitmq file ulimit. Defaults to 16384. Only available on systems with `$::osfamily == 'Debian'` or `$::osfamily == 'RedHat'`.
173+
# Set rabbitmq file ulimit. Defaults to 16384. Only available on systems with systemd
174174
# @param oom_score_adj
175175
# Set rabbitmq-server process OOM score. Defaults to 0.
176176
# @param heartbeat

spec/classes/rabbitmq_spec.rb

Lines changed: 12 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -119,39 +119,16 @@
119119
end
120120

121121
['infinity', -1, 1234].each do |value|
122-
context "with file_limit => '#{value}'" do
122+
context "with file_limit => '#{value}'", if: os_facts['systemd'] do
123123
let(:params) { { file_limit: value } }
124124

125-
if os_facts[:os]['family'] == 'RedHat'
126-
it do
127-
is_expected.to contain_file('/etc/security/limits.d/rabbitmq-server.conf').
128-
with_owner('0').
129-
with_group('0').
130-
with_mode('0644').
131-
that_notifies('Class[Rabbitmq::Service]').
132-
with_content("rabbitmq soft nofile #{value}\nrabbitmq hard nofile #{value}\n")
133-
end
134-
else
135-
it { is_expected.not_to contain_file('/etc/security/limits.d/rabbitmq-server.conf') }
136-
end
125+
selinux_ignore_defaults = os_facts[:os]['family'] == 'RedHat'
137126

138-
if os_facts[:os]['family'] == 'Debian'
139-
it { is_expected.to contain_file('/etc/default/rabbitmq-server').with_content(%r{ulimit -n #{value}}) }
140-
else
141-
it { is_expected.not_to contain_file('/etc/default/rabbitmq-server') }
142-
end
143-
144-
if os_facts['systemd']
145-
selinux_ignore_defaults = os_facts[:os]['family'] == 'RedHat'
146-
147-
it do
148-
is_expected.to contain_systemd__service_limits("#{name}.service").
149-
with_selinux_ignore_defaults(selinux_ignore_defaults).
150-
with_limits({ 'LimitNOFILE' => value, 'OOMScoreAdjust' => 0 }).
151-
with_restart_service(false)
152-
end
153-
else
154-
it { is_expected.not_to contain_systemd__service_limits("#{name}.service") }
127+
it do
128+
is_expected.to contain_systemd__service_limits("#{name}.service").
129+
with_selinux_ignore_defaults(selinux_ignore_defaults).
130+
with_limits({ 'LimitNOFILE' => value, 'OOMScoreAdjust' => 0 }).
131+
with_restart_service(false)
155132
end
156133
end
157134
end
@@ -167,23 +144,13 @@
167144
end
168145

169146
[-1000, 0, 1000].each do |value|
170-
context "with oom_score_adj => '#{value}'" do
147+
context "with oom_score_adj => '#{value}'", if: os_facts['systemd'] do
171148
let(:params) { { oom_score_adj: value } }
172149

173-
if os_facts[:os]['family'] == 'Debian'
174-
it { is_expected.to contain_file('/etc/default/rabbitmq-server').with_content(%r{^echo #{value} > /proc/\$\$/oom_score_adj$}) }
175-
else
176-
it { is_expected.not_to contain_file('/etc/default/rabbitmq-server') }
177-
end
178-
179-
if os_facts['systemd']
180-
it do
181-
is_expected.to contain_systemd__service_limits("#{name}.service").
182-
with_limits({ 'LimitNOFILE' => 16_384, 'OOMScoreAdjust' => value }).
183-
with_restart_service(false)
184-
end
185-
else
186-
it { is_expected.not_to contain_systemd__service_limits("#{name}.service") }
150+
it do
151+
is_expected.to contain_systemd__service_limits("#{name}.service").
152+
with_limits({ 'LimitNOFILE' => 16_384, 'OOMScoreAdjust' => value }).
153+
with_restart_service(false)
187154
end
188155
end
189156
end

templates/default.epp

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)