Puppet Class: redis::sentinel

Defined in:
manifests/sentinel.pp

Summary

Install redis-sentinel

Overview

Examples:

Basic inclusion

include redis::sentinel

Configuring options

class {'redis::sentinel':
  down_after => 80000,
  log_file   => '/var/log/redis/sentinel.log',
}

Parameters:

  • auth_pass (Optional[Variant[String[1], Sensitive[String[1]]]]) (defaults to: undef) —

    The password to use to authenticate with the master and slaves.

  • config_file (Stdlib::Absolutepath) —

    The location and name of the sentinel config file.

  • config_file_orig (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.

  • config_file_mode (Stdlib::Filemode) (defaults to: '0640') —

    Permissions of config file.

  • config_group (String[1]) —

    Adjust filesystem group for config files.

  • config_owner (String[1]) —

    Adjust filesystem owner for config files.

  • conf_template (String[1]) (defaults to: 'redis/redis-sentinel.conf.epp') —

    Define which template to use.

  • daemonize (Boolean) —

    Have Redis sentinel run as a daemon.

  • down_after (Integer[1]) (defaults to: 30000) —

    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.

  • failover_timeout (Integer[1]) (defaults to: 180000) —

    Specify the failover timeout in milliseconds.

  • log_file (Stdlib::Absolutepath) —

    Specify where to write log entries.

  • log_level (Redis::LogLevel) (defaults to: 'notice') —

    Specify how much we should log.

  • master_name (String[1]) (defaults to: 'mymaster') —

    Specify the name of the master redis server. The valid charset is A-z 0-9 and the three characters “.-_”.

  • redis_host (Stdlib::Host) (defaults to: '127.0.0.1') —

    Specify the bound host of the master redis server.

  • redis_port (Stdlib::Port) (defaults to: 6379) —

    Specify the port of the master redis server.

  • requirepass (Optional[String[1]]) (defaults to: undef) —

    Specify the password to require client authentication via the AUTH command, however this feature is only available starting with Redis 5.0.1.

  • protected_mode (Boolean) (defaults to: true) —

    Whether protected mode is enabled or not. Only applicable when no bind is set.

  • package_name (String[1]) —

    The name of the package that installs sentinel.

  • package_ensure (String[1]) (defaults to: 'installed') —

    Do we ensure this package. This parameter takes effect only if an independent package is required for sentinel.

  • parallel_sync (Integer[0]) (defaults to: 1) —

    How many slaves can be reconfigured at the same time to use a new master after a failover.

  • pid_file (Stdlib::Absolutepath) —

    If sentinel is daemonized it will write its pid at this location.

  • quorum (Integer[1]) (defaults to: 2) —

    Number of sentinels that must agree that a master is down to signal sdown state.

  • sentinel_announce_hostnames (Optional[Enum['yes', 'no']]) (defaults to: undef) —

    Whether or not sentinels will announce hostnames instead of ip addresses to clients. This can be required for TLS.

  • sentinel_announce_ip (Optional[Stdlib::Host]) (defaults to: undef) —

    Specify the IP or hostname that Sentinel will announce

  • sentinel_announce_port (Optional[Stdlib::Port]) (defaults to: undef) —

    Specify the port that Sentinel will announce

  • sentinel_bind (Optional[Variant[Undef, Stdlib::IP::Address, Array[Stdlib::IP::Address]]]) (defaults to: undef) —

    Allow optional sentinel server ip binding. Can help overcome issues arising from protect-mode added Redis 3.2

  • sentinel_port (Stdlib::Port) (defaults to: 26379) —

    The port of sentinel server.

  • sentinel_resolve_hostnames (Optional[Enum['yes', 'no']]) (defaults to: undef) —

    Whether or not sentinels can resolve hostnames to ip addresses.

  • sentinel_tls_port (Optional[Stdlib::Port::Unprivileged]) (defaults to: undef) —

    Configure which TLS port to listen on.

  • service_group (String[1]) —

    The group of the config file.

  • service_name (String[1]) —

    The name of the service (for puppet to manage).

  • service_user (String[1]) —

    The owner of the config file.

  • service_ensure (Stdlib::Ensure::Service) (defaults to: 'running') —

    Ensure the service state at run time.

  • service_enable (Boolean) (defaults to: true) —

    Enable the service at boot time.

  • tls_cert_file (Optional[Stdlib::Absolutepath]) (defaults to: undef) —

    Specify which X.509 certificate file to use for TLS connections.

  • tls_key_file (Optional[Stdlib::Absolutepath]) (defaults to: undef) —

    Specify which privaye key file to use for TLS connections.

  • tls_key_file_pass (Optional[Variant[String[1], Sensitive[String[1]], Deferred]]) (defaults to: undef) —

    Passphrase to encrypt the private key file.

  • tls_ca_cert_file (Optional[Stdlib::Absolutepath]) (defaults to: undef) —

    Specify which X.509 CA certificate(s) bundle file to use.

  • tls_ca_cert_dir (Optional[Stdlib::Absolutepath]) (defaults to: undef) —

    Specify which X.509 CA certificate(s) bundle directory to use.

  • tls_auth_clients (Enum['yes', 'no', 'optional']) (defaults to: 'no') —

    Specify if clients and replicas are required to authenticate using valid client side certificates.

  • tls_replication (Boolean) (defaults to: false) —

    Specify if TLS should be enabled on replication links.

  • working_dir (Stdlib::Absolutepath) —

    The directory into which sentinel will change to avoid mount conflicts.

  • notification_script (Optional[Stdlib::Absolutepath]) (defaults to: undef) —

    Path to the notification script

  • client_reconfig_script (Optional[Stdlib::Absolutepath]) (defaults to: undef) —

    Path to the client-reconfig script

  • sentinel_auth_pass (Optional[Variant[String[1], Sensitive[String[1]]]]) (defaults to: undef) —

    The password that Sentinels use to authenticate with each other. This is needed for Redis 7 with ACLs enabled.

  • sentinel_auth_user (Optional[String[1]]) (defaults to: undef) —

    The username that Sentinels use to authenticate with each other. This is needed for Redis 7 with ACLs enabled.

  • acls (Array[String[1]]) (defaults to: []) —

    This is a way to pass an array of raw ACLs to Sentinel. The ACLs must be in the form of:

    user USERNAME [additional ACL options]
    
  • manage_redis (Boolean) (defaults to: true) —

    Manage redis base class. If set to false, sentinel is installed without redis server.



175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
# File 'manifests/sentinel.pp', line 175

class redis::sentinel (
  Stdlib::Absolutepath $config_file,
  Stdlib::Absolutepath $config_file_orig,
  String[1] $config_group,
  String[1] $config_owner,
  Boolean $daemonize,
  Stdlib::Absolutepath $log_file,
  String[1] $package_name,
  Stdlib::Absolutepath $pid_file,
  String[1] $service_group,
  String[1] $service_name,
  String[1] $service_user,
  Stdlib::Absolutepath $working_dir,
  Optional[Variant[String[1], Sensitive[String[1]]]] $auth_pass = undef,
  Stdlib::Filemode $config_file_mode = '0640',
  String[1] $conf_template = 'redis/redis-sentinel.conf.epp',
  Boolean $protected_mode = true,
  Integer[1] $down_after = 30000,
  Integer[1] $failover_timeout = 180000,
  Redis::LogLevel $log_level = 'notice',
  String[1] $master_name  = 'mymaster',
  Stdlib::Host $redis_host = '127.0.0.1',
  Stdlib::Port $redis_port = 6379,
  Optional[String[1]] $requirepass = undef,
  String[1] $package_ensure = 'installed',
  Integer[0] $parallel_sync = 1,
  Integer[1] $quorum = 2,
  Optional[Enum['yes', 'no']] $sentinel_announce_hostnames = undef,
  Optional[Stdlib::Host] $sentinel_announce_ip = undef,
  Optional[Stdlib::Port] $sentinel_announce_port = undef,
  Optional[Variant[Undef, Stdlib::IP::Address, Array[Stdlib::IP::Address]]] $sentinel_bind = undef,
  Stdlib::Port $sentinel_port = 26379,
  Optional[Enum['yes', 'no']] $sentinel_resolve_hostnames = undef,
  Optional[Stdlib::Port::Unprivileged] $sentinel_tls_port = undef,
  Stdlib::Ensure::Service $service_ensure = 'running',
  Boolean $service_enable = true,
  Optional[Stdlib::Absolutepath] $tls_cert_file = undef,
  Optional[Stdlib::Absolutepath] $tls_key_file = undef,
  Optional[Variant[String[1], Sensitive[String[1]], Deferred]] $tls_key_file_pass = undef,
  Optional[Stdlib::Absolutepath] $tls_ca_cert_file = undef,
  Optional[Stdlib::Absolutepath] $tls_ca_cert_dir = undef,
  Enum['yes', 'no', 'optional'] $tls_auth_clients = 'no',
  Boolean $tls_replication = false,
  Optional[Stdlib::Absolutepath] $notification_script = undef,
  Optional[Stdlib::Absolutepath] $client_reconfig_script = undef,
  Optional[Variant[String[1], Sensitive[String[1]]]] $sentinel_auth_pass = undef,
  Optional[String[1]] $sentinel_auth_user = undef,
  Array[String[1]] $acls = [],
  Boolean $manage_redis = true,
) {
  $auth_pass_unsensitive = if $auth_pass =~ Sensitive {
    $auth_pass.unwrap
  } else {
    $auth_pass
  }

  if $manage_redis {
    contain 'redis'
  }

  if $package_name != $redis::package_name {
    stdlib::ensure_packages([$package_name],
      {
        ensure => $package_ensure
      },
    )
    if $manage_redis {
      Package[$package_name] -> Class['redis']
    }
  }
  Package[$package_name] -> File[$config_file_orig]

  file { $config_file_orig:
    ensure  => file,
    owner   => $config_owner,
    group   => $config_group,
    mode    => $config_file_mode,
    content => epp($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,
  }

  service { $service_name:
    ensure => $service_ensure,
    enable => $service_enable,
  }
}