Version information
This version is compatible with:
- Puppet Enterprise 2025.2.x, 2025.1.x, 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
Add this module to your Puppetfile:
mod 'saz-memcached', '10.0.1'
Learn more about managing modules with a PuppetfileDocumentation
memcached module for Puppet
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",
}
Reference
Table of Contents
Classes
Public Classes
memcached
: This class manages memcachedmemcached::params
: == Class: memcached::params
Private Classes
memcached::instance::servicefile
: helper class to configure the memcache multiinstance unit file once
Defined types
memcached::instance
: Manage multiple memcached instances
Functions
memcached::max_memory
: Calculate max_memory size from fact 'memsize' and passed argument.
Classes
memcached
This class manages memcached
Examples
Use default settings
include memcached
Parameters
The following parameters are available in the memcached
class:
package_ensure
service_manage
service_flags
logfile
logstdout
syslog
pidfile
manage_firewall
max_memory
max_item_size
min_item_size
factor
lock_memory
listen
listen_ip
tcp_port
udp_port
user
max_connections
verbosity
unix_socket
unix_socket_mask
install_dev
processorcount
service_restart
auto_removal
use_sasl
use_tls
tls_cert_chain
tls_key
tls_ca_cert
tls_verify_mode
use_registry
registry_key
large_mem_pages
use_svcprop
svcprop_fmri
svcprop_key
extended_opts
config_tmpl
disable_cachedump
max_reqs_per_event
disable_flush_all
disable_watch
memory_file
package_ensure
Data type: Enum['present', 'latest', 'absent']
Set ensure of the memcached package
Default value: 'present'
service_manage
Data type: Boolean
Manage the memcached service
Default value: true
service_flags
Data type: Optional[String]
Pass flags to the service managed by Puppet
Default value: $memcached::params::service_flags
logfile
Data type: Optional[Stdlib::Absolutepath]
Specify file to log to. Not supported on OS using systemd
Default value: $memcached::params::logfile
logstdout
Data type: Boolean
Disable logging to a file or syslog entirely. Only supported on RedHat-based OS and Suse
Default value: false
syslog
Data type: Boolean
Log to syslog. Only supported on RedHat-based OS and Suse
Default value: false
pidfile
Data type: Variant[Stdlib::Absolutepath, Boolean[false], Undef]
Save pid in file
Default value: $memcached::params::pidfile
manage_firewall
Data type: Boolean
Create simple firewall rules. Only supported on Linux
Default value: false
max_memory
Data type: Variant[Integer[0], Pattern[/^1?\d?\d%$/]]
Max memory memcached should use to store items. Either in percent or mb
Default value: '95%'
max_item_size
Data type: Optional[Variant[Integer, String]]
Adjusts max item size
Default value: undef
min_item_size
Data type: Optional[Variant[Integer, String]]
Min space used for key+value+flags
Default value: undef
factor
Data type: Optional[Variant[Integer, String]]
Chunk size growth factor
Default value: undef
lock_memory
Data type: Boolean
Lock down all paged memory
Default value: false
listen
Data type: Optional[Variant[String,Array[String]]]
Interface to listen on
Default value: undef
listen_ip
Data type: Optional[Variant[Stdlib::IP::Address,Array[Stdlib::IP::Address]]]
Deprecated. Use listen
instead
Default value: undef
tcp_port
Data type: Integer
TCP port to listen on
Default value: 11211
udp_port
Data type: Integer
UDP port to listen on
Default value: 0
user
Data type: String
User to run memcached service as
Default value: $memcached::params::user
max_connections
Data type: Integer
Max simultaneous connections
Default value: 8192
verbosity
Data type: Optional[Enum['v', 'vv', 'vvv']]
v: verbose (print errors/warnings while in event loop) vv: very verbose (also print client commands/responses) vvv: extremely verbose (internal state transitions)
Default value: undef
unix_socket
Data type: Optional[String]
UNIX socket to listen on (disables network support)
Default value: undef
unix_socket_mask
Data type: String
access mask for UNIX socket, in octal
Default value: '0755'
install_dev
Data type: Boolean
Manage installation of the memcached dev package
Default value: false
processorcount
Data type: Variant[String,Integer]
Number of threads to use
Default value: $facts['processors']['count']
service_restart
Data type: Boolean
Whether or not to restart the memcached service on changes
Default value: true
auto_removal
Data type: Boolean
Return error on memory exhausted instead of evicting
Default value: false
use_sasl
Data type: Boolean
Turn on SASL authentication
Default value: false
use_tls
Data type: Boolean
Enable TLS/SSL
Default value: false
tls_cert_chain
Data type: Optional[Stdlib::Absolutepath]
Path to certificate chain file
Default value: undef
tls_key
Data type: Optional[Stdlib::Absolutepath]
Path to certificate key file
Default value: undef
tls_ca_cert
Data type: Optional[Stdlib::Absolutepath]
Path to CA certificate file
Default value: undef
tls_verify_mode
Data type: Integer[0,3]
Peer certificate verify mode
Default value: 1
use_registry
Data type: Boolean
Default value: $memcached::params::use_registry
registry_key
Data type: String
Default value: 'HKLM\System\CurrentControlSet\services\memcached\ImagePath'
large_mem_pages
Data type: Boolean
Try to use large memory pages (if available)
Default value: false
use_svcprop
Data type: Boolean
Default value: $memcached::params::use_svcprop
svcprop_fmri
Data type: String
Default value: 'memcached:default'
svcprop_key
Data type: String
Default value: 'memcached/options'
extended_opts
Data type: Optional[Array[String]]
Array of extended options
Default value: undef
config_tmpl
Data type: String
Use a different config template
Default value: $memcached::params::config_tmpl
disable_cachedump
Data type: Boolean
Disable stats cachedump and lru_crawler metadump
Default value: false
max_reqs_per_event
Data type: Optional[Integer]
Maximum number of requests per event, limits the requests processed per connection to prevent starvation
Default value: undef
disable_flush_all
Data type: Boolean
Disable flush_all command
Default value: false
disable_watch
Data type: Boolean
Disable watch commands (live logging)
Default value: false
memory_file
Data type: Optional[Stdlib::Absolutepath]
mmap a file for item memory.
Default value: undef
memcached::params
== Class: memcached::params
Defined types
memcached::instance
Manage multiple memcached instances
Parameters
The following parameters are available in the memcached::instance
defined type:
manage_firewall
Data type: Boolean
enable/disable fireall management via puppetlabs/firewall
Default value: false
port
Data type: Stdlib::Port::Unprivileged
the udp and tcp port to listen on. By default, the instance name is used
Default value: Integer($name)
limits
Data type: Optional[Systemd::ServiceLimits]
systemd limits for the service
Default value: undef
override_content
Data type: Optional[String[1]]
overrides for the unit, as string
Default value: undef
override_source
Data type: Optional[Stdlib::Filesource]
overrides for the unit, as file resource
Default value: undef
Functions
memcached::max_memory
Type: Ruby 4.x API
Calculate max_memory size from fact 'memsize' and passed argument.
memcached::max_memory(Any $arg)
Calculate max_memory size from fact 'memsize' and passed argument.
Returns: Integer
arg
Data type: Any
Changelog
All notable changes to this project will be documented in this file. Each new release typically also includes the latest modulesync defaults. These should not affect the functionality of the module.
v10.0.1 (2025-03-10)
Fixed bugs:
Closed issues:
- memcached::max_memory no longer accepts an integer #186
v10.0.0 (2025-03-07)
Breaking changes:
- Remove Scientific LINUX #180 (kajinamit)
- drop OracleLinux 7, add 8 and 9 as supported OS #176 (saz)
- remove some eol OS #174 (saz)
- Drop workaround for Puppet 5 #172 (kajinamit)
Implemented enhancements:
- Bump upper limit of puppet-systemd #179 (kajinamit)
- add disable-flush-all, disable-watch and memory-file parameter #177 (saz)
- add Ubuntu 24.04 as supported OS #175 (saz)
Merged pull requests:
v9.0.0 (2024-05-21)
Closed issues:
- Default pidfile on Ubuntu misplaced #159
- Make release at puppet forge compatible with Puppet 8 #154
- Default user on debian to "memcache" #105
Merged pull requests:
- release: v9.0.0 #171 (saz)
- drop EOL Ubuntu 18.04 #170 (saz)
- replace systemd::service_limits with systemd::manage_dropin #169 (saz)
- support newer firewall module #168 (saz)
- add pidfile value to OpenBSD params #166 (saz)
- drop puppet6 support #165 (saz)
- allow puppet/systemd \< 8, add Debian 12 as supported OS #164 (saz)
- Update from modulesync_config #163 (saz)
- Add support for OpenBSD #162 (buzzdeee)
- Fix Ubuntu pidfile and default user #160 (toggetit)
v8.3.0 (2024-02-26)
Closed issues:
- Upstream release with Puppet 8 support? #153
- package_ensure: absent will assume the memcached user exists #149
- Disabling pidfile not possible #142
Merged pull requests:
- prepare release: 8.3.0 #158 (saz)
- update all dependencies #157 (saz)
- Allow disabling PID file #156 (siebrand)
- README: use new parameter for address binding #152 (thtomate)
- Bugfix: replace legacy fact in sysconfig-template #151 (sircubbi)
- set file ensure based on $package_ensure, fixes #149 #150 (saz)
- fix: wrong camelcase in Stdlib::IP::Address type #148 (saz)
- Add max_reqs_per_event option for the memcached config #136 (s10)
v8.2.0 (2023-05-26)
Merged pull requests:
- prepare release v8.2.0 #147 (saz)
- Stop using deprecated Stdlib::Compat::Ip_address #145 (traylenator)
- Update from modulesync_config #144 (saz)
- Bump upper version of puppet-systemd #143 (kajinamit)
v8.1.0 (2022-07-11)
Merged pull requests:
v8.0.0 (2022-07-10)
Closed issues:
- Passing an array to memcached::listen doesn't work #133
- Deprecation warning is shown by default #131
- Error while evaluating a Function Call, Failed to parse template memcached/memcached_sysconfig.erb (Version 3.7.0) #115
Merged pull requests:
- Make sure memcached logfile exists #140 (danifr)
- Support CentOS 8/RHEL 8 #139 (kajinamit)
- Load modern facts first #138 (kajinamit)
- manifests/instance: Fix duplicate systemd daemon-reload execs #137 (jonasdemoor)
- Update from saz modulesync_config #135 (saz)
v7.0.0 (2021-06-11)
Closed issues:
- support puppetlabs-firewall 3.0.0 #129
Merged pull requests:
v6.0.0 (2021-03-09)
Merged pull requests:
- Revert "Add notls_listener_addr and notls_listener_port paramenters" #128 (moisesguimaraes)
- Add listen_addr option #127 (moisesguimaraes)
v5.0.0 (2021-01-07)
Closed issues:
- use_sasl not working on rhel systems/sysconfig #123
Merged pull requests:
- Disable UDP by default #125 (moisesguimaraes)
- Add notls_listener_addr and notls_listener_port paramenters #124 (moisesguimaraes)
- Adds sasl support to RHEL derivatives #122 (khudson)
v4.0.0 (2020-12-04)
Closed issues:
Merged pull requests:
- Manage multiple memcached instances #120 (bastelfreak)
- migrate to rspec-puppet-facts #119 (bastelfreak)
- Implement basic acceptance tests #118 (bastelfreak)
- apply Vox Pupuli Gemfile/Rakefile & apply up2date puppet-lint recommendations #117 (bastelfreak)
- Drop EOL Puppet 4 support #116 (bastelfreak)
v3.7.0 (2020-09-05)
Merged pull requests:
- Add support to set TLS parameters in /etc/sysconfig/memcached #113 (kajinamit)
- Make ssl_ca_cert optional #112 (kajinamit)
v3.6.0 (2020-09-03)
Merged pull requests:
- Add TLS parameters #109 (moisesguimaraes)
v3.5.0 (2020-05-12)
Closed issues:
Merged pull requests:
- Updating version dependencies #107 (cubiclelord)
v3.4.0 (2019-01-22)
Closed issues:
- max memory size is never calculated unless percentage is used #100
Merged pull requests:
- growth factor should be integer/string #103 (anesterova)
- allow puppet 6.x #101 (bastelfreak)
v3.3.0 (2018-07-19)
Merged pull requests:
- Add the logstdout bool parameter ti disable syslog/file logging completely #99 (mbaldessari)
- Allow an array of IP addresses in addition to a single IP address #98 (cubiclelord)
v3.2.0 (2018-07-07)
Closed issues:
Merged pull requests:
- Remove trailing whitespace from svcprop value. #97 (matmannion)
- .rubocop.yml : update TrailingCommainLiteral #95 (andrewspiers)
v3.1.0 (2018-01-09)
Closed issues:
- Changelog? #87
Merged pull requests:
- use puppet4 functions-api #92 (juliantodt)
- Add option to disable memcached's cachedump #90 (derekhiggins)
- Fix .rubocop.yml issues #89 (JAORMX)
- Make sysconfig configuration work with undef values for logfile #88 (JAORMX)
- Unix socket mask #86 (obi11235)
- Implement puppet4 datatypes #84 (bastelfreak)
v3.0.2 (2017-05-10)
Closed issues:
- $max_memory parameter is not a boolean #85
v3.0.1 (2017-01-06)
Closed issues:
- 3.0.0 contains an additional colon typo in memcached_max_memory.rb #82
v3.0.0 (2017-01-06)
Closed issues:
- CentOS 7 unix_socket does nothing #78
- Any chance of a release soon? #75
- Set additional memcached options #71
- Default
listen_ip
#66 - "Permission denied" error when trying to write PID file as non-root user #64
- Upstart service installation error #62
- Single-instance config not working #61
- Support multiple memcache instances #18
Merged pull requests:
- allow custom runtime params on freebsd #81 (sethlyons)
- Support Puppet v4 AIO (Ruby 2.3.1) #80 (ghoneycutt)
- add support for freebsd #79 (sethlyons)
- Add the ability to specify an array of extended options #77 (dmart)
- custom template, min_item_size, factor supoort #74 (michalrychlik)
- Added support for unix_socket in the sysconfig template #72 (agitelzon)
- fix puppetlabs-firewall port parameter deprecation warning #70 (crigertg)
- add quote around tcp/udp ports so they are treated as strings #67 (mmarseglia)
- Solaris support for SMF management of memcached #63 (matmannion)
v2.8.1 (2015-06-07)
v2.8.0 (2015-05-26)
Merged pull requests:
- feature: Add possibilty to configure no listen_ip. #60 (andrekeller)
- Add a $service_manage boolean #59 (Spredzy)
- add support for logging to syslog. #56 (mmarseglia)
- Add ability to specify max object size. (-I) #55 (mattkenn4545)
- Updates to run multiple instances of memcached. #54 (dansajner)
v2.7.1 (2015-03-29)
v2.7.0 (2015-03-29)
Merged pull requests:
- Convert @processorcount to string #53 (jonhattan)
- Add windows support #52 (bgrolleman)
- Add support for custom and disabling of pidfiles. #51 (jburnham)
- Add support for large memory pages #50 (joshuaspence)
v2.6.0 (2014-09-22)
Closed issues:
Merged pull requests:
- Replaced references to type() function with is_string() for Puppet 3.7.x... #49 (misterdorm)
- Add SASL support #48 (gloppasglop)
- Added option "auto_removal" this option aim to enable or disable the -M ... #46 (sxd)
- Releax the Puppet Enterprise requirement #44 (hogepodge)
- Fix bug when
package_ensure
was set toabsent
. #43 (riton) - Add SLES Support #41 (globin)
v2.5.0 (2014-06-22)
Closed issues:
- Autoreload service on config change #36
- logfile setting in /etc/sysconfig/memcached in the case of Redhat OS #30
- Add support for item size limit #29
Merged pull requests:
- explicitly calling to_s on parameters that could potentially be a numeri... #40 (misterdorm)
- $logfile support for redhat #39 (fizmat)
- Enforce Linux line endings for *.erb templates. #38 (hdanes)
v2.4.0 (2014-02-10)
Closed issues:
- memcached.log : "Could not open the pid file /var/run/memcached.pid for writing: Permission denied" #27
Merged pull requests:
- Add firewall #34 (ghoneycutt)
- Fix remaining deprecation warnings #26 (judge-red)
- Fix Puppet 3.2.x deprecation warnings #23 (blkperl)
- Implement Override the default size of each slab page #20 (elgerpostema)
v2.1.0 (2013-02-01)
Merged pull requests:
v2.0.4 (2012-11-06)
Merged pull requests:
v2.0.3 (2012-10-19)
Closed issues:
- memcache module is failing #15
- No LICENSE file #13
- rspec testsuite broken since 8053bb43 #11
- max_memory calculated value #4
Merged pull requests:
- Backwards compatibility fix #16 (derekhiggins)
- Enrich memory variables: allow percents & add lock flag #14 (garex)
- Remove a trailing comma for compatibility with puppet 2.6 #12 (branan)
- Fix rake spec exit status #10 (fcharlier)
- Support for Unix sockets and verbosity. #9 (acceso)
- Using $::osfamily to make it work on RedHat derivatives #8 (vaneldik)
v2.0.1 (2012-05-04)
Merged pull requests:
- Adding fedora support #6 (derekhiggins)
v2.0.0 (2012-01-20)
Merged pull requests:
- Simplify looking up user defaults from params namespace #3 (bodepd)
- CentOS/Redhat support #2 (bramswenson)
- Refactor #1 (bodepd)
* This Changelog was automatically generated by github_changelog_generator
Dependencies
- puppetlabs/stdlib (>= 4.13.1 < 10.0.0)
- puppetlabs/firewall (>= 0.1.0 < 9.0.0)
- puppet/systemd (>= 6.0.0 < 9.0.0)
- puppet/selinux (>= 3.2.0 < 5.0.0)
Copyright 2011-2016 Steffen Zieger Copyright 2014-2016 Garrett Honeycutt <code@garretthoneycutt.com> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.