summaryrefslogtreecommitdiff
path: root/puppet/modules/systemd/manifests/service_limits.pp
diff options
context:
space:
mode:
authorMicah Anderson <micah@riseup.net>2017-11-28 11:35:01 -0500
committerMicah Anderson <micah@riseup.net>2017-11-28 11:35:01 -0500
commit0d251e2ceddd3e02ed8bba8725830689dbdd1397 (patch)
tree37d7096d9e458ca1e6431dff8a2f571553011c44 /puppet/modules/systemd/manifests/service_limits.pp
parent93a181d44e2d8163ae44945aac1b6477e268170d (diff)
parentbf6c56d86c7ba45e7ca766d990a9e9162025e5ac (diff)
Merge tag 'refs/tags/0.10.0' into stable
Release 0.10.0
Diffstat (limited to 'puppet/modules/systemd/manifests/service_limits.pp')
-rw-r--r--puppet/modules/systemd/manifests/service_limits.pp50
1 files changed, 50 insertions, 0 deletions
diff --git a/puppet/modules/systemd/manifests/service_limits.pp b/puppet/modules/systemd/manifests/service_limits.pp
new file mode 100644
index 00000000..a9cdc25a
--- /dev/null
+++ b/puppet/modules/systemd/manifests/service_limits.pp
@@ -0,0 +1,50 @@
+# -- Define: systemd::service_limits
+# Creates a custom config file and reloads systemd
+define systemd::service_limits(
+ $ensure = file,
+ $path = '/etc/systemd/system',
+ $limits = undef,
+ $source = undef,
+ $restart_service = true
+) {
+ include ::systemd
+
+ if $limits {
+ validate_hash($limits)
+ $content = template('systemd/limits.erb')
+ }
+ else {
+ $content = undef
+ }
+
+ if $limits and $source {
+ fail('You may not supply both limits and source parameters to systemd::service_limits')
+ } elsif $limits == undef and $source == undef {
+ fail('You must supply either the limits or source parameter to systemd::service_limits')
+ }
+
+ file { "${path}/${title}.d/":
+ ensure => 'directory',
+ owner => 'root',
+ group => 'root',
+ }
+ ->
+ file { "${path}/${title}.d/limits.conf":
+ ensure => $ensure,
+ content => $content,
+ source => $source,
+ owner => 'root',
+ group => 'root',
+ mode => '0444',
+ notify => Exec['systemctl-daemon-reload'],
+ }
+
+ if $restart_service {
+ exec { "systemctl restart ${title}":
+ path => $::path,
+ refreshonly => true,
+ subscribe => File["${path}/${title}.d/limits.conf"],
+ require => Exec['systemctl-daemon-reload'],
+ }
+ }
+}