Puppet Class: profile::redis::slave

Defined in:
modules/profile/manifests/redis/slave.pp

Overview

Parameters:

  • settings (Any) (defaults to: hiera('profile::redis::slave::settings'))
  • instance_overrides (Any) (defaults to: lookup('profile::redis::slave::instance_overrides', {'default_value' => {}}))
  • master (Any) (defaults to: hiera('profile::redis::slave::master'))
  • aof (Any) (defaults to: hiera('profile::redis::slave::aof', false))
  • prometheus_nodes (Any) (defaults to: hiera('prometheus_nodes'))


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'modules/profile/manifests/redis/slave.pp', line 1

class profile::redis::slave(
    $settings = hiera('profile::redis::slave::settings'),
    $instance_overrides = lookup('profile::redis::slave::instance_overrides', {'default_value' => {}}),
    $master = hiera('profile::redis::slave::master'),
    $aof = hiera('profile::redis::slave::aof', false),
    $prometheus_nodes = hiera('prometheus_nodes'),
){
    # Figure out the redis instances running on the master from Puppetdb
    $resources = query_resources(
        "fqdn='${master}'",
        'Redis::Instance[~".*"]', false)
    $password = $resources[0]['parameters']['settings']['requirepass']
    $redis_ports = inline_template("<%= @resources.map{|r| r['title']}.join ' ' -%>")
    $instances = split($redis_ports, ' ')
    $uris = apply_format("localhost:%s/${password}", $instances)

    $auth_settings = {
        'masterauth'  => $password,
        'requirepass' => $password,
    }

    $slaveof = ipresolve($master, 4)

    $instances.each |String $instance| {
        if $instance in keys($instance_overrides) {
            $override = $instance_overrides[$instance]
        } else {
            $override = {}
        }
        ::profile::redis::instance { $instance:
            settings => merge($settings, $auth_settings, $override),
            slaveof  => $slaveof,
            aof      => $aof,
        }
    }

    # Add monitoring, using nrpe and not remote checks anymore
    redis::monitoring::nrpe_instance { $instances: }

    profile::prometheus::redis_exporter{ $instances:
        password         => $password,
        prometheus_nodes => $prometheus_nodes,
    }

    ferm::service { 'redis_slave_role':
        proto   => 'tcp',
        notrack => true,
        port    => inline_template('(<%= @redis_ports %>)'),
    }

}