Puppet Class: profile::cassandra

Defined in:
modules/profile/manifests/cassandra.pp

Overview

Class profile::cassandra

Parameters:

  • all_instances (Any) (defaults to: hiera('profile::cassandra::instances'))
  • rack (Any) (defaults to: hiera('profile::cassandra::rack'))
  • cassandra_settings (Any) (defaults to: hiera('profile::cassandra::settings'))
  • graphite_host (Any) (defaults to: hiera('graphite_host'))
  • prometheus_nodes (Any) (defaults to: hiera('prometheus_nodes'))
  • client_ips (Array[Stdlib::IP::Address]) (defaults to: hiera('profile::cassandra::client_ips', []))
  • allow_analytics (Any) (defaults to: hiera('profile::cassandra::allow_analytics'))
  • metrics_blacklist (Any) (defaults to: hiera('profile::cassandra::metrics_blacklist', undef))
  • metrics_whitelist (Any) (defaults to: hiera('profile::cassandra::metrics_whitelist', undef))
  • monitor_enabled (Any) (defaults to: hiera('profile::cassandra::monitor_enabled', true))
  • disable_graphite_metrics (Any) (defaults to: hiera('profile::cassandra::disable_graphite_metrics', false))


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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'modules/profile/manifests/cassandra.pp', line 3

class profile::cassandra(
    $all_instances = hiera('profile::cassandra::instances'),
    $rack = hiera('profile::cassandra::rack'),
    $cassandra_settings = hiera('profile::cassandra::settings'),
    $graphite_host = hiera('graphite_host'),
    $prometheus_nodes = hiera('prometheus_nodes'),
    Array[Stdlib::IP::Address] $client_ips = hiera('profile::cassandra::client_ips', []),
    $allow_analytics = hiera('profile::cassandra::allow_analytics'),
    $metrics_blacklist = hiera('profile::cassandra::metrics_blacklist', undef),
    $metrics_whitelist = hiera('profile::cassandra::metrics_whitelist', undef),
    $monitor_enabled = hiera('profile::cassandra::monitor_enabled', true),
    $disable_graphite_metrics = hiera('profile::cassandra::disable_graphite_metrics', false),
) {
    include ::passwords::cassandra
    $instances = $all_instances[$::fqdn]
    # We get the cassandra seeds from $all_instances, with a template hack
    # This is preferred over a very specialized parser function.
    $all_seeds = split(template('profile/cassandra/seeds.erb'), '\|')
    $seeds = split($all_seeds[0], ',')
    $ferm_seeds = split($all_seeds[1], ',')

    $base_settings = {
        'instances'     => $instances,
        'rack'          => $rack,
        'seeds'         => $seeds,
        'logstash_host' => 'localhost',
    }
    $cassandra_real_settings = merge($base_settings, $cassandra_settings)

    create_resources('class', {'::cassandra' => $cassandra_real_settings})

    # Selectively disable the cassandra metrics collector - T186567
    $ensure_cassandra_metrics = $disable_graphite_metrics ? {
        true    => absent,
        default => present,
    }

    # rsyslog forwards json messages sent to localhost along to logstash via kafka
    if $cassandra_real_settings['logstash_host'] == 'localhost' {
        class { '::profile::rsyslog::udp_json_logback_compat': }
    }

    class { '::cassandra::metrics':
        graphite_host => $graphite_host,
        whitelist     => $metrics_whitelist,
        blacklist     => $metrics_blacklist,
        ensure        => $ensure_cassandra_metrics,
    }

    class { '::cassandra::logging': }
    class { '::cassandra::twcs': }

    class { '::cassandra::sysctl':
        # Queue page flushes at 24MB intervals
        vm_dirty_background_bytes => 25165824,
    }

    if $cassandra_settings['tls_cluster_name'] {
        $tls_cluster_name = $cassandra_settings['tls_cluster_name']
    } else {
        $tls_cluster_name = ''
    }
    if $instances {
        $instance_names = keys($instances)
        ::cassandra::instance::monitoring{ $instance_names:
            monitor_enabled  => $monitor_enabled,
            instances        => $instances,
            tls_cluster_name => $tls_cluster_name,
        }
    } else {
        $default_instances = {
            'default' => {
                'listen_address' => $::cassandra::listen_address,
        }}
        ::cassandra::instance::monitoring{ 'default':
            monitor_enabled  => $monitor_enabled,
            instances        => $default_instances,
            tls_cluster_name => $tls_cluster_name,
        }
    }

    system::role { 'cassandra':
        description => 'Cassandra server',
    }

    $cassandra_hosts_ferm = join($ferm_seeds, ' ')
    $prometheus_nodes_ferm = join($prometheus_nodes, ' ')
    $client_ips_ferm = join($client_ips, ' ')

    # Cassandra intra-node messaging
    ferm::service { 'cassandra-intra-node':
        proto  => 'tcp',
        port   => '7000',
        srange => "@resolve((${cassandra_hosts_ferm}))",
    }

    if $cassandra_settings['tls_cluster_name'] {
        # Cassandra intra-node SSL messaging
        ferm::service { 'cassandra-intra-node-ssl':
            proto  => 'tcp',
            port   => '7001',
            srange => "@resolve((${cassandra_hosts_ferm}))",
        }
    }

    # Cassandra JMX/RMI
    ferm::service { 'cassandra-jmx-rmi':
        proto  => 'tcp',
        # hardcoded limit of 4 instances per host
        port   => '7199:7202',
        srange => "@resolve((${cassandra_hosts_ferm}))",
    }

    # Cassandra CQL query interface
    # Note: $client_ips is presumed to be IPs and not be resolved
    ferm::service { 'cassandra-cql':
        proto  => 'tcp',
        port   => '9042',
        srange => "(@resolve((${cassandra_hosts_ferm})) ${client_ips_ferm})",
    }
    # Prometheus jmx_exporter for Cassandra
    ferm::service { 'cassandra-jmx_exporter':
        proto  => 'tcp',
        port   => '7800',
        srange => "@resolve((${prometheus_nodes_ferm}))",
    }
    if $allow_analytics {
        include ::network::constants
        $analytics_networks = join($network::constants::analytics_networks, ' ')
        ferm::service { 'cassandra-analytics-cql':
            proto  => 'tcp',
            port   => '9042',
            srange => "(@resolve((${cassandra_hosts_ferm})) ${analytics_networks})",
        }

    }

}