Puppet Class: memcached

Defined in:
modules/memcached/manifests/init.pp

Overview

Class: memcached

Memcached is a general-purpose, in-memory key-value store.

Parameters

size

Instance size in megabytes (default: 2000).

port

Port to listen on (default: 11000).

ip

IP address to listen on (default: '0.0.0.0').

version

Package version to install, or 'present' for any version (default: 'present').

growth_factor

Multiplier for computing the sizes of memory chunks that items are stored in. Corresponds to memcached's -f parameter, and it wil dictate the distribution of slab sizes. Note: change the default only if you know what you are doing. Default: 1.25

growth_factor

This is the value of the smallest slab that memcached will use. All the other slabs will be created using the growth_factor parameter. Note: change the default only if you know what you are doing. Default: 48

enable_tls

Configure mcrouter using TLS on external interfaces. This parameter is only supported on memcached 1.6 Default: false

enlable_tls_localhost

By default the socket on localhost will not be wrapped in TLS This is to make debugging easier and support the prometheus exporter. Set this to true to also wrap localhost Default: false

ssl_cert

The public key used for SSL connections Default: undef

ssl_key

The public key used for SSL connections Default: undef

extra_options

A hash of additional command-line options and values.

Examples

class { '::memcached':
  size => 100,
  port => 11211,
  ip   => '127.0.0.1',
}

Parameters:

  • size (Integer) (defaults to: 2000)
  • port (Stdlib::Port) (defaults to: 11000)
  • ip (Stdlib::IP::Address) (defaults to: '0.0.0.0')
  • version (String) (defaults to: 'present')
  • min_slab_size (Integer) (defaults to: 48)
  • growth_factor (Float) (defaults to: 1.25)
  • extra_options (Hash[String, Any]) (defaults to: {})
  • enable_16 (Boolean) (defaults to: false)
  • enable_tls (Boolean) (defaults to: false)
  • enable_tls_localhost (Boolean) (defaults to: false)
  • ssl_cert (Optional[Stdlib::Unixpath]) (defaults to: undef)
  • ssl_key (Optional[Stdlib::Unixpath]) (defaults to: undef)


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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'modules/memcached/manifests/init.pp', line 64

class memcached(
    Integer                    $size                 = 2000,
    Stdlib::Port               $port                 = 11000,
    Stdlib::IP::Address        $ip                   = '0.0.0.0',
    String                     $version              = 'present',
    Integer                    $min_slab_size        = 48,
    Float                      $growth_factor        = 1.25,
    Hash[String, Any]          $extra_options        = {},
    Boolean                    $enable_16            = false,
    Boolean                    $enable_tls           = false,
    Boolean                    $enable_tls_localhost = false,
    Optional[Stdlib::Unixpath] $ssl_cert             = undef,
    Optional[Stdlib::Unixpath] $ssl_key              = undef,
) {
    if $enable_tls and ! $enable_16 {
        fail('you can only enable tls with memcached1.6')
    }
    if $enable_tls and (!$ssl_key or !$ssl_key) {
        fail('you must provide ssl_cert and ssl_key if you enable_tls')
    }
    if $ip == '0.0.0.0' and $enable_tls and !$enable_tls_localhost {
        # if the ip is 0.0.0.0, indicating all ipv4 interfaces,
        # then we need to split theses addresses out to ensure we
        # have notls on localhost
        $listen = [$facts['networking']['ip'], 'notls:localhost']
    } else {
        $listen = [$ip]
    }
    if $enable_16 {
        apt::package_from_component { 'memcached_16':
            component => 'component/memcached16',
            packages  => ['memcached'],
            before    => Service['memcached'],
        }
        $override = true
    } else {
        package { 'memcached':
            ensure => $version,
            before => Service['memcached'],
        }
        $override = false
    }

    systemd::service { 'memcached':
        ensure   => present,
        override => $override,
        content  => systemd_template('memcached'),
    }

    # Prefer a direct check if memcached is not running on localhost.

    if $ip == '127.0.0.1' {
        nrpe::monitor_service { 'memcached':
            description  => 'Memcached',
            nrpe_command => "/usr/lib/nagios/plugins/check_tcp -H ${ip} -p ${port}",
            notes_url    => 'https://wikitech.wikimedia.org/wiki/Memcached',
        }
    } else {
        monitoring::service { 'memcached':
            description   => 'Memcached',
            check_command => "check_tcp!${port}",
            notes_url     => 'https://wikitech.wikimedia.org/wiki/Memcached',
        }
    }

}