Skip to content

Commit

Permalink
replace systemd fact with core fact
Browse files Browse the repository at this point in the history
  • Loading branch information
bastelfreak committed Jun 12, 2024
1 parent 381dcc0 commit 443541f
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 17 deletions.
2 changes: 1 addition & 1 deletion REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,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 systemd
Set rabbitmq file ulimit. Defaults to 16384. Only available on Linux

Default value: `16384`

Expand Down
2 changes: 1 addition & 1 deletion manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@
}
}
if $facts['systemd'] { # systemd fact provided by systemd module
if $facts['kernel'] == 'Linux' {
systemd::manage_dropin { 'service-90-limits.conf':
unit => "${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 systemd
# Set rabbitmq file ulimit. Defaults to 16384. Only available on Linux
# @param oom_score_adj
# Set rabbitmq-server process OOM score. Defaults to 0.
# @param heartbeat
Expand Down
3 changes: 0 additions & 3 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,5 @@
hasrestart => true,
name => $service_name,
}
if $facts['systemd'] and defined(Class['systemd::systemctl::daemon_reload']) {
Class['systemd::systemctl::daemon_reload'] -> Service['rabbitmq-server']
}
}
}
15 changes: 4 additions & 11 deletions spec/classes/rabbitmq_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
end

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

selinux_ignore_defaults = os_facts[:os]['family'] == 'RedHat'
Expand All @@ -143,7 +143,7 @@
end

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

it { is_expected.to contain_systemd__manage_dropin('service-90-limits.conf').with_service_entry({ 'LimitNOFILE' => 16_384, 'OOMScoreAdjust' => value }) }
Expand All @@ -160,11 +160,11 @@
end
end

context 'on systems with systemd', if: os_facts['systemd'] do
context 'on Linux', if: os_facts[:kernel] == 'Linux' do
it { is_expected.to contain_systemd__manage_dropin('service-90-limits.conf') }
end

context 'on systems without systemd', unless: os_facts['systemd'] do
context 'on non-Linux', unless: os_facts[:kernel] == 'Linux' do
it { is_expected.not_to contain_systemd__manage_dropin('service-90-limits.conf') }
end

Expand Down Expand Up @@ -1747,13 +1747,6 @@
}
end

context 'on systems with systemd', if: os_facts[:systemd] do
it do
is_expected.to contain_service('rabbitmq-server').
that_requires('Class[systemd::systemctl::daemon_reload]')
end
end

describe 'service with ensure stopped' do
let :params do
{ service_ensure: 'stopped' }
Expand Down

0 comments on commit 443541f

Please sign in to comment.