Puppet Class: profile::cache::base

Defined in:
modules/profile/manifests/cache/base.pp

Overview

Class profile::cache::base

Sets up some common things for cache instances:

  • conftool

  • monitoring

  • logging/analytics

Parameters:

  • cache_cluster (Any) (defaults to: hiera('cache::cluster'))
  • statsd_host (Any) (defaults to: hiera('statsd'))
  • zero_site (Any) (defaults to: hiera('profile::cache::base::zero_site'))
  • packages_version (Any) (defaults to: hiera('profile::cache::base::packages_version', 'installed'))
  • varnish_version (Any) (defaults to: hiera('profile::cache::base::varnish_version', 5))
  • purge_host_regex (Any) (defaults to: hiera('profile::cache::base::purge_host_regex', ''))
  • purge_multicasts (Any) (defaults to: hiera('profile::cache::base::purge_multicasts', ['239.128.0.112']))
  • purge_varnishes (Any) (defaults to: hiera('profile::cache::base::purge_varnishes', ['127.0.0.1:3128', '127.0.0.1:3127']))
  • fe_runtime_params (Any) (defaults to: hiera('profile::cache::base::fe_runtime_params', []))
  • be_runtime_params (Any) (defaults to: hiera('profile::cache::base::be_runtime_params', []))
  • logstash_host (Any) (defaults to: hiera('logstash_host', undef))
  • logstash_syslog_port (Any) (defaults to: hiera('logstash_syslog_port', undef))
  • logstash_json_lines_port (Any) (defaults to: hiera('logstash_json_lines_port', undef))
  • log_slow_request_threshold (Any) (defaults to: hiera('profile::cache::base::log_slow_request_threshold', '60.0'))
  • allow_iptables (Any) (defaults to: hiera('profile::cache::base::allow_iptables', false))
  • extra_nets (Any) (defaults to: hiera('profile::cache::base::extra_nets', []))
  • extra_trust (Any) (defaults to: hiera('profile::cache::base::extra_trust', []))


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
# File 'modules/profile/manifests/cache/base.pp', line 8

class profile::cache::base(
    $cache_cluster = hiera('cache::cluster'),
    $statsd_host = hiera('statsd'),
    $zero_site = hiera('profile::cache::base::zero_site'),
    $packages_version = hiera('profile::cache::base::packages_version', 'installed'),
    $varnish_version = hiera('profile::cache::base::varnish_version', 5),
    $purge_host_regex = hiera('profile::cache::base::purge_host_regex', ''),
    $purge_multicasts = hiera('profile::cache::base::purge_multicasts', ['239.128.0.112']),
    $purge_varnishes = hiera('profile::cache::base::purge_varnishes', ['127.0.0.1:3128', '127.0.0.1:3127']),
    $fe_runtime_params = hiera('profile::cache::base::fe_runtime_params', []),
    $be_runtime_params = hiera('profile::cache::base::be_runtime_params', []),
    $logstash_host = hiera('logstash_host', undef),
    $logstash_syslog_port = hiera('logstash_syslog_port', undef),
    $logstash_json_lines_port = hiera('logstash_json_lines_port', undef),
    $log_slow_request_threshold = hiera('profile::cache::base::log_slow_request_threshold', '60.0'),
    $allow_iptables = hiera('profile::cache::base::allow_iptables', false),
    $extra_nets = hiera('profile::cache::base::extra_nets', []),
    $extra_trust = hiera('profile::cache::base::extra_trust', []),
) {
    require network::constants
    $wikimedia_nets = flatten(concat($::network::constants::aggregate_networks, $extra_nets))
    $wikimedia_trust = flatten(concat($::network::constants::aggregate_networks, $extra_trust))

    # Needed profiles
    require ::profile::conftool::client
    require ::profile::prometheus::varnish_exporter
    require ::profile::cache::ssl::unified
    require ::profile::standard

    # FIXME: this cannot be required or it will cause a dependency cycle. It might be a good idea not to include it here
    include ::profile::cache::kafka::webrequest

    # Globals we need to include
    include ::lvs::configuration
    include ::network::constants

    if ! $allow_iptables {
        # Prevent accidental iptables module loads
        kmod::blacklist { 'cp-bl':
            modules => ['x_tables'],
        }
    }

    class { 'conftool::scripts': }
    class { 'tlsproxy::prometheus': }
    class { 'prometheus::node_vhtcpd': }

    # TODO: Spin off a profile::cache::base::production?
    if $::realm == 'production' {
        # Only production needs system perf tweaks
        class { '::cpufrequtils': }
        class { 'cacheproxy::performance': }
    }
    # Basic varnish classes
    class { '::varnish::packages':
        version         => $packages_version,
        varnish_version => $varnish_version,
    }

    class { '::varnish::common':
        varnish_version            => $varnish_version,
        fe_runtime_params          => $fe_runtime_params,
        be_runtime_params          => $be_runtime_params,
        log_slow_request_threshold => $log_slow_request_threshold,
        logstash_host              => $logstash_host,
        logstash_json_lines_port   => $logstash_json_lines_port,
    }

    class { [
        '::varnish::common::errorpage',
        '::varnish::common::browsersec',
        '::varnish::common::director_scripts',
    ]:
    }

    class { 'varnish::zero_update':
        site         => $zero_site,
    }

    class { 'varnish::trusted_proxies': }

    ###########################################################################
    # Analytics/Logging stuff
    ###########################################################################
    if $logstash_host != undef and $logstash_syslog_port != undef {
        $forward_syslog = "${logstash_host}:${logstash_syslog_port}"
    } else {
        $forward_syslog = ''
    }

    class { '::varnish::logging':
        cache_cluster  => $cache_cluster,
        statsd_host    => $statsd_host,
        forward_syslog => $forward_syslog,
    }

    # auto-depool on shutdown + conditional one-shot auto-pool on start
    class { 'cacheproxy::traffic_pool': }

    ###########################################################################
    # Purging
    ###########################################################################
    class { 'varnish::htcppurger':
        host_regex => $purge_host_regex,
        mc_addrs   => $purge_multicasts,
        varnishes  => $purge_varnishes,
    }
    Class[varnish::packages] -> Class[varnish::htcppurger]
}