diff --git a/REFERENCE.md b/REFERENCE.md index 35c4afd..e4b3370 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -1,2015 +1,2026 @@ # Reference ## Table of Contents ### Classes #### Public Classes * [`redis`](#redis): This class installs redis -* [`redis::administration`](#redisadministration): Allows various adminstrative settings for Redis As documented in the FAQ and https://redis.io/topics/admin +* [`redis::administration`](#redisadministration): Allows various administrative settings for Redis * [`redis::globals`](#redisglobals): Set a global config for Redis * [`redis::sentinel`](#redissentinel): Install redis-sentinel #### Private Classes * `redis::config`: This class provides configuration for Redis. * `redis::install`: This class installs the application. * `redis::params`: This class provides a number of parameters. * `redis::preinstall`: Provides anything required by the install class, such as package repositories. * `redis::service`: This class manages the Redis daemon. * `redis::ulimit`: 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 ### Defined types * [`redis::instance`](#redisinstance): Allows the configuration of multiple redis configurations on one machine ### Functions -* [`redis::get`](#redisget): ``` +* [`redis::get`](#redisget): Returns the value of the key being looked up or `undef` if the key does not exist. ### Data types * [`Redis::LogLevel`](#redisloglevel): Specify the server verbosity level. * [`Redis::RedisUrl`](#redisredisurl) ### Tasks * [`redis_cli`](#redis_cli): Executes a redis-cli command on the target system ## Classes ### `redis` This class installs redis #### Examples ##### Default install ```puppet include redis ``` ##### Slave Node ```puppet class { '::redis': bind => '10.0.1.2', slaveof => '10.0.1.1 6379', } ``` ##### Binding on multiple interfaces ```puppet class { 'redis': bind => ['127.0.0.1', '10.0.0.1', '10.1.0.1'], } ``` ##### Binding on all interfaces ```puppet class { 'redis': bind => [], } ``` #### Parameters The following parameters are available in the `redis` class. ##### `activerehashing` Data type: `Boolean` Enable/disable active rehashing. Default value: ``true`` ##### `aof_load_truncated` Data type: `Boolean` Enable/disable loading truncated AOF file Default value: ``true`` ##### `aof_rewrite_incremental_fsync` Data type: `Boolean` Enable/disable fsync for AOF file Default value: ``true`` ##### `appendfilename` Data type: `String[1]` The name of the append only file Default value: `'appendonly.aof'` ##### `appendfsync` Data type: `Enum['no', 'always', 'everysec']` Adjust fsync mode Default value: `'everysec'` ##### `appendonly` Data type: `Boolean` Enable/disable appendonly mode. Default value: ``false`` ##### `auto_aof_rewrite_min_size` Data type: `String[1]` Adjust minimum size for auto-aof-rewrite. Default value: `'64mb'` ##### `auto_aof_rewrite_percentage` Data type: `Integer[0]` Adjust percentatge for auto-aof-rewrite. Default value: `100` ##### `bind` Data type: `Variant[Stdlib::IP::Address, Array[Stdlib::IP::Address]]` Configure which IP address(es) to listen on. To bind on all interfaces, use an empty array. Default value: `['127.0.0.1']` ##### `config_dir` Data type: `Stdlib::Absolutepath` Directory containing the configuration files. Default value: `$redis::params::config_dir` ##### `config_dir_mode` Data type: `Stdlib::Filemode` Adjust mode for directory containing configuration files. Default value: `$redis::params::config_dir_mode` ##### `config_file_orig` Data type: `Stdlib::Absolutepath` The location and name of a config file that provides the source Default value: `$redis::params::config_file_orig` ##### `config_file` Data type: `Stdlib::Absolutepath` Adjust main configuration file. Default value: `$redis::params::config_file` ##### `config_file_mode` Data type: `Stdlib::Filemode` Adjust permissions for configuration files. Default value: `'0644'` ##### `config_group` Data type: `String[1]` Adjust filesystem group for config files. Default value: `$redis::params::config_group` ##### `config_owner` Data type: `String[1]` Adjust filesystem owner for config files. Default value: `$redis::params::config_owner` ##### `conf_template` Data type: `String[1]` Define which template to use. Default value: `'redis/redis.conf.erb'` ##### `daemonize` Data type: `Boolean` Have Redis run as a daemon. Default value: `$redis::params::daemonize` ##### `default_install` Data type: `Boolean` Configure a default install of redis. Default value: ``true`` ##### `databases` Data type: `Integer[1]` Set the number of databases. Default value: `16` ##### `dbfilename` Data type: `Variant[String[1], Boolean]` The filename where to dump the DB Default value: `'dump.rdb'` ##### `extra_config_file` Data type: `Optional[String]` Optional extra config file to include Default value: ``undef`` ##### `hash_max_ziplist_entries` Data type: `Integer[0]` Set max ziplist entries for hashes. Default value: `512` ##### `hash_max_ziplist_value` Data type: `Integer[0]` Set max ziplist values for hashes. Default value: `64` ##### `hll_sparse_max_bytes` Data type: `Integer[0]` HyperLogLog sparse representation bytes limit Default value: `3000` ##### `hz` Data type: `Integer[1, 500]` Set redis background tasks frequency Default value: `10` ##### `latency_monitor_threshold` Data type: `Integer[0]` Latency monitoring threshold in milliseconds Default value: `0` ##### `list_max_ziplist_entries` Data type: `Integer[0]` Set max ziplist entries for lists. Default value: `512` ##### `list_max_ziplist_value` Data type: `Integer[0]` Set max ziplist values for lists. Default value: `64` ##### `log_dir` Data type: `Stdlib::Absolutepath` Specify directory where to write log entries. Default value: `'/var/log/redis'` ##### `log_dir_mode` Data type: `Stdlib::Filemode` Adjust mode for directory containing log files. Default value: `$redis::params::log_dir_mode` ##### `log_file` Data type: `Stdlib::Absolutepath` Specify file where to write log entries. Default value: `'/var/log/redis/redis.log'` ##### `log_level` Data type: `Redis::LogLevel` Specify the server verbosity level. Default value: `'notice'` ##### `manage_repo` Data type: `Boolean` Enable/disable upstream repository configuration. Default value: ``false`` ##### `manage_package` Data type: `Boolean` Enable/disable management of package Default value: ``true`` ##### `managed_by_cluster_manager` Data type: `Boolean` Choose if redis will be managed by a cluster manager such as pacemaker or rgmanager Default value: ``false`` ##### `masterauth` Data type: `Optional[String[1]]` If the master is password protected (using the "requirepass" configuration Default value: ``undef`` ##### `maxclients` Data type: `Integer[1]` Set the max number of connected clients at the same time. Default value: `10000` ##### `maxmemory` Data type: `Any` Don't use more memory than the specified amount of bytes. Default value: ``undef`` ##### `maxmemory_policy` Data type: `Any` How Redis will select what to remove when maxmemory is reached. Default value: ``undef`` ##### `maxmemory_samples` Data type: `Any` Select as well the sample size to check. Default value: ``undef`` ##### `min_slaves_max_lag` Data type: `Integer[0]` The lag in seconds Default value: `10` ##### `min_slaves_to_write` Data type: `Integer[0]` Minimum number of slaves to be in "online" state Default value: `0` ##### `no_appendfsync_on_rewrite` Data type: `Boolean` If you have latency problems turn this to 'true'. Otherwise leave it as Default value: ``false`` ##### `notify_keyspace_events` Data type: `Optional[String[1]]` Which events to notify Pub/Sub clients about events happening Default value: ``undef`` ##### `notify_service` Data type: `Boolean` You may disable service reloads when config files change if you Default value: ``true`` ##### `package_ensure` Data type: `String[1]` Default action for package. Default value: `'present'` ##### `package_name` Data type: `String[1]` Upstream package name. Default value: `$redis::params::package_name` ##### `pid_file` Data type: `Stdlib::Absolutepath` Where to store the pid. Default value: `$redis::params::pid_file` ##### `port` Data type: `Stdlib::Port` Configure which port to listen on. Default value: `6379` ##### `protected_mode` Data type: `Boolean` Whether protected mode is enabled or not. Only applicable when no bind is set. Default value: ``true`` ##### `ppa_repo` Data type: `Optional[String]` Specify upstream (Ubuntu) PPA entry. Default value: `$redis::params::ppa_repo` ##### `rdbcompression` Data type: `Boolean` Enable/disable compression of string objects using LZF when dumping. Default value: ``true`` ##### `repl_backlog_size` Data type: `String[1]` The replication backlog size Default value: `'1mb'` ##### `repl_backlog_ttl` Data type: `Integer[0]` The number of seconds to elapse before freeing backlog buffer Default value: `3600` ##### `repl_disable_tcp_nodelay` Data type: `Boolean` Enable/disable TCP_NODELAY on the slave socket after SYNC Default value: ``false`` ##### `repl_ping_slave_period` Data type: `Integer[1]` Slaves send PINGs to server in a predefined interval. It's possible Default value: `10` ##### `repl_timeout` Data type: `Integer[1]` Set the replication timeout for: Default value: `60` ##### `requirepass` Data type: `Optional[String]` Require clients to issue AUTH before processing any other commands. Default value: ``undef`` ##### `save_db_to_disk` Data type: `Boolean` Set if save db to disk. Default value: ``true`` ##### `save_db_to_disk_interval` Data type: `Hash` save the dataset every N seconds if there are at least M changes in the dataset Default value: `{ '900' => '1', '300' => '10', '60' => '10000' }` ##### `service_manage` Data type: `Boolean` Specify if the service should be part of the catalog. Default value: ``true`` ##### `service_enable` Data type: `Boolean` Enable/disable daemon at boot. Default value: ``true`` ##### `service_ensure` Data type: `Stdlib::Ensure::Service` Specify if the server should be running. Default value: `'running'` ##### `service_group` Data type: `String[1]` Specify which group to run as. Default value: `'redis'` ##### `service_name` Data type: `String[1]` Specify the service name for Init or Systemd. Default value: `$redis::params::service_name` ##### `service_user` Data type: `String[1]` Specify which user to run as. Default value: `'redis'` ##### `set_max_intset_entries` Data type: `Integer[0]` The following configuration setting sets the limit in the size of the set in order to use this special memory saving encoding. Default value: `512` ##### `slave_priority` Data type: `Integer[0]` The priority number for slave promotion by Sentinel Default value: `100` ##### `slave_read_only` Data type: `Boolean` You can configure a slave instance to accept writes or not. Default value: ``true`` ##### `slave_serve_stale_data` Data type: `Boolean` When a slave loses its connection with the master, or when the replication is still in progress, the slave can act in two different ways: 1) if slave-serve-stale-data is set to 'yes' (the default) the slave will still reply to client requests, possibly with out of date data, or the data set may just be empty if this is the first synchronization. 2) if slave-serve-stale-data is set to 'no' the slave will reply with an error "SYNC with master in progress" to all the kind of commands but to INFO and SLAVEOF. Default value: ``true`` ##### `slaveof` Data type: `Optional[String[1]]` Use slaveof to make a Redis instance a copy of another Redis server. Default value: ``undef`` ##### `slowlog_log_slower_than` Data type: `Integer[0]` Tells Redis what is the execution time, in microseconds, to exceed in order for the command to get logged. Default value: `10000` ##### `slowlog_max_len` Data type: `Integer[0]` Tells Redis what is the length to exceed in order for the command to get logged. Default value: `1024` ##### `stop_writes_on_bgsave_error` Data type: `Boolean` If false then Redis will continue to work as usual even if there are problems with disk, permissions, and so forth. Default value: ``true`` ##### `syslog_enabled` Data type: `Boolean` Enable/disable logging to the system logger. Default value: ``false`` ##### `syslog_facility` Data type: `Optional[String[1]]` Specify the syslog facility. Must be USER or between LOCAL0-LOCAL7. Default value: ``undef`` ##### `tcp_backlog` Data type: `Integer[0]` Sets the TCP backlog Default value: `511` ##### `tcp_keepalive` Data type: `Integer[0]` TCP keepalive. Default value: `0` ##### `timeout` Data type: `Integer[0]` Close the connection after a client is idle for N seconds (0 to disable). Default value: `0` ##### `ulimit` Data type: `Integer[0]` Limit the use of system-wide resources. Default value: `65536` ##### `unixsocket` Data type: `Variant[Stdlib::Absolutepath, Enum['']]` Define unix socket path Default value: `'/var/run/redis/redis.sock'` ##### `unixsocketperm` Data type: `Variant[Stdlib::Filemode, Enum['']]` Define unix socket file permissions Default value: `'0755'` ##### `workdir` Data type: `Stdlib::Absolutepath` The DB will be written inside this directory, with the filename specified above using the 'dbfilename' configuration directive. Default value: `$redis::params::workdir` ##### `workdir_mode` Data type: `Stdlib::Filemode` Adjust mode for data directory. Default value: `'0750'` ##### `zset_max_ziplist_entries` Data type: `Integer[0]` Set max entries for sorted sets. Default value: `128` ##### `zset_max_ziplist_value` Data type: `Integer[0]` Set max values for sorted sets. Default value: `64` ##### `cluster_enabled` Data type: `Boolean` Enables redis 3.0 cluster functionality Default value: ``false`` ##### `cluster_config_file` Data type: `String[1]` Config file for saving cluster nodes configuration. This file is never touched by humans. Only set if cluster_enabled is true Default value: `'nodes.conf'` ##### `cluster_node_timeout` Data type: `Integer[1]` Node timeout. Only set if cluster_enabled is true Default value: `5000` ##### `cluster_slave_validity_factor` Data type: `Integer[0]` Control variable to disable promoting slave in case of disconnection from master Only set if cluster_enabled is true Default value: `0` ##### `cluster_require_full_coverage` Data type: `Boolean` If false Redis Cluster will server queries even if requests about a subset of keys can be processed Only set if cluster_enabled is true Default value: ``true`` ##### `cluster_migration_barrier` Data type: `Integer[0]` Minimum number of slaves master will remain connected with, for another slave to migrate to a master which is no longer covered by any slave. Only set if cluster_enabled is true Default value: `1` ##### `instances` Data type: `Hash[String[1], Hash]` Iterate through multiple instance configurations Default value: `{}` ##### `output_buffer_limit_slave` Data type: `String[1]` Default value: `'256mb 64mb 60'` ##### `output_buffer_limit_pubsub` Data type: `String[1]` Default value: `'32mb 8mb 60'` ##### `manage_service_file` Data type: `Boolean` Default value: ``false`` ##### `minimum_version` Data type: `String[1]` Default value: `$redis::params::minimum_version` ### `redis::administration` -Allows various adminstrative settings for Redis -As documented in the FAQ and https://redis.io/topics/admin +As documented in the FAQ and https://redis.io/topics/admin. +For disabling Transparent Huge Pages (THP), use separate module such as: +https://forge.puppet.com/modules/alexharvey/disable_transparent_hugepage * **See also** * https://redis.io/topics/admin #### Examples ##### ```puppet include redis::administration ``` ##### ```puppet class {'redis::administration': - disable_thp => false, + enable_overcommit_memory => false, } ``` #### Parameters The following parameters are available in the `redis::administration` class. ##### `enable_overcommit_memory` Data type: `Boolean` Enable the overcommit memory setting Default value: ``true`` -##### `disable_thp` - -Data type: `Boolean` - -Disable Transparent Huge Pages - -Default value: ``true`` - ##### `somaxconn` Data type: `Integer[0]` Set somaxconn value Default value: `65535` ### `redis::globals` Set a global config for Redis #### Parameters The following parameters are available in the `redis::globals` class. ##### `scl` Data type: `Optional[String]` Use a specific Software CoLlection on Red Hat based systems Default value: ``undef`` ### `redis::sentinel` Install redis-sentinel #### Examples ##### Basic inclusion ```puppet include redis::sentinel ``` ##### Configuring options ```puppet class {'redis::sentinel': down_after => 80000, log_file => '/var/log/redis/sentinel.log', } ``` #### Parameters The following parameters are available in the `redis::sentinel` class. ##### `auth_pass` Data type: `Optional[String[1]]` The password to use to authenticate with the master and slaves. Default value: ``undef`` ##### `config_file` Data type: `Stdlib::Absolutepath` The location and name of the sentinel config file. Default value: `$redis::params::sentinel_config_file` ##### `config_file_orig` Data type: `Stdlib::Absolutepath` The location and name of a config file that provides the source of the sentinel config file. Two different files are needed because sentinel itself writes to its own config file and we do not want override that when puppet is run unless there are changes from the manifests. Default value: `$redis::params::sentinel_config_file_orig` ##### `config_file_mode` Data type: `Stdlib::Filemode` Permissions of config file. Default value: `'0644'` ##### `conf_template` Data type: `String[1]` Define which template to use. Default value: `'redis/redis-sentinel.conf.erb'` ##### `daemonize` Data type: `Boolean` Have Redis sentinel run as a daemon. Default value: `$redis::params::sentinel_daemonize` ##### `down_after` Data type: `Integer[1]` Number of milliseconds the master (or any attached slave or sentinel) should be unreachable (as in, not acceptable reply to PING, continuously, for the specified period) in order to consider it in S_DOWN state. Default value: `30000` ##### `failover_timeout` Data type: `Integer[1]` Specify the failover timeout in milliseconds. Default value: `180000` ##### `log_file` Data type: `Stdlib::Absolutepath` Specify where to write log entries. Default value: `$redis::params::sentinel_log_file` ##### `log_level` Data type: `Redis::LogLevel` Specify how much we should log. Default value: `'notice'` ##### `master_name` Data type: `String[1]` Specify the name of the master redis server. The valid charset is A-z 0-9 and the three characters ".-_". Default value: `'mymaster'` ##### `redis_host` Data type: `Stdlib::Host` Specify the bound host of the master redis server. Default value: `'127.0.0.1'` ##### `redis_port` Data type: `Stdlib::Port` Specify the port of the master redis server. Default value: `6379` ##### `protected_mode` Data type: `Boolean` Whether protected mode is enabled or not. Only applicable when no bind is set. Default value: `$redis::params::sentinel_protected_mode` ##### `package_name` Data type: `String[1]` The name of the package that installs sentinel. Default value: `$redis::params::sentinel_package_name` ##### `package_ensure` Data type: `String[1]` Do we ensure this package. Default value: `'present'` ##### `parallel_sync` Data type: `Integer[0]` How many slaves can be reconfigured at the same time to use a new master after a failover. Default value: `1` ##### `pid_file` Data type: `Stdlib::Absolutepath` If sentinel is daemonized it will write its pid at this location. Default value: `$redis::params::sentinel_pid_file` ##### `quorum` Data type: `Integer[1]` Number of sentinels that must agree that a master is down to signal sdown state. Default value: `2` ##### `sentinel_bind` Data type: `Variant[Undef, Stdlib::IP::Address, Array[Stdlib::IP::Address]]` Allow optional sentinel server ip binding. Can help overcome issues arising from protect-mode added Redis 3.2 Default value: ``undef`` ##### `sentinel_port` Data type: `Stdlib::Port` The port of sentinel server. Default value: `26379` ##### `service_group` Data type: `String[1]` The group of the config file. Default value: `'redis'` ##### `service_name` Data type: `String[1]` The name of the service (for puppet to manage). Default value: `$redis::params::sentinel_service_name` ##### `service_user` Data type: `String[1]` The owner of the config file. Default value: `'redis'` ##### `service_enable` Data type: `Boolean` Enable the service at boot time. Default value: ``true`` ##### `working_dir` Data type: `Stdlib::Absolutepath` The directory into which sentinel will change to avoid mount conflicts. Default value: `$redis::params::sentinel_working_dir` ##### `notification_script` Data type: `Optional[Stdlib::Absolutepath]` Path to the notification script Default value: ``undef`` ##### `client_reconfig_script` Data type: `Optional[Stdlib::Absolutepath]` Path to the client-reconfig script Default value: ``undef`` ##### `service_ensure` Data type: `Stdlib::Ensure::Service` Default value: `'running'` ## Defined types ### `redis::instance` This is an defined type to allow the configuration of multiple redis instances on one machine without conflicts #### Examples ##### ```puppet redis::instance {'6380': port => 6380, } ``` #### Parameters The following parameters are available in the `redis::instance` defined type. ##### `activerehashing` Data type: `Boolean` Enable/disable active rehashing. Default value: `$redis::activerehashing` ##### `aof_load_truncated` Data type: `Boolean` Enable/disable loading truncated AOF file Default value: `$redis::aof_load_truncated` ##### `aof_rewrite_incremental_fsync` Data type: `Boolean` Enable/disable fsync for AOF file Default value: `$redis::aof_rewrite_incremental_fsync` ##### `appendfilename` Data type: `String[1]` The name of the append only file Default value: `$redis::appendfilename` ##### `appendfsync` Data type: `Enum['no', 'always', 'everysec']` Adjust fsync mode. Valid options: always, everysec, no. Default value: `$redis::appendfsync` ##### `appendonly` Data type: `Boolean` Enable/disable appendonly mode. Default value: `$redis::appendonly` ##### `auto_aof_rewrite_min_size` Data type: `String[1]` Adjust minimum size for auto-aof-rewrite. Default value: `$redis::auto_aof_rewrite_min_size` ##### `auto_aof_rewrite_percentage` Data type: `Integer[0]` Adjust percentatge for auto-aof-rewrite. Default value: `$redis::auto_aof_rewrite_percentage` ##### `bind` Data type: `Variant[Stdlib::IP::Address, Array[Stdlib::IP::Address]]` Configure which IP address(es) to listen on. To bind on all interfaces, use an empty array. Default value: `$redis::bind` ##### `config_file_orig` Data type: `Stdlib::Absolutepath` The location and name of a config file that provides the source Default value: `$redis::config_file_orig` ##### `config_file` Data type: `Stdlib::Absolutepath` Adjust main configuration file. Default value: `$redis::config_file` ##### `config_file_mode` Data type: `Stdlib::Filemode` Adjust permissions for configuration files. Default value: `$redis::config_file_mode` ##### `config_group` Data type: `String[1]` Adjust filesystem group for config files. Default value: `$redis::config_group` ##### `config_owner` Data type: `String[1]` Adjust filesystem owner for config files. Default value: `$redis::config_owner` ##### `conf_template` Data type: `String[1]` Define which template to use. Default value: `$redis::conf_template` ##### `daemonize` Data type: `Boolean` Have Redis run as a daemon. Default value: ``true`` ##### `databases` Data type: `Integer[1]` Set the number of databases. Default value: `$redis::databases` ##### `dbfilename` Data type: `Variant[String[1], Boolean]` The filename where to dump the DB Default value: `$redis::dbfilename` ##### `extra_config_file` Data type: `Optional[String]` Optional extra config file to include Default value: `$redis::extra_config_file` ##### `hash_max_ziplist_entries` Data type: `Integer[0]` Set max ziplist entries for hashes. Default value: `$redis::hash_max_ziplist_entries` ##### `hash_max_ziplist_value` Data type: `Integer[0]` Set max ziplist values for hashes. Default value: `$redis::hash_max_ziplist_value` ##### `hll_sparse_max_bytes` Data type: `Integer[0]` HyperLogLog sparse representation bytes limit Default value: `$redis::hll_sparse_max_bytes` ##### `hz` Data type: `Integer[1, 500]` Set redis background tasks frequency Default value: `$redis::hz` ##### `latency_monitor_threshold` Data type: `Integer[0]` Latency monitoring threshold in milliseconds Default value: `$redis::latency_monitor_threshold` ##### `list_max_ziplist_entries` Data type: `Integer[0]` Set max ziplist entries for lists. Default value: `$redis::list_max_ziplist_entries` ##### `list_max_ziplist_value` Data type: `Integer[0]` Set max ziplist values for lists. Default value: `$redis::list_max_ziplist_value` ##### `log_dir` Data type: `Stdlib::Absolutepath` Specify directory where to write log entries. Default value: `$redis::log_dir` ##### `log_dir_mode` Data type: `Stdlib::Filemode` Adjust mode for directory containing log files. Default value: `$redis::log_dir_mode` ##### `log_file` Data type: `Optional[Stdlib::Absolutepath]` Specify file where to write log entries. Default value: ``undef`` ##### `log_level` Data type: `Redis::LogLevel` Specify the server verbosity level. Default value: `$redis::log_level` ##### `masterauth` Data type: `Optional[String[1]]` If the master is password protected (using the "requirepass" configuration Default value: `$redis::masterauth` ##### `maxclients` Data type: `Integer[1]` Set the max number of connected clients at the same time. Default value: `$redis::maxclients` ##### `maxmemory` Data type: `Any` Don't use more memory than the specified amount of bytes. Default value: `$redis::maxmemory` ##### `maxmemory_policy` Data type: `Any` How Redis will select what to remove when maxmemory is reached. Default value: `$redis::maxmemory_policy` ##### `maxmemory_samples` Data type: `Any` Select as well the sample size to check. Default value: `$redis::maxmemory_samples` ##### `min_slaves_max_lag` Data type: `Integer[0]` The lag in seconds Default value: `$redis::min_slaves_max_lag` ##### `min_slaves_to_write` Data type: `Integer[0]` Minimum number of slaves to be in "online" state Default value: `$redis::min_slaves_to_write` ##### `no_appendfsync_on_rewrite` Data type: `Boolean` If you have latency problems turn this to 'true'. Otherwise leave it as Default value: `$redis::no_appendfsync_on_rewrite` ##### `notify_keyspace_events` Data type: `Optional[String[1]]` Which events to notify Pub/Sub clients about events happening Default value: `$redis::notify_keyspace_events` ##### `pid_file` Data type: `Stdlib::Absolutepath` Where to store the pid. Default value: `"/var/run/redis/redis-server-${name}.pid"` ##### `port` Data type: `Stdlib::Port` Configure which port to listen on. Default value: `$redis::port` ##### `protected_mode` Data type: `Boolean` Whether protected mode is enabled or not. Only applicable when no bind is set. Default value: `$redis::protected_mode` ##### `rdbcompression` Data type: `Boolean` Enable/disable compression of string objects using LZF when dumping. Default value: `$redis::rdbcompression` ##### `repl_backlog_size` Data type: `String[1]` The replication backlog size Default value: `$redis::repl_backlog_size` ##### `repl_backlog_ttl` Data type: `Integer[0]` The number of seconds to elapse before freeing backlog buffer Default value: `$redis::repl_backlog_ttl` ##### `repl_disable_tcp_nodelay` Data type: `Boolean` Enable/disable TCP_NODELAY on the slave socket after SYNC Default value: `$redis::repl_disable_tcp_nodelay` ##### `repl_ping_slave_period` Data type: `Integer[1]` Slaves send PINGs to server in a predefined interval. It's possible Default value: `$redis::repl_ping_slave_period` ##### `repl_timeout` Data type: `Integer[1]` Set the replication timeout for: Default value: `$redis::repl_timeout` ##### `requirepass` Data type: `Optional[String]` Require clients to issue AUTH before processing any other commands. Default value: `$redis::requirepass` ##### `save_db_to_disk` Data type: `Boolean` Set if save db to disk. Default value: `$redis::save_db_to_disk` ##### `save_db_to_disk_interval` Data type: `Hash` save the dataset every N seconds if there are at least M changes in the dataset Default value: `$redis::save_db_to_disk_interval` ##### `service_name` Data type: `String[1]` The service name for this instance Default value: `"redis-server-${name}"` ##### `service_enable` Data type: `Boolean` Enable/disable daemon at boot. Default value: `$redis::service_enable` ##### `service_ensure` Data type: `Stdlib::Ensure::Service` Specify if the server should be running. Default value: `$redis::service_ensure` ##### `service_group` Data type: `String[1]` Specify which group to run as. Default value: `$redis::service_group` ##### `service_user` Data type: `String[1]` Specify which user to run as. Default value: `$redis::service_user` ##### `set_max_intset_entries` Data type: `Integer[0]` The following configuration setting sets the limit in the size of the set in order to use this special memory saving encoding. Default value: `$redis::set_max_intset_entries` ##### `slave_priority` Data type: `Integer[0]` The priority number for slave promotion by Sentinel Default value: `$redis::slave_priority` ##### `slave_read_only` Data type: `Boolean` You can configure a slave instance to accept writes or not. Default value: `$redis::slave_read_only` ##### `slave_serve_stale_data` Data type: `Boolean` When a slave loses its connection with the master, or when the replication is still in progress, the slave can act in two different ways: 1) if slave-serve-stale-data is set to 'yes' (the default) the slave will still reply to client requests, possibly with out of date data, or the data set may just be empty if this is the first synchronization. 2) if slave-serve-stale-data is set to 'no' the slave will reply with an error "SYNC with master in progress" to all the kind of commands but to INFO and SLAVEOF. Default value: `$redis::slave_serve_stale_data` ##### `slaveof` Data type: `Optional[String[1]]` Use slaveof to make a Redis instance a copy of another Redis server. Default value: `$redis::slaveof` ##### `slowlog_log_slower_than` Data type: `Integer[0]` Tells Redis what is the execution time, in microseconds, to exceed in order for the command to get logged. Default value: `$redis::slowlog_log_slower_than` ##### `slowlog_max_len` Data type: `Integer[0]` Tells Redis what is the length to exceed in order for the command to get logged. Default value: `$redis::slowlog_max_len` ##### `stop_writes_on_bgsave_error` Data type: `Boolean` If false then Redis will continue to work as usual even if there are problems with disk, permissions, and so forth. Default value: `$redis::stop_writes_on_bgsave_error` ##### `syslog_enabled` Data type: `Boolean` Enable/disable logging to the system logger. Default value: `$redis::syslog_enabled` ##### `syslog_facility` Data type: `Optional[String[1]]` Specify the syslog facility. Must be USER or between LOCAL0-LOCAL7. Default value: `$redis::syslog_facility` ##### `tcp_backlog` Data type: `Integer[0]` Sets the TCP backlog Default value: `$redis::tcp_backlog` ##### `tcp_keepalive` Data type: `Integer[0]` TCP keepalive. Default value: `$redis::tcp_keepalive` ##### `timeout` Data type: `Integer[0]` Close the connection after a client is idle for N seconds (0 to disable). Default value: `$redis::timeout` ##### `ulimit` Data type: `Integer[0]` Limit the use of system-wide resources. Default value: `$redis::ulimit` ##### `unixsocket` Data type: `Variant[Stdlib::Absolutepath, Enum['']]` Define unix socket path Default value: `"/var/run/redis/redis-server-${name}.sock"` ##### `unixsocketperm` Data type: `Variant[Stdlib::Filemode , Enum['']]` Define unix socket file permissions Default value: `$redis::unixsocketperm` ##### `workdir` Data type: `Stdlib::Absolutepath` The DB will be written inside this directory, with the filename specified above using the 'dbfilename' configuration directive. Default value: `"${redis::workdir}/redis-server-${name}"` ##### `workdir_mode` Data type: `Stdlib::Filemode` Adjust mode for data directory. Default value: `$redis::workdir_mode` ##### `zset_max_ziplist_entries` Data type: `Integer[0]` Set max entries for sorted sets. Default value: `$redis::zset_max_ziplist_entries` ##### `zset_max_ziplist_value` Data type: `Integer[0]` Set max values for sorted sets. Default value: `$redis::zset_max_ziplist_value` ##### `cluster_enabled` Data type: `Boolean` Enables redis 3.0 cluster functionality Default value: `$redis::cluster_enabled` ##### `cluster_config_file` Data type: `String[1]` Config file for saving cluster nodes configuration. This file is never touched by humans. Only set if cluster_enabled is true Default value: `$redis::cluster_config_file` ##### `cluster_node_timeout` Data type: `Integer[1]` Node timeout. Only set if cluster_enabled is true Default value: `$redis::cluster_node_timeout` ##### `cluster_slave_validity_factor` Data type: `Integer[0]` Control variable to disable promoting slave in case of disconnection from master Only set if cluster_enabled is true Default value: `$redis::cluster_slave_validity_factor` ##### `cluster_require_full_coverage` Data type: `Boolean` If false Redis Cluster will server queries even if requests about a subset of keys can be processed Only set if cluster_enabled is true Default value: `$redis::cluster_require_full_coverage` ##### `cluster_migration_barrier` Data type: `Integer[0]` Minimum number of slaves master will remain connected with, for another slave to migrate to a master which is no longer covered by any slave Only set if cluster_enabled is true Default value: `$redis::cluster_migration_barrier` ##### `output_buffer_limit_slave` Data type: `String[1]` Default value: `$redis::output_buffer_limit_slave` ##### `output_buffer_limit_pubsub` Data type: `String[1]` Default value: `$redis::output_buffer_limit_pubsub` ##### `managed_by_cluster_manager` Data type: `Boolean` Default value: `$redis::managed_by_cluster_manager` ##### `manage_service_file` Data type: `Boolean` Default value: ``true`` ## Functions ### `redis::get` Type: Ruby 4.x API +Takes two arguments with an optional third. The first being a string +value of the key to be looked up, the second is the URL to the Redis service +and the third optional argument is a default value to be used if the lookup +fails. + +example usage +``` +$version = redis::get('version.myapp', 'redis://redis.example.com:6379') +$version_with_default = redis::get('version.myapp', 'redis://redis.example.com:6379', $::myapp_version) ``` #### `redis::get(String[1] $key, Redis::RedisUrl $url, Optional[String] $default)` +Takes two arguments with an optional third. The first being a string +value of the key to be looked up, the second is the URL to the Redis service +and the third optional argument is a default value to be used if the lookup +fails. + +example usage +``` +$version = redis::get('version.myapp', 'redis://redis.example.com:6379') +$version_with_default = redis::get('version.myapp', 'redis://redis.example.com:6379', $::myapp_version) ``` Returns: `Optional[String]` Returns the value of the key from Redis ##### `key` Data type: `String[1]` The key to look up in redis ##### `url` Data type: `Redis::RedisUrl` The endpoint of the Redis instance ##### `default` Data type: `Optional[String]` The value to return if the key is not found or the connection to Redis fails ## Data types ### `Redis::LogLevel` This can be one of: * debug (a lot of information, useful for development/testing) * verbose (many rarely useful info, but not a mess like the debug level) * notice (moderately verbose, what you want in production probably) * warning (only very important / critical messages are logged) Alias of `Enum['debug', 'verbose', 'notice', 'warning']` ### `Redis::RedisUrl` The Redis::RedisUrl data type. Alias of `Pattern[/(^redis:\/\/)/]` ## Tasks ### `redis_cli` Executes a redis-cli command on the target system **Supports noop?** false #### Parameters ##### `command` Data type: `String[1]` The command to run, including all arguments diff --git a/lib/puppet/functions/redis/get.rb b/lib/puppet/functions/redis/get.rb index ad6d484..1e5f07d 100644 --- a/lib/puppet/functions/redis/get.rb +++ b/lib/puppet/functions/redis/get.rb @@ -1,32 +1,32 @@ require 'redis' -# Returns the value of the key being looked up or `undef` if the key does not -# exist. Takes two arguments with an optional third. The first being a string +# @summary Returns the value of the key being looked up or `undef` if the key does not exist. +# Takes two arguments with an optional third. The first being a string # value of the key to be looked up, the second is the URL to the Redis service # and the third optional argument is a default value to be used if the lookup # fails. # # example usage # ``` # $version = redis::get('version.myapp', 'redis://redis.example.com:6379') # $version_with_default = redis::get('version.myapp', 'redis://redis.example.com:6379', $::myapp_version) # ``` Puppet::Functions.create_function(:'redis::get') do # @param key The key to look up in redis # @param url The endpoint of the Redis instance # @param default The value to return if the key is not found or the connection to Redis fails # @return Returns the value of the key from Redis dispatch :get do param 'String[1]', :key param 'Redis::RedisUrl', :url optional_param 'String', :default return_type 'Optional[String]' end def get(key, url, default = nil) Redis.new(url: url).get(key) || default rescue Redis::CannotConnectError, SocketError => e raise Puppet::Error, "connection to redis server failed - #{e}" unless default Puppet.debug "Connection to redis failed with #{e} - Returning default value of #{default}" default end end diff --git a/manifests/administration.pp b/manifests/administration.pp index dc2fcdf..d8c343e 100644 --- a/manifests/administration.pp +++ b/manifests/administration.pp @@ -1,49 +1,39 @@ -# Allows various adminstrative settings for Redis -# As documented in the FAQ and https://redis.io/topics/admin +# @summary Allows various administrative settings for Redis +# As documented in the FAQ and https://redis.io/topics/admin. +# For disabling Transparent Huge Pages (THP), use separate module such as: +# https://forge.puppet.com/modules/alexharvey/disable_transparent_hugepage # # @example # include redis::administration # # @example # class {'redis::administration': -# disable_thp => false, +# enable_overcommit_memory => false, # } # # @param enable_overcommit_memory # Enable the overcommit memory setting -# @param disable_thp -# Disable Transparent Huge Pages # @param somaxconn # Set somaxconn value # # @author - Peter Souter # @see https://redis.io/topics/admin # class redis::administration ( Boolean $enable_overcommit_memory = true, - Boolean $disable_thp = true, Integer[0] $somaxconn = 65535, ) { if $enable_overcommit_memory { sysctl { 'vm.overcommit_memory': ensure => 'present', value => '1', } } - if $disable_thp { - exec { 'Disable Hugepages': - command => 'echo never > /sys/kernel/mm/transparent_hugepage/enabled', - path => ['/sbin', '/usr/sbin', '/bin', '/usr/bin'], - onlyif => 'test -f /sys/kernel/mm/transparent_hugepage/enabled', - unless => 'cat /sys/kernel/mm/transparent_hugepage/enabled | grep "\[never\]"', - } - } - if $somaxconn > 0 { sysctl { 'net.core.somaxconn': ensure => 'present', value => $somaxconn, } } } diff --git a/spec/acceptance/suites/default/redis_adminstration_spec.rb b/spec/acceptance/suites/default/redis_adminstration_spec.rb index 89b800b..2e850fc 100644 --- a/spec/acceptance/suites/default/redis_adminstration_spec.rb +++ b/spec/acceptance/suites/default/redis_adminstration_spec.rb @@ -1,32 +1,28 @@ require 'spec_helper_acceptance' # systcl settings are untestable in docker describe 'redis::administration', unless: default['hypervisor'] =~ %r{docker} do it 'runs successfully' do pp = <<-EOS include redis include redis::administration EOS # Apply twice to ensure no errors the second time. apply_manifest(pp, catch_failures: true) apply_manifest(pp, catch_changes: true) end describe file('/proc/sys/vm/overcommit_memory') do its(:content) { is_expected.to eq("1\n") } end - describe file('/sys/kernel/mm/transparent_hugepage/enabled') do - its(:content) { is_expected.to eq("always madvise [never]\n") } - end - describe file('/proc/sys/net/core/somaxconn') do its(:content) { is_expected.to eq("65535\n") } end describe command('timeout 1s redis-server --port 7777 --loglevel verbose') do its(:stderr) { is_expected.not_to match(%r{WARNING}) } its(:exit_status) { is_expected.to eq(124) } end end diff --git a/spec/classes/redis_administration_spec.rb b/spec/classes/redis_administration_spec.rb index 9f486fd..15dd78d 100644 --- a/spec/classes/redis_administration_spec.rb +++ b/spec/classes/redis_administration_spec.rb @@ -1,28 +1,19 @@ require 'spec_helper' describe 'redis::administration' do context 'should set kernel and system values' do it do is_expected.to contain_sysctl('vm.overcommit_memory').with( 'ensure' => 'present', 'value' => '1' ) end - it do - is_expected.to contain_exec('Disable Hugepages').with( - 'command' => 'echo never > /sys/kernel/mm/transparent_hugepage/enabled', - 'path' => ['/sbin', '/usr/sbin', '/bin', '/usr/bin'], - 'onlyif' => 'test -f /sys/kernel/mm/transparent_hugepage/enabled', - 'unless' => 'cat /sys/kernel/mm/transparent_hugepage/enabled | grep "\\[never\\]"' - ) - end - it do is_expected.to contain_sysctl('net.core.somaxconn').with( 'ensure' => 'present', 'value' => '65535' ) end end end