Defined Type: systemd::service_limits
- Defined in:
- manifests/service_limits.pp
Overview
Deprecated - Adds a set of custom limits to the service
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'manifests/service_limits.pp', line 32
define systemd::service_limits (
Enum['present', 'absent', 'file'] $ensure = 'present',
Stdlib::Absolutepath $path = '/etc/systemd/system',
Boolean $selinux_ignore_defaults = false,
Optional[Systemd::ServiceLimits] $limits = undef,
Optional[String] $source = undef,
Boolean $restart_service = false,
) {
if $restart_service {
fail('The restart_service parameter is deprecated and only false is a valid value')
}
include systemd
if $name !~ Pattern['^.+\.(service|socket|mount|swap)$'] {
fail('$name must match Pattern["^.+\.(service|socket|mount|swap)$"]')
}
if $ensure != 'absent' {
if ($limits and !empty($limits)) and $source {
fail('You may not supply both limits and source parameters to systemd::service_limits')
}
elsif ($limits == undef or empty($limits)) and ($source == undef) {
fail('You must supply either the limits or source parameter to systemd::service_limits')
}
}
if $limits {
# Some typing changed between Systemd::ServiceLimits and Systemd::Unit::Service
$_now_tupled = [
'IODeviceWeight',
'IOReadBandwidthMax',
'IOWriteBandwidthMax',
'IOReadIOPSMax',
'IOWriteIOPSMax',
]
$_my_limits = $limits.map | $_directive, $_value | {
if $_directive in $_now_tupled {
{ $_directive => $_value.map | $_pair | { Array($_pair).flatten } } # Convert { 'a' => 'b' } to ['a', b']
} else {
{ $_directive => $_value }
}
}.reduce | $_memo, $_value | { $_memo + $_value }
deprecation("systemd::servicelimits - ${title}",'systemd::servicelimits is deprecated, use systemd::manage_dropin')
systemd::manage_dropin { "${name}-90-limits.conf":
ensure => $ensure,
unit => $name,
filename => '90-limits.conf',
path => $path,
selinux_ignore_defaults => $selinux_ignore_defaults,
service_entry => $_my_limits,
notify_service => true,
}
} else {
deprecation("systemd::servicelimits ${title}",'systemd::servicelimits is deprecated, use systemd::dropin_file or systemd::manage_dropin')
systemd::dropin_file { "${name}-90-limits.conf":
ensure => $ensure,
unit => $name,
filename => '90-limits.conf',
path => $path,
selinux_ignore_defaults => $selinux_ignore_defaults,
source => $source,
notify_service => true,
}
}
}
|