diff --git a/REFERENCE.md b/REFERENCE.md index 25c5a753..8efa137d 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -38,7 +38,6 @@ * [`systemd::modules_load`](#systemd--modules_load): Creates a modules-load.d drop file * [`systemd::network`](#systemd--network): Creates network config for systemd-networkd * [`systemd::networkd::interface`](#systemd--networkd--interface): This class implements a network interface file for systemd-networkd -* [`systemd::service_limits`](#systemd--service_limits): Deprecated - Adds a set of custom limits to the service * [`systemd::timer`](#systemd--timer): Create a timer and optionally a service unit to execute with the timer unit * [`systemd::timer_wrapper`](#systemd--timer_wrapper): Helper to define timer and accompanying services for a given task (cron like interface). * [`systemd::tmpfile`](#systemd--tmpfile): Creates a systemd tmpfile @@ -163,7 +162,6 @@ * [`Systemd::MachineInfoSettings`](#Systemd--MachineInfoSettings): Matches Systemd machine-info (hostnamectl) file Struct * [`Systemd::OomdSettings`](#Systemd--OomdSettings): Configurations for oomd.conf * [`Systemd::Output`](#Systemd--Output): Defines allowed output values -* [`Systemd::ServiceLimits`](#Systemd--ServiceLimits): Deprecated - Matches Systemd Service Limit Struct * [`Systemd::ServiceManagerSettings`](#Systemd--ServiceManagerSettings): Matches Systemd system.conf/user.conf settings * [`Systemd::SettingEnsure`](#Systemd--SettingEnsure): Defines allowed ensure states for an ini_setting * [`Systemd::Timespan`](#Systemd--Timespan): Defines a timespan type @@ -199,7 +197,6 @@ This module allows triggering systemd commands once for all modules The following parameters are available in the `systemd` class: * [`default_target`](#-systemd--default_target) -* [`service_limits`](#-systemd--service_limits) * [`networks`](#-systemd--networks) * [`timers`](#-systemd--timers) * [`tmpfiles`](#-systemd--tmpfiles) @@ -282,14 +279,6 @@ The default systemd boot target, unmanaged if set to undef. Default value: `undef` -##### `service_limits` - -Data type: `Stdlib::CreateResources` - -Deprecated, use dropin_files - Hash of `systemd::service_limits` resources - -Default value: `{}` - ##### `networks` Data type: `Stdlib::CreateResources` @@ -2077,83 +2066,6 @@ The structure is equal to the 'network' parameter of an interface. Default value: `{}` -### `systemd::service_limits` - -Deprecated - Adds a set of custom limits to the service - -* **See also** - * systemd.exec(5) - -#### Parameters - -The following parameters are available in the `systemd::service_limits` defined type: - -* [`name`](#-systemd--service_limits--name) -* [`ensure`](#-systemd--service_limits--ensure) -* [`path`](#-systemd--service_limits--path) -* [`selinux_ignore_defaults`](#-systemd--service_limits--selinux_ignore_defaults) -* [`limits`](#-systemd--service_limits--limits) -* [`source`](#-systemd--service_limits--source) -* [`restart_service`](#-systemd--service_limits--restart_service) - -##### `name` - -Data type: `Pattern['^.+\.(service|socket|mount|swap)$']` - -The name of the service that you will be modifying - -##### `ensure` - -Data type: `Enum['present', 'absent', 'file']` - -Whether to drop a file or remove it - -Default value: `'present'` - -##### `path` - -Data type: `Stdlib::Absolutepath` - -The path to the main systemd settings directory - -Default value: `'/etc/systemd/system'` - -##### `selinux_ignore_defaults` - -Data type: `Boolean` - -If Puppet should ignore the default SELinux labels. - -Default value: `false` - -##### `limits` - -Data type: `Optional[Systemd::ServiceLimits]` - -A Hash of service limits matching the settings in ``systemd.exec(5)`` - -* Mutually exclusive with ``$source`` - -Default value: `undef` - -##### `source` - -Data type: `Optional[String]` - -A ``File`` resource compatible ``source`` - -* Mutually exclusive with ``$limits`` - -Default value: `undef` - -##### `restart_service` - -Data type: `Boolean` - -Unused parameter for compatibility with older versions. Will fail if true is passed in. - -Default value: `false` - ### `systemd::timer` Create a timer and optionally a service unit to execute with the timer unit @@ -5500,59 +5412,6 @@ Used in DefaultStandardOutput/DefaultStandardError e.g. Alias of `Enum['inherit', 'null', 'tty', 'journal', 'journal+console', 'kmsg', 'kmsg+console']` -### `Systemd::ServiceLimits` - -Deprecated - Matches Systemd Service Limit Struct - -Alias of - -```puppet -Struct[{ - Optional['LimitCPU'] => Pattern['^\d+(s|m|h|d|w|M|y)?(:\d+(s|m|h|d|w|M|y)?)?$'], - Optional['LimitFSIZE'] => Pattern['^(infinity|((\d+(K|M|G|T|P|E)?(:\d+(K|M|G|T|P|E)?)?)))$'], - Optional['LimitDATA'] => Pattern['^(infinity|((\d+(K|M|G|T|P|E)?(:\d+(K|M|G|T|P|E)?)?)))$'], - Optional['LimitSTACK'] => Pattern['^(infinity|((\d+(K|M|G|T|P|E)?(:\d+(K|M|G|T|P|E)?)?)))$'], - Optional['LimitCORE'] => Pattern['^(infinity|((\d+(K|M|G|T|P|E)?(:\d+(K|M|G|T|P|E)?)?)))$'], - Optional['LimitRSS'] => Pattern['^(infinity|((\d+(K|M|G|T|P|E)?(:\d+(K|M|G|T|P|E)?)?)))$'], - Optional['LimitNOFILE'] => Variant[Integer[-1],Pattern['^(infinity|\d+(:(infinity|\d+))?)$']], - Optional['LimitAS'] => Pattern['^(infinity|((\d+(K|M|G|T|P|E)?(:\d+(K|M|G|T|P|E)?)?)))$'], - Optional['LimitNPROC'] => Variant[Integer[-1],Pattern['^(infinity|\d+(:(infinity|\d+))?)$']], - Optional['LimitMEMLOCK'] => Pattern['^(infinity|((\d+(K|M|G|T|P|E)?(:\d+(K|M|G|T|P|E)?)?)))$'], - Optional['LimitLOCKS'] => Integer[1], - Optional['LimitSIGPENDING'] => Integer[1], - Optional['LimitMSGQUEUE'] => Pattern['^(infinity|((\d+(K|M|G|T|P|E)?(:\d+(K|M|G|T|P|E)?)?)))$'], - Optional['LimitNICE'] => Variant[Integer[0,40], Pattern['^(-\+([0-1]?[0-9]|20))|([0-3]?[0-9]|40)$']], - Optional['LimitRTPRIO'] => Integer[0], - Optional['LimitRTTIME'] => Pattern['^\d+(ms|s|m|h|d|w|M|y)?(:\d+(ms|s|m|h|d|w|M|y)?)?$'], - Optional['CPUAccounting'] => Boolean, - Optional['CPUShares'] => Integer[2,262144], - Optional['StartupCPUShares'] => Integer[2,262144], - Optional['CPUQuota'] => Optional[Pattern['^([1-9][0-9]*)%$']], - Optional['MemoryAccounting'] => Boolean, - Optional['MemoryLow'] => Pattern['\A(infinity|\d+(K|M|G|T|%)?(:\d+(K|M|G|T|%)?)?)\z'], - Optional['MemoryMin'] => Pattern['\A(infinity|\d+(K|M|G|T|%)?(:\d+(K|M|G|T|%)?)?)\z'], - Optional['MemoryHigh'] => Pattern['\A(infinity|\d+(K|M|G|T|%)?(:\d+(K|M|G|T|%)?)?)\z'], - Optional['MemoryMax'] => Pattern['\A(infinity|\d+(K|M|G|T|%)?(:\d+(K|M|G|T|%)?)?)\z'], - Optional['MemoryLimit'] => Pattern['\A(infinity|\d+(K|M|G|T|%)?(:\d+(K|M|G|T|%)?)?)\z'], - Optional['MemorySwapMax'] => Pattern['\A(infinity|\d+(K|M|G|T|%)?(:\d+(K|M|G|T|%)?)?)\z'], - Optional['TasksAccounting'] => Boolean, - Optional['TasksMax'] => Variant[Integer[1],Pattern['^(infinity|([1-9][0-9]?$|^100)%)$']], - Optional['IOAccounting'] => Boolean, - Optional['IOWeight'] => Integer[1,10000], - Optional['StartupIOWeight'] => Integer[1,10000], - Optional['IODeviceWeight'] => Array[Hash[Stdlib::Absolutepath, Integer[1,10000], 1, 1]], - Optional['IOReadBandwidthMax'] => Array[Hash[Stdlib::Absolutepath, Pattern['^(\d+(K|M|G|T)?)$'], 1, 1]], - Optional['IOWriteBandwidthMax'] => Array[Hash[Stdlib::Absolutepath, Pattern['^(\d+(K|M|G|T)?)$'], 1, 1]], - Optional['IOReadIOPSMax'] => Array[Hash[Stdlib::Absolutepath, Pattern['^(\d+(K|M|G|T)?)$'], 1, 1]], - Optional['IOWriteIOPSMax'] => Array[Hash[Stdlib::Absolutepath, Pattern['^(\d+(K|M|G|T)?)$'], 1, 1]], - Optional['DeviceAllow'] => String[1], - Optional['DevicePolicy'] => Enum['auto','closed','strict'], - Optional['Slice'] => String[1], - Optional['Delegate'] => Boolean, - Optional['OOMScoreAdjust'] => Integer[-1000,1000] - }] -``` - ### `Systemd::ServiceManagerSettings` NOTE: Systemd::SettingEnsure here allows to delete the setting from the INI diff --git a/manifests/init.pp b/manifests/init.pp index 1258e8ab..cc38a32e 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -5,9 +5,6 @@ # @param default_target # The default systemd boot target, unmanaged if set to undef. # -# @param service_limits -# Deprecated, use dropin_files - Hash of `systemd::service_limits` resources -# # @param networks # Hash of `systemd::network` resources # @@ -263,7 +260,6 @@ class systemd ( Optional[Pattern['^.+\.target$']] $default_target = undef, Hash[String,String] $accounting = {}, - Stdlib::CreateResources $service_limits = {}, Stdlib::CreateResources $networks = {}, Stdlib::CreateResources $timers = {}, Stdlib::CreateResources $tmpfiles = {}, @@ -353,11 +349,6 @@ } } - $service_limits.each |$service_limit, $service_limit_data| { - systemd::service_limits { $service_limit: - * => $service_limit_data, - } - } $networks.each |$network, $network_data| { systemd::network { $network: * => $network_data, diff --git a/manifests/service_limits.pp b/manifests/service_limits.pp deleted file mode 100644 index ca07ad22..00000000 --- a/manifests/service_limits.pp +++ /dev/null @@ -1,99 +0,0 @@ -# Deprecated - Adds a set of custom limits to the service -# -# @api public -# -# @see systemd.exec(5) -# -# @param name [Pattern['^.+\.(service|socket|mount|swap)$']] -# The name of the service that you will be modifying -# -# @param ensure -# Whether to drop a file or remove it -# -# @param path -# The path to the main systemd settings directory -# -# @param selinux_ignore_defaults -# If Puppet should ignore the default SELinux labels. -# -# @param limits -# A Hash of service limits matching the settings in ``systemd.exec(5)`` -# -# * Mutually exclusive with ``$source`` -# -# @param source -# A ``File`` resource compatible ``source`` -# -# * Mutually exclusive with ``$limits`` -# -# @param restart_service -# Unused parameter for compatibility with older versions. Will fail if true is passed in. -# -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::service_limits - ${title}",'systemd::service_limits 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::service_limits ${title}",'systemd::service_limits 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, - } - } -} diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index efe37acb..b3830bc5 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -473,22 +473,6 @@ it { is_expected.to contain_exec('set local hardware clock to UTC time') } end - context 'when passing service limits' do - let(:params) do - { - service_limits: { 'openstack-nova-compute.service' => { 'limits' => { 'LimitNOFILE' => 32_768 } } }, - } - end - - # systemd::service_limits is deprecated - before do - Puppet.settings[:strict] = :warning - end - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_systemd__service_limits('openstack-nova-compute.service').with_limits('LimitNOFILE' => 32_768) } - end - context 'when passing networks' do let :params do { diff --git a/spec/defines/service_limits_spec.rb b/spec/defines/service_limits_spec.rb deleted file mode 100644 index 52dd5f69..00000000 --- a/spec/defines/service_limits_spec.rb +++ /dev/null @@ -1,97 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe 'systemd::service_limits' do - context 'supported operating systems' do - on_supported_os.each do |os, facts| - context "on #{os}" do - let(:facts) { facts } - - let(:title) { 'test.service' } - - # Whole type is deprecated but check it still works. - before do - Puppet.settings[:strict] = :warning - end - - describe 'with limits and present' do - let(:params) do - { - limits: { - 'LimitCPU' => '10m', - 'LimitFSIZE' => 'infinity', - 'LimitDATA' => '10K', - 'LimitNOFILE' => '20:infinity', - 'LimitNICE' => '-10', - 'LimitRTPRIO' => 50, - 'MemorySwapMax' => '0', - 'CPUQuota' => '125%', - 'IODeviceWeight' => [ - { '/dev/weight' => 10 }, - { '/dev/weight2' => 20 }, - ], - 'IOReadBandwidthMax' => [ - { '/bw/max' => '10K' }, - ], - }, - } - end - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_systemd__manage_dropin("#{title}-90-limits.conf").with_ensure('present') } - - it { - expect(subject).to create_file("/etc/systemd/system/#{title}.d/90-limits.conf"). - with(ensure: 'file', mode: '0444'). - with_content(%r{LimitCPU=10m}). - with_content(%r{LimitFSIZE=infinity}). - with_content(%r{LimitDATA=10K}). - with_content(%r{LimitNOFILE=20:infinity}). - with_content(%r{LimitNICE=-10}). - with_content(%r{LimitRTPRIO=50}). - with_content(%r{MemorySwapMax=0}). - with_content(%r{CPUQuota=125%}). - with_content(%r{IODeviceWeight=/dev/weight 10}). - with_content(%r{IODeviceWeight=/dev/weight2 20}). - with_content(%r{IOReadBandwidthMax=/bw/max 10K}) - } - - describe 'with service managed' do - let(:pre_condition) do - <<-PUPPET - service { 'test': - } - PUPPET - end - - it { is_expected.to compile.with_all_deps } - - it do - is_expected.to create_file("/etc/systemd/system/#{title}.d/90-limits.conf"). - that_notifies('Service[test]') - end - end - end - - describe 'source specified' do - let(:params) { { source: 'puppet:///mine/content' } } - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_systemd__dropin_file("#{title}-90-limits.conf").with_ensure('present') } - end - - describe 'ensured absent' do - let(:params) { { ensure: 'absent' } } - - it { is_expected.to compile.with_all_deps } - - it do - expect(subject).to create_file("/etc/systemd/system/#{title}.d/90-limits.conf"). - with_ensure('absent') - end - end - end - end - end -end diff --git a/spec/type_aliases/systemd_servicelimits_spec.rb b/spec/type_aliases/systemd_servicelimits_spec.rb deleted file mode 100644 index 7bc07f7b..00000000 --- a/spec/type_aliases/systemd_servicelimits_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe 'Systemd::ServiceLimits' do - it { is_expected.to allow_value({ 'LimitMEMLOCK' => '100:100K' }) } - - it { is_expected.to allow_value({ 'MemoryAccounting' => true }) } - - it { - is_expected.to allow_value( - { - 'MemoryLow' => '100', - 'MemoryMin' => '10%', - 'MemoryHigh' => '8G', - 'MemoryMax' => 'infinity', - 'MemorySwapMax' => '1T', - } - ) - } - - it { is_expected.not_to allow_value({ 'MemoryHigh' => '1P' }) } -end diff --git a/types/servicelimits.pp b/types/servicelimits.pp deleted file mode 100644 index 6696ed65..00000000 --- a/types/servicelimits.pp +++ /dev/null @@ -1,48 +0,0 @@ -# @summary Deprecated - Matches Systemd Service Limit Struct -# -type Systemd::ServiceLimits = Struct[ - { - Optional['LimitCPU'] => Pattern['^\d+(s|m|h|d|w|M|y)?(:\d+(s|m|h|d|w|M|y)?)?$'], - Optional['LimitFSIZE'] => Pattern['^(infinity|((\d+(K|M|G|T|P|E)?(:\d+(K|M|G|T|P|E)?)?)))$'], - Optional['LimitDATA'] => Pattern['^(infinity|((\d+(K|M|G|T|P|E)?(:\d+(K|M|G|T|P|E)?)?)))$'], - Optional['LimitSTACK'] => Pattern['^(infinity|((\d+(K|M|G|T|P|E)?(:\d+(K|M|G|T|P|E)?)?)))$'], - Optional['LimitCORE'] => Pattern['^(infinity|((\d+(K|M|G|T|P|E)?(:\d+(K|M|G|T|P|E)?)?)))$'], - Optional['LimitRSS'] => Pattern['^(infinity|((\d+(K|M|G|T|P|E)?(:\d+(K|M|G|T|P|E)?)?)))$'], - Optional['LimitNOFILE'] => Variant[Integer[-1],Pattern['^(infinity|\d+(:(infinity|\d+))?)$']], - Optional['LimitAS'] => Pattern['^(infinity|((\d+(K|M|G|T|P|E)?(:\d+(K|M|G|T|P|E)?)?)))$'], - Optional['LimitNPROC'] => Variant[Integer[-1],Pattern['^(infinity|\d+(:(infinity|\d+))?)$']], - Optional['LimitMEMLOCK'] => Pattern['^(infinity|((\d+(K|M|G|T|P|E)?(:\d+(K|M|G|T|P|E)?)?)))$'], - Optional['LimitLOCKS'] => Integer[1], - Optional['LimitSIGPENDING'] => Integer[1], - Optional['LimitMSGQUEUE'] => Pattern['^(infinity|((\d+(K|M|G|T|P|E)?(:\d+(K|M|G|T|P|E)?)?)))$'], - Optional['LimitNICE'] => Variant[Integer[0,40], Pattern['^(-\+([0-1]?[0-9]|20))|([0-3]?[0-9]|40)$']], - Optional['LimitRTPRIO'] => Integer[0], - Optional['LimitRTTIME'] => Pattern['^\d+(ms|s|m|h|d|w|M|y)?(:\d+(ms|s|m|h|d|w|M|y)?)?$'], - Optional['CPUAccounting'] => Boolean, - Optional['CPUShares'] => Integer[2,262144], - Optional['StartupCPUShares'] => Integer[2,262144], - Optional['CPUQuota'] => Optional[Pattern['^([1-9][0-9]*)%$']], - Optional['MemoryAccounting'] => Boolean, - Optional['MemoryLow'] => Pattern['\A(infinity|\d+(K|M|G|T|%)?(:\d+(K|M|G|T|%)?)?)\z'], - Optional['MemoryMin'] => Pattern['\A(infinity|\d+(K|M|G|T|%)?(:\d+(K|M|G|T|%)?)?)\z'], - Optional['MemoryHigh'] => Pattern['\A(infinity|\d+(K|M|G|T|%)?(:\d+(K|M|G|T|%)?)?)\z'], - Optional['MemoryMax'] => Pattern['\A(infinity|\d+(K|M|G|T|%)?(:\d+(K|M|G|T|%)?)?)\z'], - Optional['MemoryLimit'] => Pattern['\A(infinity|\d+(K|M|G|T|%)?(:\d+(K|M|G|T|%)?)?)\z'], - Optional['MemorySwapMax'] => Pattern['\A(infinity|\d+(K|M|G|T|%)?(:\d+(K|M|G|T|%)?)?)\z'], - Optional['TasksAccounting'] => Boolean, - Optional['TasksMax'] => Variant[Integer[1],Pattern['^(infinity|([1-9][0-9]?$|^100)%)$']], - Optional['IOAccounting'] => Boolean, - Optional['IOWeight'] => Integer[1,10000], - Optional['StartupIOWeight'] => Integer[1,10000], - Optional['IODeviceWeight'] => Array[Hash[Stdlib::Absolutepath, Integer[1,10000], 1, 1]], - Optional['IOReadBandwidthMax'] => Array[Hash[Stdlib::Absolutepath, Pattern['^(\d+(K|M|G|T)?)$'], 1, 1]], - Optional['IOWriteBandwidthMax'] => Array[Hash[Stdlib::Absolutepath, Pattern['^(\d+(K|M|G|T)?)$'], 1, 1]], - Optional['IOReadIOPSMax'] => Array[Hash[Stdlib::Absolutepath, Pattern['^(\d+(K|M|G|T)?)$'], 1, 1]], - Optional['IOWriteIOPSMax'] => Array[Hash[Stdlib::Absolutepath, Pattern['^(\d+(K|M|G|T)?)$'], 1, 1]], - Optional['DeviceAllow'] => String[1], - Optional['DevicePolicy'] => Enum['auto','closed','strict'], - Optional['Slice'] => String[1], - Optional['Delegate'] => Boolean, - Optional['OOMScoreAdjust'] => Integer[-1000,1000] - } -]