Skip to content

Commit

Permalink
Merge pull request voxpupuli#982 from bastelfreak/puppet8
Browse files Browse the repository at this point in the history
systemd: migrate from service_limits->manage_dropin
  • Loading branch information
wyardley authored May 19, 2024
2 parents 7f3da85 + 7c269bc commit be1d148
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 18 deletions.
7 changes: 3 additions & 4 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,13 @@
}
if $facts['systemd'] { # systemd fact provided by systemd module
systemd::service_limits { "${service_name}.service":
systemd::manage_dropin { 'service-90-limits.conf':
unit => "${service_name}.service",
selinux_ignore_defaults => ($facts['os']['family'] == 'RedHat'),
limits => {
service_entry => {
'LimitNOFILE' => $file_limit,
'OOMScoreAdjust' => $oom_score_adj,
},
# The service will be notified when config changes
restart_service => false,
}
}
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
},
{
"name": "puppet/systemd",
"version_requirement": ">= 2.10.0 < 8.0.0"
"version_requirement": ">= 4.0.0 < 8.0.0"
}
],
"tags": [
Expand Down
18 changes: 5 additions & 13 deletions spec/classes/rabbitmq_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,9 @@
selinux_ignore_defaults = os_facts[:os]['family'] == 'RedHat'

it do
is_expected.to contain_systemd__service_limits("#{name}.service").
is_expected.to contain_systemd__manage_dropin('service-90-limits.conf').
with_selinux_ignore_defaults(selinux_ignore_defaults).
with_limits({ 'LimitNOFILE' => value, 'OOMScoreAdjust' => 0 }).
with_restart_service(false)
with_service_entry({ 'LimitNOFILE' => value, 'OOMScoreAdjust' => 0 })
end
end
end
Expand All @@ -147,11 +146,7 @@
context "with oom_score_adj => '#{value}'", if: os_facts['systemd'] do
let(:params) { { oom_score_adj: value } }

it do
is_expected.to contain_systemd__service_limits("#{name}.service").
with_limits({ 'LimitNOFILE' => 16_384, 'OOMScoreAdjust' => value }).
with_restart_service(false)
end
it { is_expected.to contain_systemd__manage_dropin('service-90-limits.conf').with_service_entry({ 'LimitNOFILE' => 16_384, 'OOMScoreAdjust' => value }) }
end
end

Expand All @@ -166,14 +161,11 @@
end

context 'on systems with systemd', if: os_facts['systemd'] do
it do
is_expected.to contain_systemd__service_limits("#{name}.service").
with_restart_service(false)
end
it { is_expected.to contain_systemd__manage_dropin('service-90-limits.conf') }
end

context 'on systems without systemd', unless: os_facts['systemd'] do
it { is_expected.not_to contain_systemd__service_limits("#{name}.service") }
it { is_expected.not_to contain_systemd__manage_dropin('service-90-limits.conf') }
end

context 'with admin_enable set to true' do
Expand Down

0 comments on commit be1d148

Please sign in to comment.