Skip to content

Commit

Permalink
Merge pull request voxpupuli#981 from bastelfreak/cleanup
Browse files Browse the repository at this point in the history
Remove leftovers from Linux systems without systemd
  • Loading branch information
bastelfreak authored May 19, 2024
2 parents b1e4eb1 + 8c318e0 commit 7f3da85
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 82 deletions.
2 changes: 1 addition & 1 deletion REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ Default value: `undef`

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

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

Default value: `16384`

Expand Down
21 changes: 0 additions & 21 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -220,27 +220,6 @@
}
}
case $facts['os']['family'] {
'Debian': {
file { '/etc/default/rabbitmq-server':
ensure => file,
content => epp('rabbitmq/default.epp'),
mode => '0644',
owner => '0',
group => '0',
}
}
'RedHat': {
file { '/etc/security/limits.d/rabbitmq-server.conf':
content => template('rabbitmq/limits.conf'),
owner => '0',
group => '0',
mode => '0644',
}
}
default: {}
}
if $facts['systemd'] { # systemd fact provided by systemd module
systemd::service_limits { "${service_name}.service":
selinux_ignore_defaults => ($facts['os']['family'] == 'RedHat'),
Expand Down
2 changes: 1 addition & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
# set explicitly if using clustering. If you run Pacemaker and you don't want to use RabbitMQ buildin cluster, you can set config_cluster
# to 'False' and set 'erlang_cookie'.
# @param file_limit
# Set rabbitmq file ulimit. Defaults to 16384. Only available on systems with `$::osfamily == 'Debian'` or `$::osfamily == 'RedHat'`.
# Set rabbitmq file ulimit. Defaults to 16384. Only available on systems with systemd
# @param oom_score_adj
# Set rabbitmq-server process OOM score. Defaults to 0.
# @param heartbeat
Expand Down
57 changes: 12 additions & 45 deletions spec/classes/rabbitmq_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,39 +119,16 @@
end

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

if os_facts[:os]['family'] == 'RedHat'
it do
is_expected.to contain_file('/etc/security/limits.d/rabbitmq-server.conf').
with_owner('0').
with_group('0').
with_mode('0644').
that_notifies('Class[Rabbitmq::Service]').
with_content("rabbitmq soft nofile #{value}\nrabbitmq hard nofile #{value}\n")
end
else
it { is_expected.not_to contain_file('/etc/security/limits.d/rabbitmq-server.conf') }
end
selinux_ignore_defaults = os_facts[:os]['family'] == 'RedHat'

if os_facts[:os]['family'] == 'Debian'
it { is_expected.to contain_file('/etc/default/rabbitmq-server').with_content(%r{ulimit -n #{value}}) }
else
it { is_expected.not_to contain_file('/etc/default/rabbitmq-server') }
end

if os_facts['systemd']
selinux_ignore_defaults = os_facts[:os]['family'] == 'RedHat'

it do
is_expected.to contain_systemd__service_limits("#{name}.service").
with_selinux_ignore_defaults(selinux_ignore_defaults).
with_limits({ 'LimitNOFILE' => value, 'OOMScoreAdjust' => 0 }).
with_restart_service(false)
end
else
it { is_expected.not_to contain_systemd__service_limits("#{name}.service") }
it do
is_expected.to contain_systemd__service_limits("#{name}.service").
with_selinux_ignore_defaults(selinux_ignore_defaults).
with_limits({ 'LimitNOFILE' => value, 'OOMScoreAdjust' => 0 }).
with_restart_service(false)
end
end
end
Expand All @@ -167,23 +144,13 @@
end

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

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

if os_facts['systemd']
it do
is_expected.to contain_systemd__service_limits("#{name}.service").
with_limits({ 'LimitNOFILE' => 16_384, 'OOMScoreAdjust' => value }).
with_restart_service(false)
end
else
it { is_expected.not_to contain_systemd__service_limits("#{name}.service") }
it do
is_expected.to contain_systemd__service_limits("#{name}.service").
with_limits({ 'LimitNOFILE' => 16_384, 'OOMScoreAdjust' => value }).
with_restart_service(false)
end
end
end
Expand Down
14 changes: 0 additions & 14 deletions templates/default.epp

This file was deleted.

0 comments on commit 7f3da85

Please sign in to comment.