Puppet Class: redis::ulimit

Defined in:
manifests/ulimit.pp

Overview

Redis class for configuring ulimit Used to DRY up the config class, and move the logic for ulimit changes all into one place.

Parameters are not required as it’s a private class only referencable from the redis module, where the variables would already be defined

Examples:

contain redis::ulimit

Author:

    • Peter Souter



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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
# File 'manifests/ulimit.pp', line 17

class redis::ulimit {
  assert_private('The redis::ulimit class is only to be called from the redis::config class')

  $service_provider_lookup = pick(getvar_emptystring('service_provider'), false)

  if $::redis::managed_by_cluster_manager {
    file { '/etc/security/limits.d/redis.conf':
      ensure  => 'file',
      owner   => 'root',
      group   => 'root',
      mode    => '0644',
      content => "redis soft nofile ${::redis::ulimit}\nredis hard nofile ${::redis::ulimit}\n",
    }
  }
  if $service_provider_lookup == 'systemd' {
    file { "/etc/systemd/system/${::redis::service_name}.service.d/":
      ensure                  => 'directory',
      owner                   => 'root',
      group                   => 'root',
      selinux_ignore_defaults => true,
    }

    file { "/etc/systemd/system/${::redis::service_name}.service.d/limit.conf":
      ensure => file,
      owner  => 'root',
      group  => 'root',
      mode   => '0444',
    }
    augeas { 'Systemd redis ulimit' :
      incl    => "/etc/systemd/system/${::redis::service_name}.service.d/limits.conf",
      lens    => 'Systemd.lns',
      context => "/etc/systemd/system/${::redis::service_name}.service.d/limits.conf",
      changes => [
        "defnode nofile Service/LimitNOFILE \"\"",
        "set \$nofile/value \"${::redis::ulimit}\""],
      notify  => [
        Exec['systemd-reload-redis'],
      ],
    }
  } else {
    augeas { 'redis ulimit':
      changes => "set ULIMIT ${::redis::ulimit}",
    }
    case $::osfamily {
      'Debian': {
        Augeas['redis ulimit'] {
          context => '/files/etc/default/redis-server',
        }
      }
      'RedHat': {
        Augeas['redis ulimit'] {
          context => '/files/etc/sysconfig/redis',
        }
      }
      default: {
        warning("Not sure how to set ULIMIT on non-systemd OSFamily ${::osfamily}, PR's welcome")
      }
    }
  }

}