diff --git a/REFERENCE.md b/REFERENCE.md index a812c96..92b8317 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -1,2263 +1,2094 @@ # 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::config`](#redisconfig): = Class: redis::config This class provides configuration for Redis. -* [`redis::install`](#redisinstall): = Class: redis::install This class installs the application. -* [`redis::params`](#redisparams): = Class: redis::params This class provides a number of parameters. -* [`redis::preinstall`](#redispreinstall): = Class: redis::preinstall This class provides anything required by the install class. Such as package repositories. -* [`redis::sentinel`](#redissentinel): = Class: redis::sentinel This class installs redis-sentinel == Parameters: [*auth_pass*] The password to use to authenticate with the m -* [`redis::service`](#redisservice): = Class: redis::service This class manages the Redis daemon. +* [`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): 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 bein **Data types** * [`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: `String` Enable/disable active rehashing. Default value: $redis::params::activerehashing ##### `aof_load_truncated` Data type: `String` Enable/disable loading truncated AOF file Default value: $redis::params::aof_load_truncated ##### `aof_rewrite_incremental_fsync` Data type: `String` Enable/disable fsync for AOF file Default value: $redis::params::aof_rewrite_incremental_fsync ##### `appendfilename` Data type: `String` The name of the append only file Default value: $redis::params::appendfilename ##### `appendfsync` Data type: `Enum['no', 'always', 'everysec']` Adjust fsync mode. Default: `everysec` Default value: $redis::params::appendfsync ##### `appendonly` Data type: `String` Enable/disable appendonly mode. Default value: $redis::params::appendonly ##### `auto_aof_rewrite_min_size` Data type: `String` Adjust minimum size for auto-aof-rewrite. Default value: $redis::params::auto_aof_rewrite_min_size ##### `auto_aof_rewrite_percentage` Data type: `String` Adjust percentatge for auto-aof-rewrite. Default value: $redis::params::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::params::bind ##### `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: `String` The location and name of a config file that provides the source Default value: $redis::params::config_file_orig ##### `config_file` Data type: `String` Adjust main configuration file. Default value: $redis::params::config_file ##### `config_file_mode` Data type: `Stdlib::Filemode` Adjust permissions for configuration files. Default value: $redis::params::config_file_mode ##### `config_group` Data type: `String` Adjust filesystem group for config files. Default value: $redis::params::config_group ##### `config_owner` Data type: `String` Adjust filesystem owner for config files. Default value: $redis::params::config_owner ##### `conf_template` Data type: `String` Define which template to use. Default value: $redis::params::conf_template ##### `daemonize` Data type: `String` Have Redis run as a daemon. Default value: $redis::params::daemonize ##### `default_install` Data type: `Boolean` Configure a default install of redis. Default value: $redis::params::default_install ##### `databases` Data type: `String` Set the number of databases. Default value: $redis::params::databases ##### `dbfilename` Data type: `String` The filename where to dump the DB Default value: $redis::params::dbfilename ##### `extra_config_file` Data type: `String` Description Default value: $redis::params::extra_config_file ##### `hash_max_ziplist_entries` Data type: `String` Set max ziplist entries for hashes. Default value: $redis::params::hash_max_ziplist_entries ##### `hash_max_ziplist_value` Data type: `String` Set max ziplist values for hashes. Default value: $redis::params::hash_max_ziplist_value ##### `hll_sparse_max_bytes` Data type: `String` HyperLogLog sparse representation bytes limit Default value: $redis::params::hll_sparse_max_bytes ##### `hz` Data type: `String` Set redis background tasks frequency Default value: $redis::params::hz ##### `latency_monitor_threshold` Data type: `String` Latency monitoring threshold in milliseconds Default value: $redis::params::latency_monitor_threshold ##### `list_max_ziplist_entries` Data type: `String` Set max ziplist entries for lists. Default value: $redis::params::list_max_ziplist_entries ##### `list_max_ziplist_value` Data type: `String` Set max ziplist values for lists. Default value: $redis::params::list_max_ziplist_value ##### `log_dir` Data type: `Stdlib::Absolutepath` Specify directory where to write log entries. Default value: $redis::params::log_dir ##### `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: $redis::params::log_file ##### `log_level` Data type: `String` Specify the server verbosity level. Default value: $redis::params::log_level ##### `manage_repo` Data type: `Boolean` Enable/disable upstream repository configuration. Default value: $redis::params::manage_repo ##### `manage_package` Data type: `Boolean` Enable/disable management of package Default value: $redis::params::manage_package ##### `managed_by_cluster_manager` Data type: `String` Choose if redis will be managed by a cluster manager such as pacemaker or rgmanager Default value: $redis::params::managed_by_cluster_manager ##### `masterauth` Data type: `String` If the master is password protected (using the "requirepass" configuration Default value: $redis::params::masterauth ##### `maxclients` Data type: `String` Set the max number of connected clients at the same time. Default value: $redis::params::maxclients ##### `maxmemory` Data type: `String` Don't use more memory than the specified amount of bytes. Default value: $redis::params::maxmemory ##### `maxmemory_policy` Data type: `String` How Redis will select what to remove when maxmemory is reached. Default value: $redis::params::maxmemory_policy ##### `maxmemory_samples` Data type: `String` Select as well the sample size to check. Default value: $redis::params::maxmemory_samples ##### `min_slaves_max_lag` Data type: `String` The lag in seconds Default value: $redis::params::min_slaves_max_lag ##### `min_slaves_to_write` Data type: `String` Minimum number of slaves to be in "online" state Default value: $redis::params::min_slaves_to_write ##### `no_appendfsync_on_rewrite` Data type: `String` If you have latency problems turn this to 'true'. Otherwise leave it as Default value: $redis::params::no_appendfsync_on_rewrite ##### `notify_keyspace_events` Data type: `String` Which events to notify Pub/Sub clients about events happening Default value: $redis::params::notify_keyspace_events ##### `notify_service` Data type: `String` You may disable service reloads when config files change if you Default value: $redis::params::notify_service ##### `package_ensure` Data type: `String` Default action for package. Default value: $redis::params::package_ensure ##### `package_name` Data type: `String` Upstream package name. Default value: $redis::params::package_name ##### `pid_file` Data type: `String` Where to store the pid. Default value: $redis::params::pid_file ##### `port` Data type: `Stdlib::Port` Configure which port to listen on. Default value: $redis::params::port ##### `protected_mode` Data type: `String` Whether protected mode is enabled or not. Only applicable when no bind is set. Default value: $redis::params::protected_mode ##### `ppa_repo` Data type: `String` Specify upstream (Ubuntu) PPA entry. Default value: $redis::params::ppa_repo ##### `rdbcompression` Data type: `String` Enable/disable compression of string objects using LZF when dumping. Default value: $redis::params::rdbcompression ##### `repl_backlog_size` Data type: `String` The replication backlog size Default value: $redis::params::repl_backlog_size ##### `repl_backlog_ttl` Data type: `String` The number of seconds to elapse before freeing backlog buffer Default value: $redis::params::repl_backlog_ttl ##### `repl_disable_tcp_nodelay` Data type: `String` Enable/disable TCP_NODELAY on the slave socket after SYNC Default value: $redis::params::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::params::repl_ping_slave_period ##### `repl_timeout` Data type: `String` Set the replication timeout for: Default value: $redis::params::repl_timeout ##### `requirepass` Data type: `String` Require clients to issue AUTH before processing any other commands. Default value: $redis::params::requirepass ##### `save_db_to_disk` Data type: `String` Set if save db to disk. Default value: $redis::params::save_db_to_disk ##### `save_db_to_disk_interval` Data type: `String` save the dataset every N seconds if there are at least M changes in the dataset Default value: $redis::params::save_db_to_disk_interval ##### `service_manage` Data type: `Boolean` Specify if the service should be part of the catalog. Default value: $redis::params::service_manage ##### `service_enable` Data type: `String` Enable/disable daemon at boot. Default value: $redis::params::service_enable ##### `service_ensure` Data type: `String` Specify if the server should be running. Default value: $redis::params::service_ensure ##### `service_group` Data type: `String` Specify which group to run as. Default value: $redis::params::service_group ##### `service_hasrestart` Data type: `String` Does the init script support restart? Default value: $redis::params::service_hasrestart ##### `service_hasstatus` Data type: `String` Does the init script support status? Default value: $redis::params::service_hasstatus ##### `service_name` Data type: `String` Specify the service name for Init or Systemd. Default value: $redis::params::service_name ##### `service_provider` Data type: `String` Specify the service provider to use Default value: $redis::params::service_provider ##### `service_user` Data type: `String` Specify which user to run as. Default value: $redis::params::service_user ##### `set_max_intset_entries` Data type: `String` The following configuration setting sets the limit in the size of the set in order to use this special memory saving encoding. Default: 512 Default value: $redis::params::set_max_intset_entries ##### `slave_priority` Data type: `String` The priority number for slave promotion by Sentinel Default value: $redis::params::slave_priority ##### `slave_read_only` Data type: `String` You can configure a slave instance to accept writes or not. Default value: $redis::params::slave_read_only ##### `slave_serve_stale_data` Data type: `String` 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: true Default value: $redis::params::slave_serve_stale_data ##### `slaveof` Data type: `String` Use slaveof to make a Redis instance a copy of another Redis server. Default value: $redis::params::slaveof ##### `slowlog_log_slower_than` Data type: `String` Tells Redis what is the execution time, in microseconds, to exceed in order for the command to get logged. Default: 10000 Default value: $redis::params::slowlog_log_slower_than ##### `slowlog_max_len` Data type: `String` Tells Redis what is the length to exceed in order for the command to get logged. Default: 1024 Default value: $redis::params::slowlog_max_len ##### `stop_writes_on_bgsave_error` Data type: `String` If false then Redis will continue to work as usual even if there are problems with disk, permissions, and so forth. Default: true Default value: $redis::params::stop_writes_on_bgsave_error ##### `syslog_enabled` Data type: `String` Enable/disable logging to the system logger. Default value: $redis::params::syslog_enabled ##### `syslog_facility` Data type: `String` Specify the syslog facility. Must be USER or between LOCAL0-LOCAL7. Default: undef Default value: $redis::params::syslog_facility ##### `tcp_backlog` Data type: `String` Sets the TCP backlog Default value: $redis::params::tcp_backlog ##### `tcp_keepalive` Data type: `String` TCP keepalive. Default value: $redis::params::tcp_keepalive ##### `timeout` Data type: `String` Close the connection after a client is idle for N seconds (0 to disable). Default value: $redis::params::timeout ##### `ulimit` Data type: `String` Limit the use of system-wide resources. Default value: $redis::params::ulimit ##### `unixsocket` Data type: `String` Define unix socket path Default value: $redis::params::unixsocket ##### `unixsocketperm` Data type: `String` Define unix socket file permissions Default value: $redis::params::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: /var/lib/redis/ Default value: $redis::params::workdir ##### `workdir_mode` Data type: `Stdlib::Filemode` Adjust mode for data directory. Default value: $redis::params::workdir_mode ##### `zset_max_ziplist_entries` Data type: `String` Set max entries for sorted sets. Default value: $redis::params::zset_max_ziplist_entries ##### `zset_max_ziplist_value` Data type: `String` Set max values for sorted sets. Default value: $redis::params::zset_max_ziplist_value ##### `cluster_enabled` Data type: `Boolean` Enables redis 3.0 cluster functionality Default value: $redis::params::cluster_enabled ##### `cluster_config_file` Data type: `String` Config file for saving cluster nodes configuration. This file is never touched by humans. Only set if cluster_enabled is true Default: nodes.conf Default value: $redis::params::cluster_config_file ##### `cluster_node_timeout` Data type: `String` Node timeout Only set if cluster_enabled is true Default: 5000 Default value: $redis::params::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: 0 Default value: $redis::params::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: true Default value: $redis::params::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: 1 Default value: $redis::params::cluster_migration_barrier ##### `output_buffer_limit_slave` Data type: `Any` Default value: $redis::params::output_buffer_limit_slave ##### `output_buffer_limit_pubsub` Data type: `Any` Default value: $redis::params::output_buffer_limit_pubsub ##### `manage_service_file` Data type: `Boolean` Default value: $redis::params::manage_service_file ### redis::administration Allows various adminstrative settings for Redis As documented in the FAQ and https://redis.io/topics/admin #### Examples ##### ```puppet include redis::administration ``` ##### ```puppet class {'redis::administration': disable_thp => false, } ``` #### Parameters The following parameters are available in the `redis::administration` class. ##### `enable_overcommit_memory` Data type: `Boolean` Enable the overcommit memory setting (Defaults to true) Default value: `true` ##### `disable_thp` Data type: `Boolean` Disable Transparent Huge Pages (Defaults to true) Default value: `true` ##### `somaxconn` Data type: `String` Set somaxconn value (Defaults to '65535') Default value: '65535' -### redis::config - -= Class: redis::config - -This class provides configuration for Redis. - -### redis::install - -= Class: redis::install - -This class installs the application. - -### redis::params - -= Class: redis::params - -This class provides a number of parameters. - -### redis::preinstall - -= Class: redis::preinstall - -This class provides anything required by the install class. -Such as package repositories. - ### redis::sentinel -= Class: redis::sentinel - -This class installs redis-sentinel - -== Parameters: - - -[*auth_pass*] - The password to use to authenticate with the master and slaves. - - Default: undef - -[*config_file*] - The location and name of the sentinel config file. - - Default for deb: /etc/redis/redis-sentinel.conf - Default for rpm: /etc/redis-sentinel.conf - -[*config_file_orig*] - 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 for deb: /etc/redis/redis-sentinel.conf.puppet - Default for rpm: /etc/redis-sentinel.conf.puppet - -[*config_file_mode*] - Permissions of config file. - - Default: 0644 - -[*conf_template*] - Define which template to use. - - Default: redis/redis-sentinel.conf.erb - -[*daemonize*] - Have Redis sentinel run as a daemon. - - Default: true - -[*down_after*] - 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: 30000 - -[*failover_timeout*] - Specify the failover timeout in milliseconds. - - Default: 180000 - -[*init_script*] - Specifiy the init script that will be created for sentinel. - - Default: undef on rpm, /etc/init.d/redis-sentinel on apt. - -[*log_file*] - Specify where to write log entries. - - Default: /var/log/redis/redis.log - -[*log_level*] - Specify how much we should log. - - Default: notice - -[*master_name*] - Specify the name of the master redis server. - The valid charset is A-z 0-9 and the three characters ".-_". - - Default: mymaster - -[*redis_host*] - Specify the bound host of the master redis server. +Install redis-sentinel - Default: 127.0.0.1 - -[*redis_port*] - Specify the port of the master redis server. - - Default: 6379 - -[*package_name*] - The name of the package that installs sentinel. - - Default: 'redis-server' on apt, 'redis' on rpm - -[*package_ensure*] - Do we ensure this package. - - Default: 'present' - -[*parallel_sync*] - How many slaves can be reconfigured at the same time to use a - new master after a failover. - - Default: 1 - -[*pid_file*] - If sentinel is daemonized it will write its pid at this location. - - Default: /var/run/redis/redis-sentinel.pid - -[*quorum*] - Number of sentinels that must agree that a master is down to - signal sdown state. - - Default: 2 - -[*sentinel_bind*] - Allow optional sentinel server ip binding. Can help overcome - issues arising from protect-mode added Redis 3.2 - - Default: undef - -[*sentinel_port*] - The port of sentinel server. - - Default: 26379 - -[*service_group*] - The group of the config file. - - Default: redis - -[*service_name*] - The name of the service (for puppet to manage). - - Default: redis-sentinel - -[*service_owner*] - The owner of the config file. - - Default: redis - -[*service_enable*] - Enable the service at boot time. - - Default: true - -[*working_dir*] - The directory into which sentinel will change to avoid mount - conflicts. - - Default: /tmp - -[*notification_script*] - Path to the notification script - - Default: undef - -[*client_reconfig_script*] - Path to the client-reconfig script +#### Examples - Default: undef -== Actions: - - Install and configure Redis Sentinel +##### Basic inclusion -== Sample Usage: +```puppet +include redis::sentinel +``` - class { 'redis::sentinel': } +##### Configuring options - class {'redis::sentinel': - down_after => 80000, - log_file => '/var/log/redis/sentinel.log', - } +```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: `Any` +The password to use to authenticate with the master and slaves. - -Default value: $redis::params::sentinel_auth_pass +Default value: `undef` ##### `config_file` Data type: `Any` - +The location and name of the sentinel config file. Default value: $redis::params::sentinel_config_file ##### `config_file_orig` Data type: `Any` - +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: $redis::params::sentinel_config_file_mode +Default value: '0644' ##### `conf_template` -Data type: `Any` - +Data type: `String[1]` +Define which template to use. -Default value: $redis::params::sentinel_conf_template +Default value: 'redis/redis-sentinel.conf.erb' ##### `daemonize` Data type: `Any` - +Have Redis sentinel run as a daemon. Default value: $redis::params::sentinel_daemonize ##### `down_after` Data type: `Any` +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: $redis::params::sentinel_down_after +Default value: 30000 ##### `failover_timeout` Data type: `Any` +Specify the failover timeout in milliseconds. - -Default value: $redis::params::sentinel_failover_timeout +Default value: 180000 ##### `init_script` Data type: `Any` - +Specifiy the init script that will be created for sentinel. Default value: $redis::params::sentinel_init_script -##### `init_template` +##### `log_file` Data type: `Any` +Specify where to write log entries. - -Default value: $redis::params::sentinel_init_template +Default value: $redis::params::log_file ##### `log_level` Data type: `Any` - +Specify how much we should log. Default value: $redis::params::log_level -##### `log_file` - -Data type: `Any` - - - -Default value: $redis::params::log_file - ##### `master_name` -Data type: `Any` - +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: $redis::params::sentinel_master_name +Default value: 'mymaster' ##### `redis_host` Data type: `Stdlib::Host` +Specify the bound host of the master redis server. - -Default value: $redis::params::sentinel_redis_host +Default value: '127.0.0.1' ##### `redis_port` Data type: `Stdlib::Port` +Specify the port of the master redis server. - -Default value: $redis::params::port +Default value: 26379 ##### `package_name` Data type: `Any` - +The name of the package that installs sentinel. Default value: $redis::params::sentinel_package_name ##### `package_ensure` -Data type: `Any` - +Data type: `String[1]` +Do we ensure this package. -Default value: $redis::params::sentinel_package_ensure +Default value: 'present' ##### `parallel_sync` -Data type: `Any` - +Data type: `Integer[0]` +How many slaves can be reconfigured at the same time to use a +new master after a failover. -Default value: $redis::params::sentinel_parallel_sync +Default value: 1 ##### `pid_file` -Data type: `Any` - +Data type: `Stdlib::Absolutepath` +If sentinel is daemonized it will write its pid at this location. -Default value: $redis::params::sentinel_pid_file +Default value: '/var/run/redis/redis-sentinel.pid' ##### `quorum` -Data type: `Any` - +Data type: `Integer[0]` +Number of sentinels that must agree that a master is down to +signal sdown state. -Default value: $redis::params::sentinel_quorum +Default value: 2 ##### `sentinel_bind` Data type: `Any` +Allow optional sentinel server ip binding. Can help overcome +issues arising from protect-mode added Redis 3.2 - -Default value: $redis::params::sentinel_bind +Default value: `undef` ##### `sentinel_port` Data type: `Stdlib::Port` - +The port of sentinel server. Default value: $redis::params::sentinel_port ##### `service_group` Data type: `Any` - +The group of the config file. Default value: $redis::params::service_group ##### `service_name` -Data type: `Any` +Data type: `String[1]` +The name of the service (for puppet to manage). +Default value: 'redis-sentinel' -Default value: $redis::params::sentinel_service_name +##### `service_owner` -##### `service_ensure` - -Data type: `Any` +The owner of the config file. +##### `service_enable` +Data type: `Boolean` -Default value: $redis::params::service_ensure +Enable the service at boot time. -##### `service_enable` +Default value: $redis::params::service_enable -Data type: `Boolean` +##### `working_dir` +Data type: `Stdlib::Absolutepaht` +The directory into which sentinel will change to avoid mount +conflicts. -Default value: $redis::params::service_enable +Default value: '/tmp' -##### `service_user` +##### `notification_script` Data type: `Any` +Path to the notification script +Default value: `undef` -Default value: $redis::params::service_user - -##### `working_dir` +##### `client_reconfig_script` Data type: `Any` +Path to the client-reconfig script +Default value: `undef` -Default value: $redis::params::sentinel_working_dir - -##### `notification_script` +##### `init_template` -Data type: `Any` +Data type: `String[1]` -Default value: $redis::params::sentinel_notification_script +Default value: 'redis/redis-sentinel.init.erb' -##### `client_reconfig_script` +##### `service_ensure` Data type: `Any` -Default value: $redis::params::sentinel_client_reconfig_script +Default value: $redis::params::service_ensure + +##### `service_user` + +Data type: `Any` -### redis::service -= Class: redis::service -This class manages the Redis daemon. +Default value: $redis::params::service_user ## Defined types ### redis::instance -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: `String` Enable/disable active rehashing. Default value: $redis::activerehashing ##### `aof_load_truncated` Data type: `String` Enable/disable loading truncated AOF file Default value: $redis::aof_load_truncated ##### `aof_rewrite_incremental_fsync` Data type: `String` Enable/disable fsync for AOF file Default value: $redis::aof_rewrite_incremental_fsync ##### `appendfilename` Data type: `String` 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: everysec Default value: $redis::appendfsync ##### `appendonly` Data type: `String` Enable/disable appendonly mode. Default value: $redis::appendonly ##### `auto_aof_rewrite_min_size` Data type: `String` Adjust minimum size for auto-aof-rewrite. Default value: $redis::auto_aof_rewrite_min_size ##### `auto_aof_rewrite_percentage` Data type: `String` 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_dir` Data type: `Stdlib::Absolutepath` Directory containing the configuration files. Default value: $redis::config_dir ##### `config_dir_mode` Data type: `Stdlib::Filemode` Adjust mode for directory containing configuration files. Default value: $redis::config_dir_mode ##### `config_file_orig` Data type: `String` The location and name of a config file that provides the source Default value: $redis::config_file_orig ##### `config_file` Data type: `String` 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` Adjust filesystem group for config files. Default value: $redis::config_group ##### `config_owner` Data type: `String` Adjust filesystem owner for config files. Default value: $redis::config_owner ##### `conf_template` Data type: `String` Define which template to use. Default value: $redis::conf_template ##### `daemonize` Data type: `String` Have Redis run as a daemon. Default value: $redis::daemonize ##### `databases` Data type: `String` Set the number of databases. Default value: $redis::databases ##### `dbfilename` Data type: `String` The filename where to dump the DB Default value: $redis::dbfilename ##### `extra_config_file` Data type: `String` Description Default value: $redis::extra_config_file ##### `hash_max_ziplist_entries` Data type: `String` Set max ziplist entries for hashes. Default value: $redis::hash_max_ziplist_entries ##### `hash_max_ziplist_value` Data type: `String` Set max ziplist values for hashes. Default value: $redis::hash_max_ziplist_value ##### `hll_sparse_max_bytes` Data type: `String` HyperLogLog sparse representation bytes limit Default value: $redis::hll_sparse_max_bytes ##### `hz` Data type: `String` Set redis background tasks frequency Default value: $redis::hz ##### `latency_monitor_threshold` Data type: `String` Latency monitoring threshold in milliseconds Default value: $redis::latency_monitor_threshold ##### `list_max_ziplist_entries` Data type: `String` Set max ziplist entries for lists. Default value: $redis::list_max_ziplist_entries ##### `list_max_ziplist_value` Data type: `String` 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: `String` Specify the server verbosity level. Default value: $redis::log_level ##### `masterauth` Data type: `String` If the master is password protected (using the "requirepass" configuration Default value: $redis::masterauth ##### `maxclients` Data type: `String` Set the max number of connected clients at the same time. Default value: $redis::maxclients ##### `maxmemory` Data type: `String` Don't use more memory than the specified amount of bytes. Default value: $redis::maxmemory ##### `maxmemory_policy` Data type: `String` How Redis will select what to remove when maxmemory is reached. Default value: $redis::maxmemory_policy ##### `maxmemory_samples` Data type: `String` Select as well the sample size to check. Default value: $redis::maxmemory_samples ##### `min_slaves_max_lag` Data type: `String` The lag in seconds Default value: $redis::min_slaves_max_lag ##### `min_slaves_to_write` Data type: `String` Minimum number of slaves to be in "online" state Default value: $redis::min_slaves_to_write ##### `no_appendfsync_on_rewrite` Data type: `String` 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: `String` Which events to notify Pub/Sub clients about events happening Default value: $redis::notify_keyspace_events ##### `pid_file` Data type: `String` 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: `String` Whether protected mode is enabled or not. Only applicable when no bind is set. Default value: $redis::protected_mode ##### `rdbcompression` Data type: `String` Enable/disable compression of string objects using LZF when dumping. Default value: $redis::rdbcompression ##### `repl_backlog_size` Data type: `String` The replication backlog size Default value: $redis::repl_backlog_size ##### `repl_backlog_ttl` Data type: `String` The number of seconds to elapse before freeing backlog buffer Default value: $redis::repl_backlog_ttl ##### `repl_disable_tcp_nodelay` Data type: `String` 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: `String` Set the replication timeout for: Default value: $redis::repl_timeout ##### `requirepass` Data type: `String` Require clients to issue AUTH before processing any other commands. Default value: $redis::requirepass ##### `save_db_to_disk` Data type: `String` Set if save db to disk. Default value: $redis::save_db_to_disk ##### `save_db_to_disk_interval` Data type: `String` 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_enable` Data type: `String` Enable/disable daemon at boot. Default value: $redis::service_enable ##### `service_ensure` Data type: `String` Specify if the server should be running. Default value: $redis::service_ensure ##### `service_group` Data type: `String` Specify which group to run as. Default value: $redis::service_group ##### `service_hasrestart` Data type: `String` Does the init script support restart? Default value: $redis::service_hasrestart ##### `service_hasstatus` Data type: `String` Does the init script support status? Default value: $redis::service_hasstatus ##### `service_user` Data type: `String` Specify which user to run as. Default value: $redis::service_user ##### `set_max_intset_entries` Data type: `String` The following configuration setting sets the limit in the size of the set in order to use this special memory saving encoding. Default: 512 Default value: $redis::set_max_intset_entries ##### `slave_priority` Data type: `String` The priority number for slave promotion by Sentinel Default value: $redis::slave_priority ##### `slave_read_only` Data type: `String` You can configure a slave instance to accept writes or not. Default value: $redis::slave_read_only ##### `slave_serve_stale_data` Data type: `String` 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: true Default value: $redis::slave_serve_stale_data ##### `slaveof` Data type: `String` Use slaveof to make a Redis instance a copy of another Redis server. Default value: $redis::slaveof ##### `slowlog_log_slower_than` Data type: `String` Tells Redis what is the execution time, in microseconds, to exceed in order for the command to get logged. Default: 10000 Default value: $redis::slowlog_log_slower_than ##### `slowlog_max_len` Data type: `String` Tells Redis what is the length to exceed in order for the command to get logged. Default: 1024 Default value: $redis::slowlog_max_len ##### `stop_writes_on_bgsave_error` Data type: `String` If false then Redis will continue to work as usual even if there are problems with disk, permissions, and so forth. Default: true Default value: $redis::stop_writes_on_bgsave_error ##### `syslog_enabled` Data type: `String` Enable/disable logging to the system logger. Default value: $redis::syslog_enabled ##### `syslog_facility` Data type: `String` Specify the syslog facility. Must be USER or between LOCAL0-LOCAL7. Default: undef Default value: $redis::syslog_facility ##### `tcp_backlog` Data type: `String` Sets the TCP backlog Default value: $redis::tcp_backlog ##### `tcp_keepalive` Data type: `String` TCP keepalive. Default value: $redis::tcp_keepalive ##### `timeout` Data type: `String` Close the connection after a client is idle for N seconds (0 to disable). Default value: $redis::timeout ##### `ulimit` Data type: `String` Limit the use of system-wide resources. Default value: $redis::ulimit ##### `unixsocket` Data type: `String` Define unix socket path Default value: "/var/run/redis/redis-server-${name}.sock" ##### `unixsocketperm` Data type: `String` 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: /var/lib/redis/ 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: `String` Set max entries for sorted sets. Default value: $redis::zset_max_ziplist_entries ##### `zset_max_ziplist_value` Data type: `String` 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` Config file for saving cluster nodes configuration. This file is never touched by humans. Only set if cluster_enabled is true Default: nodes.conf Default value: $redis::cluster_config_file ##### `cluster_node_timeout` Data type: `String` Node timeout Only set if cluster_enabled is true Default: 5000 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: 0 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: 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: 1 Default value: $redis::cluster_migration_barrier ##### `output_buffer_limit_slave` Data type: `Any` Default value: $redis::output_buffer_limit_slave ##### `output_buffer_limit_pubsub` Data type: `Any` Default value: $redis::output_buffer_limit_pubsub ##### `minimum_version` Data type: `Any` Default value: $redis::minimum_version ##### `managed_by_cluster_manager` Data type: `Any` Default value: $redis::managed_by_cluster_manager ##### `package_ensure` Data type: `Any` Default value: $redis::package_ensure ##### `manage_service_file` Data type: `Any` Default value: `true` ## Functions ### redis::get Type: Ruby 4.x API 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) ``` #### `redis::get(String[1] $key, Redis::RedisUrl $url, Optional[String] $default)` 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) ``` 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::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/manifests/config.pp b/manifests/config.pp index 3818eee..5e2fa00 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -1,71 +1,69 @@ -# = Class: redis::config -# -# This class provides configuration for Redis. -# +# @summary This class provides configuration for Redis. +# @api private class redis::config { File { owner => $redis::config_owner, group => $redis::config_group, mode => $redis::config_file_mode, } file { $redis::config_dir: ensure => directory, mode => $redis::config_dir_mode, } file {$redis::log_dir: ensure => directory, group => $redis::service_group, mode => $redis::log_dir_mode, owner => $redis::service_user, } file {$redis::workdir: ensure => directory, group => $redis::service_group, mode => $redis::workdir_mode, owner => $redis::service_user, } if $redis::default_install { redis::instance {'default': pid_file => $redis::pid_file, log_file => $redis::log_file, manage_service_file => $redis::manage_service_file, unixsocket => $redis::unixsocket, workdir => $redis::workdir, } } if $redis::ulimit { contain redis::ulimit } $service_provider_lookup = pick(getvar('service_provider'), false) unless $facts['osfamily'] == 'Debian' or $service_provider_lookup == 'systemd' { file { '/var/run/redis': ensure => 'directory', owner => $redis::config_owner, group => $redis::config_group, mode => '0755', } } # Adjust /etc/default/redis-server on Debian systems case $::osfamily { 'Debian': { file { '/etc/default/redis-server': ensure => present, group => $redis::config_group, mode => $redis::config_file_mode, owner => $redis::config_owner, } } default: { } } } diff --git a/manifests/install.pp b/manifests/install.pp index 3e21fad..895efc1 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -1,12 +1,10 @@ -# = Class: redis::install -# -# This class installs the application. -# +# @summary This class installs the application. +# @api private class redis::install { if $redis::manage_package { package { $redis::package_name: ensure => $redis::package_ensure, } } } diff --git a/manifests/instance.pp b/manifests/instance.pp index 16d2b64..eb569db 100644 --- a/manifests/instance.pp +++ b/manifests/instance.pp @@ -1,363 +1,361 @@ -# redis::instance -# # This is an defined type to allow the configuration of # multiple redis instances on one machine without conflicts # # @summary Allows the configuration of multiple redis configurations on one machine # # @example # redis::instance {'6380': # port => 6380, # } # # @param [String] activerehashing Enable/disable active rehashing. # @param [String] aof_load_truncated Enable/disable loading truncated AOF file # @param [String] aof_rewrite_incremental_fsync Enable/disable fsync for AOF file # @param [String] appendfilename The name of the append only file # @param appendfsync Adjust fsync mode. Valid options: always, everysec, no. Default: everysec # @param [String] appendonly Enable/disable appendonly mode. # @param [String] auto_aof_rewrite_min_size Adjust minimum size for auto-aof-rewrite. # @param [String] auto_aof_rewrite_percentage Adjust percentatge for auto-aof-rewrite. # @param bind Configure which IP address(es) to listen on. To bind on all interfaces, use an empty array. # @param config_dir Directory containing the configuration files. # @param config_dir_mode Adjust mode for directory containing configuration files. # @param [String] config_file_orig The location and name of a config file that provides the source # @param [String] config_file Adjust main configuration file. # @param config_file_mode Adjust permissions for configuration files. # @param [String] config_group Adjust filesystem group for config files. # @param [String] config_owner Adjust filesystem owner for config files. # @param [String] conf_template Define which template to use. # @param [String] daemonize Have Redis run as a daemon. # @param [String] databases Set the number of databases. # @param [String] dbfilename The filename where to dump the DB # @param [String] extra_config_file Description # @param [String] hash_max_ziplist_entries Set max ziplist entries for hashes. # @param [String] hash_max_ziplist_value Set max ziplist values for hashes. # @param [String] hll_sparse_max_bytes HyperLogLog sparse representation bytes limit # @param [String] hz Set redis background tasks frequency # @param [String] latency_monitor_threshold Latency monitoring threshold in milliseconds # @param [String] list_max_ziplist_entries Set max ziplist entries for lists. # @param [String] list_max_ziplist_value Set max ziplist values for lists. # @param log_dir Specify directory where to write log entries. # @param log_dir_mode Adjust mode for directory containing log files. # @param log_file Specify file where to write log entries. # @param [String] log_level Specify the server verbosity level. # @param [String] masterauth If the master is password protected (using the "requirepass" configuration # @param [String] maxclients Set the max number of connected clients at the same time. # @param [String] maxmemory Don't use more memory than the specified amount of bytes. # @param [String] maxmemory_policy How Redis will select what to remove when maxmemory is reached. # @param [String] maxmemory_samples Select as well the sample size to check. # @param [String] min_slaves_max_lag The lag in seconds # @param [String] min_slaves_to_write Minimum number of slaves to be in "online" state # @param [String] no_appendfsync_on_rewrite If you have latency problems turn this to 'true'. Otherwise leave it as # @param [String] notify_keyspace_events Which events to notify Pub/Sub clients about events happening # @param [String] pid_file Where to store the pid. # @param port Configure which port to listen on. # @param [String] protected_mode Whether protected mode is enabled or not. Only applicable when no bind is set. # @param [String] rdbcompression Enable/disable compression of string objects using LZF when dumping. # @param [String] repl_backlog_size The replication backlog size # @param [String] repl_backlog_ttl The number of seconds to elapse before freeing backlog buffer # @param [String] repl_disable_tcp_nodelay Enable/disable TCP_NODELAY on the slave socket after SYNC # @param [Integer] repl_ping_slave_period Slaves send PINGs to server in a predefined interval. It's possible # @param [String] repl_timeout Set the replication timeout for: # @param [String] requirepass Require clients to issue AUTH before processing any # other commands. # @param [String] save_db_to_disk Set if save db to disk. # @param [String] save_db_to_disk_interval save the dataset every N seconds if there are at least M changes in the dataset # @param [String] service_enable Enable/disable daemon at boot. # @param [String] service_ensure Specify if the server should be running. # @param [String] service_group Specify which group to run as. # @param [String] service_hasrestart Does the init script support restart? # @param [String] service_hasstatus Does the init script support status? # @param [String] service_user Specify which user to run as. # @param [String] set_max_intset_entries The following configuration setting sets the limit in the size of the # set in order to use this special memory saving encoding. # Default: 512 # @param [String] slave_priority The priority number for slave promotion by Sentinel # @param [String] slave_read_only You can configure a slave instance to accept writes or not. # @param [String] slave_serve_stale_data 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: true # # @param [String] slaveof Use slaveof to make a Redis instance a copy of another Redis server. # @param [String] slowlog_log_slower_than Tells Redis what is the execution time, in microseconds, to exceed # in order for the command to get logged. # Default: 10000 # # @param [String] slowlog_max_len Tells Redis what is the length to exceed in order for the command # to get logged. # Default: 1024 # # @param [String] stop_writes_on_bgsave_error If false then Redis will continue to work as usual even if there # are problems with disk, permissions, and so forth. # Default: true # # @param [String] syslog_enabled Enable/disable logging to the system logger. # @param [String] syslog_facility Specify the syslog facility. # Must be USER or between LOCAL0-LOCAL7. # Default: undef # # @param [String] tcp_backlog Sets the TCP backlog # @param [String] tcp_keepalive TCP keepalive. # @param [String] timeout Close the connection after a client is idle for N seconds (0 to disable). # @param [String] ulimit Limit the use of system-wide resources. # @param [String] unixsocket Define unix socket path # @param [String] unixsocketperm Define unix socket file permissions # @param workdir The DB will be written inside this directory, with the filename specified # above using the 'dbfilename' configuration directive. # Default: /var/lib/redis/ # @param workdir_mode Adjust mode for data directory. # @param [String] zset_max_ziplist_entries Set max entries for sorted sets. # @param [String] zset_max_ziplist_value Set max values for sorted sets. # @param cluster_enabled Enables redis 3.0 cluster functionality # @param [String] cluster_config_file Config file for saving cluster nodes configuration. This file is never touched by humans. # Only set if cluster_enabled is true # Default: nodes.conf # @param [String] cluster_node_timeout Node timeout # Only set if cluster_enabled is true # Default: 5000 # @param [Integer] cluster_slave_validity_factor Control variable to disable promoting slave in case of disconnection from master # Only set if cluster_enabled is true # Default: 0 # @param [Boolean] cluster_require_full_coverage 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: true # @param [Integer] cluster_migration_barrier 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: 1 define redis::instance ( $activerehashing = $redis::activerehashing, $aof_load_truncated = $redis::aof_load_truncated, $aof_rewrite_incremental_fsync = $redis::aof_rewrite_incremental_fsync, $appendfilename = $redis::appendfilename, Enum['no', 'always', 'everysec'] $appendfsync = $redis::appendfsync, $appendonly = $redis::appendonly, $auto_aof_rewrite_min_size = $redis::auto_aof_rewrite_min_size, $auto_aof_rewrite_percentage = $redis::auto_aof_rewrite_percentage, Variant[Stdlib::IP::Address, Array[Stdlib::IP::Address]] $bind = $redis::bind, $output_buffer_limit_slave = $redis::output_buffer_limit_slave, $output_buffer_limit_pubsub = $redis::output_buffer_limit_pubsub, $conf_template = $redis::conf_template, Stdlib::Absolutepath $config_dir = $redis::config_dir, Stdlib::Filemode $config_dir_mode = $redis::config_dir_mode, $config_file = $redis::config_file, Stdlib::Filemode $config_file_mode = $redis::config_file_mode, $config_file_orig = $redis::config_file_orig, $config_group = $redis::config_group, $config_owner = $redis::config_owner, $daemonize = $redis::daemonize, $databases = $redis::databases, $dbfilename = $redis::dbfilename, $extra_config_file = $redis::extra_config_file, $hash_max_ziplist_entries = $redis::hash_max_ziplist_entries, $hash_max_ziplist_value = $redis::hash_max_ziplist_value, $hll_sparse_max_bytes = $redis::hll_sparse_max_bytes, $hz = $redis::hz, $latency_monitor_threshold = $redis::latency_monitor_threshold, $list_max_ziplist_entries = $redis::list_max_ziplist_entries, $list_max_ziplist_value = $redis::list_max_ziplist_value, Stdlib::Absolutepath $log_dir = $redis::log_dir, Stdlib::Filemode $log_dir_mode = $redis::log_dir_mode, $log_level = $redis::log_level, $minimum_version = $redis::minimum_version, $masterauth = $redis::masterauth, $maxclients = $redis::maxclients, $maxmemory = $redis::maxmemory, $maxmemory_policy = $redis::maxmemory_policy, $maxmemory_samples = $redis::maxmemory_samples, $min_slaves_max_lag = $redis::min_slaves_max_lag, $min_slaves_to_write = $redis::min_slaves_to_write, $no_appendfsync_on_rewrite = $redis::no_appendfsync_on_rewrite, $notify_keyspace_events = $redis::notify_keyspace_events, $managed_by_cluster_manager = $redis::managed_by_cluster_manager, $package_ensure = $redis::package_ensure, Stdlib::Port $port = $redis::port, $protected_mode = $redis::protected_mode, $rdbcompression = $redis::rdbcompression, $repl_backlog_size = $redis::repl_backlog_size, $repl_backlog_ttl = $redis::repl_backlog_ttl, $repl_disable_tcp_nodelay = $redis::repl_disable_tcp_nodelay, Integer[1] $repl_ping_slave_period = $redis::repl_ping_slave_period, $repl_timeout = $redis::repl_timeout, $requirepass = $redis::requirepass, $save_db_to_disk = $redis::save_db_to_disk, $save_db_to_disk_interval = $redis::save_db_to_disk_interval, $service_user = $redis::service_user, $set_max_intset_entries = $redis::set_max_intset_entries, $slave_priority = $redis::slave_priority, $slave_read_only = $redis::slave_read_only, $slave_serve_stale_data = $redis::slave_serve_stale_data, $slaveof = $redis::slaveof, $slowlog_log_slower_than = $redis::slowlog_log_slower_than, $slowlog_max_len = $redis::slowlog_max_len, $stop_writes_on_bgsave_error = $redis::stop_writes_on_bgsave_error, $syslog_enabled = $redis::syslog_enabled, $syslog_facility = $redis::syslog_facility, $tcp_backlog = $redis::tcp_backlog, $tcp_keepalive = $redis::tcp_keepalive, $timeout = $redis::timeout, $unixsocketperm = $redis::unixsocketperm, $ulimit = $redis::ulimit, Stdlib::Filemode $workdir_mode = $redis::workdir_mode, $zset_max_ziplist_entries = $redis::zset_max_ziplist_entries, $zset_max_ziplist_value = $redis::zset_max_ziplist_value, Boolean $cluster_enabled = $redis::cluster_enabled, $cluster_config_file = $redis::cluster_config_file, $cluster_node_timeout = $redis::cluster_node_timeout, Integer[0] $cluster_slave_validity_factor = $redis::cluster_slave_validity_factor, Boolean $cluster_require_full_coverage = $redis::cluster_require_full_coverage, Integer[0] $cluster_migration_barrier = $redis::cluster_migration_barrier, $service_ensure = $redis::service_ensure, $service_enable = $redis::service_enable, $service_group = $redis::service_group, $service_hasrestart = $redis::service_hasrestart, $service_hasstatus = $redis::service_hasstatus, # Defaults for redis::instance $manage_service_file = true, Optional[Stdlib::Absolutepath] $log_file = undef, $pid_file = "/var/run/redis/redis-server-${name}.pid", $unixsocket = "/var/run/redis/redis-server-${name}.sock", Stdlib::Absolutepath $workdir = "${redis::workdir}/redis-server-${name}", ) { if $title == 'default' { $redis_server_name = $redis::service_name $redis_file_name_orig = $config_file_orig $redis_file_name = $config_file } else { $redis_server_name = "redis-server-${name}" $redis_file_name_orig = sprintf('%s/%s.%s', dirname($config_file_orig), $redis_server_name, 'conf.puppet') $redis_file_name = sprintf('%s/%s.%s', dirname($config_file), $redis_server_name, 'conf') } if $log_dir != $redis::log_dir { file { $log_dir: ensure => directory, group => $service_group, mode => $log_dir_mode, owner => $service_user, } } $_real_log_file = $log_file ? { undef => "${log_dir}/redis-server-${name}.log", default => $log_file, } if $workdir != $redis::workdir { file { $workdir: ensure => directory, group => $service_group, mode => $workdir_mode, owner => $service_user, } } if $manage_service_file { $service_provider_lookup = pick(getvar('service_provider'), false) if $service_provider_lookup == 'systemd' { file { "/etc/systemd/system/${redis_server_name}.service": ensure => file, owner => 'root', group => 'root', mode => '0644', content => template('redis/service_templates/redis.service.erb'), } ~> Exec['systemd-reload-redis'] if $title != 'default' { service { $redis_server_name: ensure => $service_ensure, enable => $service_enable, hasrestart => $service_hasrestart, hasstatus => $service_hasstatus, subscribe => [ File["/etc/systemd/system/${redis_server_name}.service"], Exec["cp -p ${redis_file_name_orig} ${redis_file_name}"], ], } } } else { file { "/etc/init.d/${redis_server_name}": ensure => file, mode => '0755', content => template("redis/service_templates/redis.${::osfamily}.erb"), } if $title != 'default' { service { $redis_server_name: ensure => $service_ensure, enable => $service_enable, hasrestart => $service_hasrestart, hasstatus => $service_hasstatus, subscribe => [ File["/etc/init.d/${redis_server_name}"], Exec["cp -p ${redis_file_name_orig} ${redis_file_name}"], ], } } } } File { owner => $config_owner, group => $config_group, mode => $config_file_mode, } file {$redis_file_name_orig: ensure => file, } exec {"cp -p ${redis_file_name_orig} ${redis_file_name}": path => '/usr/bin:/bin', subscribe => File[$redis_file_name_orig], refreshonly => true, } $bind_arr = [$bind].flatten if $package_ensure =~ /^([0-9]+:)?[0-9]+\.[0-9]/ { if ':' in $package_ensure { $_redis_version_real = split($package_ensure, ':') $redis_version_real = $_redis_version_real[1] } else { $redis_version_real = $package_ensure } } else { $redis_version_real = pick(getvar('redis_server_version'), $minimum_version) } if ($redis_version_real and $conf_template == 'redis/redis.conf.erb') { case $redis_version_real { /^2.4./: { if $bind_arr.length > 1 { fail('Redis 2.4 doesn\'t support binding to multiple IPs') } File[$redis_file_name_orig] { content => template('redis/redis.conf.2.4.10.erb') } } /^2.8./: { File[$redis_file_name_orig] { content => template('redis/redis.conf.2.8.erb') } } /^3.2./: { File[$redis_file_name_orig] { content => template('redis/redis.conf.3.2.erb') } } default: { File[$redis_file_name_orig] { content => template($conf_template) } } } } else { File[$redis_file_name_orig] { content => template($conf_template) } } } diff --git a/manifests/params.pp b/manifests/params.pp index d86ea41..def6d03 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -1,332 +1,306 @@ -# = Class: redis::params -# -# This class provides a number of parameters. -# +# @summary This class provides a number of parameters. +# @api private class redis::params { # Generic $manage_repo = false $manage_package = true $managed_by_cluster_manager = false # redis.conf.erb $activerehashing = true $aof_load_truncated = true $aof_rewrite_incremental_fsync = true $appendfilename = 'appendonly.aof' $appendfsync = 'everysec' $appendonly = false $auto_aof_rewrite_min_size = '64mb' $auto_aof_rewrite_percentage = 100 $bind = ['127.0.0.1'] $output_buffer_limit_slave = '256mb 64mb 60' $output_buffer_limit_pubsub = '32mb 8mb 60' $conf_template = 'redis/redis.conf.erb' $default_install = true $databases = 16 $dbfilename = 'dump.rdb' $extra_config_file = undef $hash_max_ziplist_entries = 512 $hash_max_ziplist_value = 64 $hll_sparse_max_bytes = 3000 $hz = 10 $latency_monitor_threshold = 0 $list_max_ziplist_entries = 512 $list_max_ziplist_value = 64 $log_dir = '/var/log/redis' $log_file = '/var/log/redis/redis.log' $log_level = 'notice' $manage_service_file = false $maxclients = 10000 $maxmemory = undef $maxmemory_policy = undef $maxmemory_samples = undef $no_appendfsync_on_rewrite = false $notify_keyspace_events = undef $notify_service = true $port = 6379 $protected_mode = 'yes' $rdbcompression = true $requirepass = undef $save_db_to_disk = true $save_db_to_disk_interval = {'900' =>'1', '300' => '10', '60' => '10000'} - $sentinel_auth_pass = undef - $sentinel_bind = undef - $sentinel_config_file_mode = '0644' - $sentinel_config_group = 'root' - $sentinel_config_owner = 'redis' - $sentinel_conf_template = 'redis/redis-sentinel.conf.erb' - $sentinel_down_after = 30000 - $sentinel_failover_timeout = 180000 - $sentinel_master_name = 'mymaster' - $sentinel_parallel_sync = 1 - $sentinel_port = 26379 - $sentinel_quorum = 2 - $sentinel_redis_host = '127.0.0.1' - $sentinel_service_name = 'redis-sentinel' - $sentinel_working_dir = '/tmp' - $sentinel_init_template = 'redis/redis-sentinel.init.erb' - $sentinel_pid_file = '/var/run/redis/redis-sentinel.pid' - $sentinel_notification_script = undef - $sentinel_client_reconfig_script = undef $service_provider = undef $set_max_intset_entries = 512 $slave_priority = 100 $slowlog_log_slower_than = 10000 $slowlog_max_len = 1024 $stop_writes_on_bgsave_error = true $syslog_enabled = undef $syslog_facility = undef $tcp_backlog = 511 $tcp_keepalive = 0 $timeout = 0 $ulimit = 65536 $unixsocket = '/var/run/redis/redis.sock' $unixsocketperm = 755 $zset_max_ziplist_entries = 128 $zset_max_ziplist_value = 64 # redis.conf.erb - replication $masterauth = undef $min_slaves_to_write = 0 $min_slaves_max_lag = 10 $repl_backlog_size = '1mb' $repl_backlog_ttl = 3600 $repl_disable_tcp_nodelay = false $repl_ping_slave_period = 10 $repl_timeout = 60 $slave_read_only = true $slave_serve_stale_data = true $slaveof = undef # redis.conf.erb - redis 3.0 clustering $cluster_enabled = false $cluster_config_file = 'nodes.conf' $cluster_node_timeout = 5000 $cluster_slave_validity_factor = 0 $cluster_require_full_coverage = true $cluster_migration_barrier = 1 case $::osfamily { 'Debian': { $config_dir = '/etc/redis' $config_dir_mode = '0755' $config_file = '/etc/redis/redis.conf' $config_file_mode = '0644' $config_file_orig = '/etc/redis/redis.conf.puppet' $config_owner = 'redis' $daemonize = true $log_dir_mode = '0755' $package_ensure = 'present' $package_name = 'redis-server' $pid_file = '/var/run/redis/redis-server.pid' $sentinel_config_file = '/etc/redis/sentinel.conf' $sentinel_config_file_orig = '/etc/redis/redis-sentinel.conf.puppet' $sentinel_daemonize = true $sentinel_init_script = '/etc/init.d/redis-sentinel' $sentinel_package_name = 'redis-sentinel' - $sentinel_package_ensure = 'present' $service_manage = true $service_enable = true $service_ensure = 'running' $service_group = 'redis' $service_hasrestart = true $service_hasstatus = true $service_name = 'redis-server' $service_user = 'redis' $ppa_repo = 'ppa:chris-lea/redis-server' $workdir = '/var/lib/redis' $workdir_mode = '0750' case $::operatingsystem { 'Ubuntu': { $config_group = 'redis' case $::operatingsystemmajrelease { '14.04': { # upstream package is 2.8.4 $minimum_version = '2.8.4' } '16.04': { # upstream package is 3.0.3 $minimum_version = '3.0.3' } default: { warning("Ubuntu release ${::operatingsystemmajrelease} isn't 'officially' supported by module, but will give it a shot") $minimum_version = '2.8.5' } } } default: { $config_group = 'root' # Debian standard package is 2.4.14 # But we have dotdeb repo which is 3.2.5 $minimum_version = '3.2.5' } } } 'RedHat': { $config_dir = '/etc/redis' $config_dir_mode = '0755' $config_file = '/etc/redis.conf' $config_file_mode = '0644' $config_file_orig = '/etc/redis.conf.puppet' $config_group = 'root' $config_owner = 'redis' $daemonize = true $log_dir_mode = '0755' $package_ensure = 'present' $package_name = 'redis' $pid_file = '/var/run/redis/redis.pid' $sentinel_config_file = '/etc/redis-sentinel.conf' $sentinel_config_file_orig = '/etc/redis-sentinel.conf.puppet' $sentinel_daemonize = false $sentinel_init_script = undef $sentinel_package_name = 'redis' - $sentinel_package_ensure = 'present' $service_manage = true $service_enable = true $service_ensure = 'running' $service_hasrestart = true $service_hasstatus = true $service_name = 'redis' $service_user = 'redis' $ppa_repo = undef $workdir = '/var/lib/redis' $workdir_mode = '0755' case $::operatingsystemmajrelease { '6': { # CentOS 6 EPEL package is just updated to 3.2.10 # https://bugzilla.redhat.com/show_bug.cgi?id=923970 $minimum_version = '3.2.10' $service_group = 'root' } '7': { # CentOS 7 EPEL package is 3.2.3 $minimum_version = '3.2.3' $service_group = 'redis' } '8': { $minimum_version = '3.2.3' $service_group = 'redis' } default: { fail("Not sure what Redis version is avaliable upstream on your release: ${::operatingsystemmajrelease}") } } } 'FreeBSD': { $config_dir = '/usr/local/etc/redis' $config_dir_mode = '0755' $config_file = '/usr/local/etc/redis.conf' $config_file_mode = '0644' $config_file_orig = '/usr/local/etc/redis.conf.puppet' $config_group = 'wheel' $config_owner = 'redis' $daemonize = true $log_dir_mode = '0755' $package_ensure = 'present' $package_name = 'redis' $pid_file = '/var/run/redis/redis.pid' $sentinel_config_file = '/usr/local/etc/redis-sentinel.conf' $sentinel_config_file_orig = '/usr/local/etc/redis-sentinel.conf.puppet' $sentinel_daemonize = true $sentinel_init_script = undef $sentinel_package_name = 'redis' - $sentinel_package_ensure = 'present' $service_manage = true $service_enable = true $service_ensure = 'running' $service_group = 'redis' $service_hasrestart = true $service_hasstatus = true $service_name = 'redis' $service_user = 'redis' $ppa_repo = undef $workdir = '/var/db/redis' $workdir_mode = '0750' # pkg version $minimum_version = '3.2.4' } 'Suse': { $config_dir = '/etc/redis' $config_dir_mode = '0750' $config_file = '/etc/redis/redis-server.conf' $config_file_mode = '0644' $config_group = 'redis' $config_owner = 'redis' $daemonize = true $log_dir_mode = '0750' $package_ensure = 'present' $package_name = 'redis' $pid_file = '/var/run/redis/redis-server.pid' $sentinel_config_file = '/etc/redis/redis-sentinel.conf' $sentinel_config_file_orig = '/etc/redis/redis-sentinel.conf.puppet' $sentinel_daemonize = true $sentinel_init_script = undef $sentinel_package_name = 'redis' - $sentinel_package_ensure = 'present' $service_manage = true $service_enable = true $service_ensure = 'running' $service_group = 'redis' $service_hasrestart = true $service_hasstatus = true $service_name = 'redis' $service_user = 'redis' $ppa_repo = undef $workdir = '/var/lib/redis' $workdir_mode = '0750' # suse package version $minimum_version = '3.0.5' } 'Archlinux': { $config_dir = '/etc/redis' $config_dir_mode = '0755' $config_file = '/etc/redis/redis.conf' $config_file_mode = '0644' $config_file_orig = '/etc/redis/redis.conf.puppet' $config_group = 'root' $config_owner = 'root' $daemonize = true $log_dir_mode = '0755' $package_ensure = 'present' $package_name = 'redis' $pid_file = '/var/run/redis.pid' $sentinel_config_file = '/etc/redis/redis-sentinel.conf' $sentinel_config_file_orig = '/etc/redis/redis-sentinel.conf.puppet' $sentinel_daemonize = true $sentinel_init_script = undef $sentinel_package_name = 'redis' - $sentinel_package_ensure = 'present' $service_manage = true $service_enable = true $service_ensure = 'running' $service_group = 'redis' $service_hasrestart = true $service_hasstatus = true $service_name = 'redis' $service_user = 'redis' $ppa_repo = undef $workdir = '/var/lib/redis' $workdir_mode = '0750' # pkg version $minimum_version = '3.2.4' } default: { fail "Operating system ${::operatingsystem} is not supported yet." } } } diff --git a/manifests/preinstall.pp b/manifests/preinstall.pp index e82f412..ed26b72 100644 --- a/manifests/preinstall.pp +++ b/manifests/preinstall.pp @@ -1,47 +1,45 @@ -# = Class: redis::preinstall -# -# This class provides anything required by the install class. -# Such as package repositories. -# +# @summary Provides anything required by the install class, such as package +# repositories. +# @api private class redis::preinstall { if $redis::manage_repo { case $::operatingsystem { 'RedHat', 'CentOS', 'Scientific', 'OEL', 'Amazon': { require 'epel' } 'Debian': { contain 'apt' apt::source { 'dotdeb': location => 'http://packages.dotdeb.org/', release => $::lsbdistcodename, repos => 'all', key => { id => '6572BBEF1B5FF28B28B706837E3F070089DF5277', source => 'http://www.dotdeb.org/dotdeb.gpg', }, include => { 'src' => true }, before => [ Class['apt::update'], Package[$redis::package_name], ], } } 'Ubuntu': { contain 'apt' apt::ppa { $redis::ppa_repo: before => [ Class['apt::update'], Package[$redis::package_name], ], } } default: { } } } } diff --git a/manifests/sentinel.pp b/manifests/sentinel.pp index 1ba1bee..0de1aad 100644 --- a/manifests/sentinel.pp +++ b/manifests/sentinel.pp @@ -1,267 +1,202 @@ -# = Class: redis::sentinel +# @summary Install redis-sentinel # -# This class installs redis-sentinel -# -# == Parameters: -# -# -# [*auth_pass*] +# @param auth_pass # The password to use to authenticate with the master and slaves. # -# Default: undef -# -# [*config_file*] +# @param config_file # The location and name of the sentinel config file. # -# Default for deb: /etc/redis/redis-sentinel.conf -# Default for rpm: /etc/redis-sentinel.conf -# -# [*config_file_orig*] +# @param config_file_orig # 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 for deb: /etc/redis/redis-sentinel.conf.puppet -# Default for rpm: /etc/redis-sentinel.conf.puppet -# -# [*config_file_mode*] +# @param config_file_mode # Permissions of config file. # -# Default: 0644 -# -# [*conf_template*] +# @param conf_template # Define which template to use. # -# Default: redis/redis-sentinel.conf.erb -# -# [*daemonize*] +# @param daemonize # Have Redis sentinel run as a daemon. # -# Default: true -# -# [*down_after*] +# @param down_after # 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: 30000 -# -# [*failover_timeout*] +# @param failover_timeout # Specify the failover timeout in milliseconds. # -# Default: 180000 -# -# [*init_script*] +# @param init_script # Specifiy the init script that will be created for sentinel. # -# Default: undef on rpm, /etc/init.d/redis-sentinel on apt. -# -# [*log_file*] +# @param log_file # Specify where to write log entries. # -# Default: /var/log/redis/redis.log -# -# [*log_level*] +# @param log_level # Specify how much we should log. # -# Default: notice -# -# [*master_name*] +# @param master_name # Specify the name of the master redis server. # The valid charset is A-z 0-9 and the three characters ".-_". # -# Default: mymaster -# -# [*redis_host*] +# @param redis_host # Specify the bound host of the master redis server. # -# Default: 127.0.0.1 -# -# [*redis_port*] +# @param redis_port # Specify the port of the master redis server. # -# Default: 6379 -# -# [*package_name*] +# @param package_name # The name of the package that installs sentinel. # -# Default: 'redis-server' on apt, 'redis' on rpm -# -# [*package_ensure*] +# @param package_ensure # Do we ensure this package. # -# Default: 'present' -# -# [*parallel_sync*] +# @param parallel_sync # How many slaves can be reconfigured at the same time to use a # new master after a failover. # -# Default: 1 -# -# [*pid_file*] +# @param pid_file # If sentinel is daemonized it will write its pid at this location. # -# Default: /var/run/redis/redis-sentinel.pid -# -# [*quorum*] +# @param quorum # Number of sentinels that must agree that a master is down to # signal sdown state. # -# Default: 2 -# -# [*sentinel_bind*] +# @param sentinel_bind # Allow optional sentinel server ip binding. Can help overcome # issues arising from protect-mode added Redis 3.2 # -# Default: undef -# -# [*sentinel_port*] +# @param sentinel_port # The port of sentinel server. # -# Default: 26379 -# -# [*service_group*] +# @param service_group # The group of the config file. # -# Default: redis -# -# [*service_name*] +# @param service_name # The name of the service (for puppet to manage). # -# Default: redis-sentinel -# -# [*service_owner*] +# @param service_owner # The owner of the config file. # -# Default: redis -# -# [*service_enable*] +# @param service_enable # Enable the service at boot time. # -# Default: true -# -# [*working_dir*] +# @param working_dir # The directory into which sentinel will change to avoid mount # conflicts. # -# Default: /tmp -# -# [*notification_script*] +# @param notification_script # Path to the notification script # -# Default: undef -# -# [*client_reconfig_script*] +# @param client_reconfig_script # Path to the client-reconfig script # -# Default: undef -# == Actions: -# - Install and configure Redis Sentinel -# -# == Sample Usage: -# -# class { 'redis::sentinel': } +# @example Basic inclusion +# include redis::sentinel # +# @example Configuring options # class {'redis::sentinel': # down_after => 80000, -# log_file => '/var/log/redis/sentinel.log', +# log_file => '/var/log/redis/sentinel.log', # } # class redis::sentinel ( - $auth_pass = $redis::params::sentinel_auth_pass, + $auth_pass = undef, $config_file = $redis::params::sentinel_config_file, $config_file_orig = $redis::params::sentinel_config_file_orig, - Stdlib::Filemode $config_file_mode = $redis::params::sentinel_config_file_mode, - $conf_template = $redis::params::sentinel_conf_template, + Stdlib::Filemode $config_file_mode = '0644', + String[1] $conf_template = 'redis/redis-sentinel.conf.erb', $daemonize = $redis::params::sentinel_daemonize, - $down_after = $redis::params::sentinel_down_after, - $failover_timeout = $redis::params::sentinel_failover_timeout, + $down_after = 30000, + $failover_timeout = 180000, $init_script = $redis::params::sentinel_init_script, - $init_template = $redis::params::sentinel_init_template, + String[1] $init_template = 'redis/redis-sentinel.init.erb', $log_level = $redis::params::log_level, $log_file = $redis::params::log_file, - $master_name = $redis::params::sentinel_master_name, - Stdlib::Host $redis_host = $redis::params::sentinel_redis_host, - Stdlib::Port $redis_port = $redis::params::port, + String[1] $master_name = 'mymaster', + Stdlib::Host $redis_host = '127.0.0.1', + Stdlib::Port $redis_port = 26379, $package_name = $redis::params::sentinel_package_name, - $package_ensure = $redis::params::sentinel_package_ensure, - $parallel_sync = $redis::params::sentinel_parallel_sync, - $pid_file = $redis::params::sentinel_pid_file, - $quorum = $redis::params::sentinel_quorum, - $sentinel_bind = $redis::params::sentinel_bind, + String[1] $package_ensure = 'present', + Integer[0] $parallel_sync = 1, + Stdlib::Absolutepath $pid_file = '/var/run/redis/redis-sentinel.pid', + Integer[0] $quorum = 2, + $sentinel_bind = undef, Stdlib::Port $sentinel_port = $redis::params::sentinel_port, $service_group = $redis::params::service_group, - $service_name = $redis::params::sentinel_service_name, + String[1] $service_name = 'redis-sentinel', $service_ensure = $redis::params::service_ensure, Boolean $service_enable = $redis::params::service_enable, $service_user = $redis::params::service_user, - $working_dir = $redis::params::sentinel_working_dir, - $notification_script = $redis::params::sentinel_notification_script, - $client_reconfig_script = $redis::params::sentinel_client_reconfig_script, + Stdlib::Absolutepaht $working_dir = '/tmp', + $notification_script = undef, + $client_reconfig_script = undef, ) inherits redis::params { require 'redis' if $::osfamily == 'Debian' { # Debian flavour machines have a dedicated redis-sentinel package # This is default in Xenial or Stretch onwards or PPA/other upstream # See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=775414 for context if ( (versioncmp($::operatingsystemmajrelease, '16.04') >= 0 and $::operatingsystem == 'Ubuntu') or (versioncmp($::operatingsystemmajrelease, '9') >= 0 and $::operatingsystem == 'Debian') or $redis::manage_repo ) { package { $package_name: ensure => $package_ensure, before => File[$config_file_orig], } if $init_script { Package[$package_name] -> File[$init_script] } } } file { $config_file_orig: ensure => present, owner => $service_user, group => $service_group, mode => $config_file_mode, content => template($conf_template), } exec { "cp -p ${config_file_orig} ${config_file}": path => '/usr/bin:/bin', subscribe => File[$config_file_orig], notify => Service[$service_name], refreshonly => true, } if $init_script { file { $init_script: ensure => present, owner => 'root', group => 'root', mode => '0755', content => template($init_template), } exec { '/usr/sbin/update-rc.d redis-sentinel defaults': subscribe => File[$init_script], refreshonly => true, notify => Service[$service_name], } } service { $service_name: ensure => $service_ensure, enable => $service_enable, hasrestart => $redis::params::service_hasrestart, hasstatus => $redis::params::service_hasstatus, } } diff --git a/manifests/service.pp b/manifests/service.pp index c968e33..0145f27 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -1,16 +1,14 @@ -# = Class: redis::service -# -# This class manages the Redis daemon. -# +# @summary This class manages the Redis daemon. +# @api private class redis::service { if $redis::service_manage { service { $redis::service_name: ensure => $redis::service_ensure, enable => $redis::service_enable, hasrestart => $redis::service_hasrestart, hasstatus => $redis::service_hasstatus, provider => $redis::service_provider, } } }