|
1 |
| -# Adds a set of custom limits to the service |
| 1 | +# Deprecated - Adds a set of custom limits to the service |
2 | 2 | #
|
3 | 3 | # @api public
|
4 | 4 | #
|
|
47 | 47 | fail('$name must match Pattern["^.+\.(service|socket|mount|swap)$"]')
|
48 | 48 | }
|
49 | 49 |
|
50 |
| - if $limits and !empty($limits) { |
51 |
| - $_content = template("${module_name}/limits.erb") |
52 |
| - } |
53 |
| - else { |
54 |
| - $_content = undef |
55 |
| - } |
56 |
| - |
57 | 50 | if $ensure != 'absent' {
|
58 | 51 | if ($limits and !empty($limits)) and $source {
|
59 | 52 | fail('You may not supply both limits and source parameters to systemd::service_limits')
|
|
63 | 56 | }
|
64 | 57 | }
|
65 | 58 |
|
66 |
| - systemd::dropin_file { "${name}-90-limits.conf": |
67 |
| - ensure => $ensure, |
68 |
| - unit => $name, |
69 |
| - filename => '90-limits.conf', |
70 |
| - path => $path, |
71 |
| - selinux_ignore_defaults => $selinux_ignore_defaults, |
72 |
| - content => $_content, |
73 |
| - source => $source, |
74 |
| - notify_service => true, |
| 59 | + if $limits { |
| 60 | + # Some typing changed between Systemd::ServiceLimits and Systemd::Unit::Service |
| 61 | + $_now_tupled = [ |
| 62 | + 'IODeviceWeight', |
| 63 | + 'IOReadBandwidthMax', |
| 64 | + 'IOWriteBandwidthMax', |
| 65 | + 'IOReadIOPSMax', |
| 66 | + 'IOWriteIOPSMax', |
| 67 | + ] |
| 68 | + |
| 69 | + $_my_limits = $limits.map | $_directive, $_value | { |
| 70 | + if $_directive in $_now_tupled { |
| 71 | + { $_directive => $_value.map | $_pair | { Array($_pair).flatten } } # Convert { 'a' => 'b' } to ['a', b'] |
| 72 | + } else { |
| 73 | + { $_directive => $_value } |
| 74 | + } |
| 75 | + }.reduce | $_memo, $_value | { $_memo + $_value } |
| 76 | + |
| 77 | + deprecation("systemd::servicelimits - ${title}",'systemd::servicelimits is deprecated, use systemd::manage_dropin') |
| 78 | + systemd::manage_dropin { '#{name}-90-limits.conf': |
| 79 | + ensure => $ensure, |
| 80 | + unit => $name, |
| 81 | + filename => '90-limits.conf', |
| 82 | + path => $path, |
| 83 | + selinux_ignore_defaults => $selinux_ignore_defaults, |
| 84 | + service_entry => $_my_limits, |
| 85 | + notify_service => true, |
| 86 | + } |
| 87 | + } else { |
| 88 | + deprecation("systemd::servicelimits ${title}",'systemd::servicelimits is deprecated, use systemd::dropin_file or systemd::manage_dropin') |
| 89 | + systemd::dropin_file { '#{name}-90-limits.conf': |
| 90 | + ensure => $ensure, |
| 91 | + unit => $name, |
| 92 | + filename => '90-limits.conf', |
| 93 | + path => $path, |
| 94 | + selinux_ignore_defaults => $selinux_ignore_defaults, |
| 95 | + source => $source, |
| 96 | + notify_service => true, |
| 97 | + } |
75 | 98 | }
|
76 | 99 | }
|
0 commit comments