Forge Home

memcached

Manage memcached via Puppet

2,707,638 downloads

1,353 latest version

4.7 quality score

We run a couple of automated
scans to help you access a
module's quality. Each module is
given a score based on how well
the author has formatted their
code and documentation and
modules are also checked for
malware using VirusTotal.

Please note, the information below
is for guidance only and neither of
these methods should be considered
an endorsement by Puppet.

Version information

  • 9.0.0 (latest)
  • 8.3.0
  • 8.2.0
  • 8.1.0
  • 8.0.0
  • 7.0.0
  • 6.0.0
  • 5.0.0
  • 4.0.0
  • 3.7.0
  • 3.6.0
  • 3.5.0
  • 3.4.0
  • 3.3.0
  • 3.2.0
  • 3.1.0
  • 3.0.2
  • 3.0.1
  • 3.0.0
  • 2.8.1
  • 2.8.0
  • 2.7.1
  • 2.6.0
  • 2.5.0
  • 2.4.0
  • 2.3.0
  • 2.2.4
  • 2.2.3
  • 2.2.2
  • 2.2.1
  • 2.2.0
  • 2.1.0
  • 2.0.4
  • 2.0.3
  • 2.0.2
  • 2.0.1
  • 2.0.0
  • 1.0.1
  • 1.0.0
released May 22nd 2024
This version is compatible with:
  • Puppet Enterprise 2023.8.x, 2023.7.x, 2023.6.x, 2023.5.x, 2023.4.x, 2023.3.x, 2023.2.x, 2023.1.x, 2023.0.x, 2021.7.x, 2021.6.x, 2021.5.x, 2021.4.x, 2021.3.x, 2021.2.x, 2021.1.x, 2021.0.x
  • Puppet >= 7.0.0 < 9.0.0
  • , , , , , , Windows, FreeBSD,

Start using this module

  • r10k or Code Manager
  • Bolt
  • Manual installation
  • Direct download

Add this module to your Puppetfile:

mod 'saz-memcached', '9.0.0'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add saz-memcached
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install saz-memcached --version 9.0.0

Direct download is not typically how you would use a Puppet module to manage your infrastructure, but you may want to download the module in order to inspect the code.

Download

Documentation

saz/memcached — version 9.0.0 May 22nd 2024

memached module for Puppet

Build Status

Manage memcached via Puppet

How to use

Starting with version 3.0.0, memcached will be listening on 127.0.0.1 only.
This should make setups more secure (e.g. if there are no firewall rules in place).

For the old behaviour, you need to set listen to '0.0.0.0'.

Use roughly 90% of memory

    class { 'memcached': }

Set a fixed memory limit in MB

    class { 'memcached':
      max_memory => 2048
    }

Use 12% of available memory

    class { 'memcached':
      max_memory => '12%'
    }

Install multiple memcached instances

the multiinstance support uses a systemd instance unit file. This will be placed at /etc/systemd/system/memcached@.service. It allows us to manage multiple instances via the same unit file. To start a simple instance, you only need to know the desired TCP port:

memcached::instance{'11222':}

that's it! It will bind to localhost and listen to TCP port 11222. You might want to tune the systemd limits, for example the number of file descriptors (LimitNOFILE) or the number of processes (LimitNPROC):

memcached::instance{'11222':
  limits => {
    'LimitNOFILE' => 8192,
    'LimitNPROC'  => 16384,
  }
}

All systemd limits are documented in the systemd documentation.

Another usecase. Let's assume your name is Eric and you want to change the actual memcached parameters, for example to bind it to every interface:

memcached::instance{'11222':
  override_content => "[Service]\nEnvironment='LISTEN=-l 0.0.0.0'",
}

Maybe Eric also wants to override the cache size (the unit is MB):

memcached::instance{'11222':
  override_content => "[Service]\nEnvironment=CACHESIZE=4096\n",
}

last but not least, Eric might also want to override the maximum amount of connections (the default is 1024):

memcached::instance{'11222':
  override_content => "[Service]\nEnvironment=MAXCONN=4096\n",
}

Now Eric wants to use all those three settings at the same time:

memcached::instance{'11222':
  override_content => "[Service]\nEnvironment=MAXCONN=4096\nEnvironment=CACHESIZE=4096\nEnvironment='LISTEN=-l 0.0.0.0'\n",
}

Instead of passing a long string with multiple \n, Eric can also put the content in a file and provide that:

memcached::instance{'11222':
  override_source => "${module_name}/memcached_11222_override.conf\n",
}

Other class parameters

  • $package_ensure = 'present'
  • $logfile = '/var/log/memcached.log'
  • $logstdout = false (Set this to true to disable logging to a file/syslog entirely, useful when memcached runs in containers)
  • $pidfile = '/var/run/memcached.pid' (Debian family only, set to false to disable pidfile)
  • $max_memory = false
  • $max_item_size = false
  • $min_item_size = false
  • $factor = false
  • $lock_memory = false (WARNING: good if used intelligently, google for -k key)
  • $listen = '127.0.0.1' (if TLS/SSL is enabled, 'notls' prefix can be used to disable for specific listeners "notls::")
  • $listen_ip = '127.0.0.1' (deprecated, listen will take precedence over this)
  • $tcp_port = 11211
  • $udp_port = 0
  • $manage_firewall = false
  • $user = '' (OS specific setting, see params.pp)
  • $max_connections = 8192
  • $verbosity = undef
  • $unix_socket = undef
  • $install_dev = false (TRUE if 'libmemcached-dev' package should be installed)
  • $processorcount = $::processorcount
  • $service_restart = true (restart service after configuration changes, false to prevent restarts)
  • $service_flags = '-l 127.0.0.1 -u _memcached -P /var/run/memcached.pid' (only relevant for OpenBSD, to configure the service)
  • $use_sasl = false (start memcached with SASL support)
  • $use_tls = false (start memcached with TLS support)
  • $tls_cert_chain = undef
  • $tls_key = undef
  • $tls_ca_cert = undef
  • $tls_verify_mode = 1 (0: None, 1: Request, 2: Require, 3: Once)
  • $large_mem_pages = false (try to use large memory pages)