Skip to content

Commit e681042

Browse files
authored
Merge pull request #1044 from LangJV/master
(#1043) - Add support for any necessary systemd system parameters via hash input
2 parents 15427f2 + 8c6987a commit e681042

File tree

4 files changed

+72
-4
lines changed

4 files changed

+72
-4
lines changed

REFERENCE.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,27 @@ class { 'rabbitmq':
136136
}
137137
```
138138

139+
##### Change RabbitMQ service startup timeout via SystemD to 20 minutes (1200 seconds) :
140+
141+
```puppet
142+
class { 'rabbitmq':
143+
systemd_additional_service_parameters => {
144+
'TimeoutStartSec' => 1200,
145+
}
146+
}
147+
```
148+
149+
##### Change multiple RabbitMQ service startup parameters via SystemD:
150+
151+
```puppet
152+
class { 'rabbitmq':
153+
systemd_additional_service_parameters => {
154+
'TimeoutStartSec' => 1200,
155+
'TimeoutStopSec' => 1200,
156+
}
157+
}
158+
```
159+
139160
##### Change Erlang Kernel Config Variables in rabbitmq.config
140161

141162
```puppet
@@ -225,6 +246,7 @@ The following parameters are available in the `rabbitmq` class:
225246
* [`environment_variables`](#-rabbitmq--environment_variables)
226247
* [`erlang_cookie`](#-rabbitmq--erlang_cookie)
227248
* [`file_limit`](#-rabbitmq--file_limit)
249+
* [`systemd_additional_service_parameters`](#-rabbitmq--systemd_additional_service_parameters)
228250
* [`oom_score_adj`](#-rabbitmq--oom_score_adj)
229251
* [`heartbeat`](#-rabbitmq--heartbeat)
230252
* [`inetrc_config`](#-rabbitmq--inetrc_config)
@@ -565,6 +587,15 @@ Set rabbitmq file ulimit. Defaults to 16384. Only available on Linux
565587

566588
Default value: `16384`
567589

590+
##### <a name="-rabbitmq--systemd_additional_service_parameters"></a>`systemd_additional_service_parameters`
591+
592+
Data type: `Hash`
593+
594+
Hash of additional systemd service parameters which are appended to the dropin file. No validation is done, this is passed verbotem to the systemd dropin module.
595+
Defaults to {}. Only available on Linux
596+
597+
Default value: `{}`
598+
568599
##### <a name="-rabbitmq--oom_score_adj"></a>`oom_score_adj`
569600

570601
Data type: `Integer[-1000, 1000]`

manifests/config.pp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
$auth_backends = $rabbitmq::auth_backends
9090
$cluster_partition_handling = $rabbitmq::cluster_partition_handling
9191
$file_limit = $rabbitmq::file_limit
92+
$systemd_additional_service_parameters = $rabbitmq::systemd_additional_service_parameters
9293
$oom_score_adj = $rabbitmq::oom_score_adj
9394
$collect_statistics_interval = $rabbitmq::collect_statistics_interval
9495
$ipv6 = $rabbitmq::ipv6
@@ -227,14 +228,16 @@
227228
}
228229
}
229230
231+
# Create our complete hash of all possible systemd dropin values
232+
# When there is a duplicate key, the key in the rightmost hash will "win."
233+
# This order ensures that if we set LimitNOFILE or OOMScoreAdjust "twice" the explicit set one "wins" which is needed for consistency with the other places it's also configured.
234+
$completesystemdpropertieshash = $systemd_additional_service_parameters + { 'LimitNOFILE' => $file_limit, 'OOMScoreAdjust' => $oom_score_adj, }
235+
230236
if $facts['kernel'] == 'Linux' {
231237
systemd::manage_dropin { 'service-90-limits.conf':
232238
unit => "${service_name}.service",
233239
selinux_ignore_defaults => ($facts['os']['family'] == 'RedHat'),
234-
service_entry => {
235-
'LimitNOFILE' => $file_limit,
236-
'OOMScoreAdjust' => $oom_score_adj,
237-
},
240+
service_entry => $completesystemdpropertieshash,
238241
}
239242
}
240243

manifests/init.pp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,20 @@
6565
# }
6666
# }
6767
#
68+
# @example Change RabbitMQ service startup timeout via SystemD to 20 minutes (1200 seconds) :
69+
# class { 'rabbitmq':
70+
# systemd_additional_service_parameters => {
71+
# 'TimeoutStartSec' => 1200,
72+
# }
73+
# }
74+
# @example Change multiple RabbitMQ service startup parameters via SystemD:
75+
# class { 'rabbitmq':
76+
# systemd_additional_service_parameters => {
77+
# 'TimeoutStartSec' => 1200,
78+
# 'TimeoutStopSec' => 1200,
79+
# }
80+
# }
81+
#
6882
# @example Change Erlang Kernel Config Variables in rabbitmq.config
6983
# class { 'rabbitmq':
7084
# port => '5672',
@@ -176,6 +190,9 @@
176190
# to 'False' and set 'erlang_cookie'.
177191
# @param file_limit
178192
# Set rabbitmq file ulimit. Defaults to 16384. Only available on Linux
193+
# @param systemd_additional_service_parameters
194+
# Hash of additional systemd service parameters which are appended to the dropin file. No validation is done, this is passed verbotem to the systemd dropin module.
195+
# Defaults to {}. Only available on Linux
179196
# @param oom_score_adj
180197
# Set rabbitmq-server process OOM score. Defaults to 0.
181198
# @param heartbeat
@@ -470,6 +487,7 @@
470487
Boolean $wipe_db_on_cookie_change = false,
471488
String $cluster_partition_handling = 'ignore',
472489
Variant[Integer[-1],Enum['unlimited'],Pattern[/^(infinity|\d+(:(infinity|\d+))?)$/]] $file_limit = 16384,
490+
Hash $systemd_additional_service_parameters = {},
473491
Integer[-1000, 1000] $oom_score_adj = 0,
474492
Hash $environment_variables = { 'LC_ALL' => 'en_US.UTF-8' },
475493
Hash $config_variables = {},

spec/classes/rabbitmq_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,22 @@
183183
end
184184
end
185185

186+
{ 'TimeoutStartSec' => 1200, 'TimeoutStopSec' => 1200, }.each do |key, value|
187+
context "with systemd_additional_service_parameters => '{ #{key} => #{value}'", if: os_facts['kernel'] == 'Linux' do
188+
let(:params) { { systemd_additional_service_parameters: { key => value } } }
189+
190+
it { is_expected.to contain_systemd__manage_dropin('service-90-limits.conf').with_service_entry({ key => value, 'LimitNOFILE' => 16_384, 'OOMScoreAdjust' => 0 }) }
191+
end
192+
end
193+
194+
{ 'TimeoutStartSec' => 600, 'TimeoutStopSec' => 2400, }.each do |key, value|
195+
context "with systemd_additional_service_parameters => '{ #{key} => #{value}'", if: os_facts['kernel'] == 'Linux' do
196+
let(:params) { { systemd_additional_service_parameters: { key => value } } }
197+
198+
it { is_expected.to contain_systemd__manage_dropin('service-90-limits.conf').with_service_entry({ key => value, 'LimitNOFILE' => 16_384, 'OOMScoreAdjust' => 0 }) }
199+
end
200+
end
201+
186202
context 'on Linux', if: os_facts['kernel'] == 'Linux' do
187203
it { is_expected.to contain_systemd__manage_dropin('service-90-limits.conf') }
188204
end

0 commit comments

Comments
 (0)