Skip to content

(#1043) - Add support for any necessary systemd system parameters via hash input #1044

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,27 @@ class { 'rabbitmq':
}
```

##### Change RabbitMQ service startup timeout via SystemD to 20 minutes (1200 seconds) :

```puppet
class { 'rabbitmq':
systemd_additional_service_parameters => {
'TimeoutStartSec' => 1200,
}
}
```

##### Change multiple RabbitMQ service startup parameters via SystemD:

```puppet
class { 'rabbitmq':
systemd_additional_service_parameters => {
'TimeoutStartSec' => 1200,
'TimeoutStopSec' => 1200,
}
}
```

##### Change Erlang Kernel Config Variables in rabbitmq.config

```puppet
Expand Down Expand Up @@ -225,6 +246,7 @@ The following parameters are available in the `rabbitmq` class:
* [`environment_variables`](#-rabbitmq--environment_variables)
* [`erlang_cookie`](#-rabbitmq--erlang_cookie)
* [`file_limit`](#-rabbitmq--file_limit)
* [`systemd_additional_service_parameters`](#-rabbitmq--systemd_additional_service_parameters)
* [`oom_score_adj`](#-rabbitmq--oom_score_adj)
* [`heartbeat`](#-rabbitmq--heartbeat)
* [`inetrc_config`](#-rabbitmq--inetrc_config)
Expand Down Expand Up @@ -565,6 +587,15 @@ Set rabbitmq file ulimit. Defaults to 16384. Only available on Linux

Default value: `16384`

##### <a name="-rabbitmq--systemd_additional_service_parameters"></a>`systemd_additional_service_parameters`

Data type: `Hash`

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.
Defaults to {}. Only available on Linux

Default value: `{}`

##### <a name="-rabbitmq--oom_score_adj"></a>`oom_score_adj`

Data type: `Integer[-1000, 1000]`
Expand Down
11 changes: 7 additions & 4 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
$auth_backends = $rabbitmq::auth_backends
$cluster_partition_handling = $rabbitmq::cluster_partition_handling
$file_limit = $rabbitmq::file_limit
$systemd_additional_service_parameters = $rabbitmq::systemd_additional_service_parameters
$oom_score_adj = $rabbitmq::oom_score_adj
$collect_statistics_interval = $rabbitmq::collect_statistics_interval
$ipv6 = $rabbitmq::ipv6
Expand Down Expand Up @@ -227,14 +228,16 @@
}
}

# Create our complete hash of all possible systemd dropin values
# When there is a duplicate key, the key in the rightmost hash will "win."
# 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.
$completesystemdpropertieshash = $systemd_additional_service_parameters + { 'LimitNOFILE' => $file_limit, 'OOMScoreAdjust' => $oom_score_adj, }

if $facts['kernel'] == 'Linux' {
systemd::manage_dropin { 'service-90-limits.conf':
unit => "${service_name}.service",
selinux_ignore_defaults => ($facts['os']['family'] == 'RedHat'),
service_entry => {
'LimitNOFILE' => $file_limit,
'OOMScoreAdjust' => $oom_score_adj,
},
service_entry => $completesystemdpropertieshash,
}
}

Expand Down
18 changes: 18 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,20 @@
# }
# }
#
# @example Change RabbitMQ service startup timeout via SystemD to 20 minutes (1200 seconds) :
# class { 'rabbitmq':
# systemd_additional_service_parameters => {
# 'TimeoutStartSec' => 1200,
# }
# }
# @example Change multiple RabbitMQ service startup parameters via SystemD:
# class { 'rabbitmq':
# systemd_additional_service_parameters => {
# 'TimeoutStartSec' => 1200,
# 'TimeoutStopSec' => 1200,
# }
# }
#
# @example Change Erlang Kernel Config Variables in rabbitmq.config
# class { 'rabbitmq':
# port => '5672',
Expand Down Expand Up @@ -176,6 +190,9 @@
# to 'False' and set 'erlang_cookie'.
# @param file_limit
# Set rabbitmq file ulimit. Defaults to 16384. Only available on Linux
# @param systemd_additional_service_parameters
# 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.
# Defaults to {}. Only available on Linux
# @param oom_score_adj
# Set rabbitmq-server process OOM score. Defaults to 0.
# @param heartbeat
Expand Down Expand Up @@ -470,6 +487,7 @@
Boolean $wipe_db_on_cookie_change = false,
String $cluster_partition_handling = 'ignore',
Variant[Integer[-1],Enum['unlimited'],Pattern[/^(infinity|\d+(:(infinity|\d+))?)$/]] $file_limit = 16384,
Hash $systemd_additional_service_parameters = {},
Integer[-1000, 1000] $oom_score_adj = 0,
Hash $environment_variables = { 'LC_ALL' => 'en_US.UTF-8' },
Hash $config_variables = {},
Expand Down
16 changes: 16 additions & 0 deletions spec/classes/rabbitmq_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,22 @@
end
end

{ 'TimeoutStartSec' => 1200, 'TimeoutStopSec' => 1200, }.each do |key, value|
context "with systemd_additional_service_parameters => '{ #{key} => #{value}'", if: os_facts['kernel'] == 'Linux' do
let(:params) { { systemd_additional_service_parameters: { key => value } } }

it { is_expected.to contain_systemd__manage_dropin('service-90-limits.conf').with_service_entry({ key => value, 'LimitNOFILE' => 16_384, 'OOMScoreAdjust' => 0 }) }
end
end

{ 'TimeoutStartSec' => 600, 'TimeoutStopSec' => 2400, }.each do |key, value|
context "with systemd_additional_service_parameters => '{ #{key} => #{value}'", if: os_facts['kernel'] == 'Linux' do
let(:params) { { systemd_additional_service_parameters: { key => value } } }

it { is_expected.to contain_systemd__manage_dropin('service-90-limits.conf').with_service_entry({ key => value, 'LimitNOFILE' => 16_384, 'OOMScoreAdjust' => 0 }) }
end
end

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