Puppet Class: profile::benthos

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

Overview

SPDX-License-Identifier: Apache-2.0

Class: profile::benthos

Deploy self-contained Benthos instances and configurations, together with base package etc..

Parameters:

  • ensure (Wmflib::Ensure) (defaults to: lookup('profile::benthos::ensure', { 'default_value' => present }))
  • instances (Hash[String, Any]) (defaults to: lookup('profile::benthos::instances'))
  • use_geoip (Boolean) (defaults to: lookup('profile::benthos::use_geoip', { 'default_value' => false} ))


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

class profile::benthos(
    Wmflib::Ensure $ensure = lookup('profile::benthos::ensure', { 'default_value' => present }),
    Hash[String, Any] $instances = lookup('profile::benthos::instances'),
    Boolean $use_geoip = lookup('profile::benthos::use_geoip', { 'default_value' => false} ),
) {
    class { 'benthos':
        ensure => $ensure,
    }

    if $use_geoip {
        class { 'geoip': }
    }

    $instances.each | $instance, $instance_config | {
        if has_key($instance_config, 'kafka') {
            $kafka_cluster_name = sprintf('%s-%s', $instance_config['kafka']['cluster'], $instance_config['kafka']['site'])
            $kafka = kafka_config($kafka_cluster_name)
            # Setting up base environment variables
            $kafka_env_variables = {
                kafka_brokers => $kafka['brokers']['ssl_string'],
                kafka_topics  => join($instance_config['kafka']['topics'], ','),
            }
        } else {
            $kafka_env_variables = {}
        }

        $base_env_variables = {
            port => $instance_config['port'],
        }

        $custom_env_variables = $instance_config['env_variables'] ? {
            undef   => {},
            default => $instance_config['env_variables'],
        }

        $instance_ensure = $ensure == 'absent' ? {
            true    => 'absent',
            default => $instance_config['ensure'],
        }

        benthos::instance { $instance:
            ensure        => $instance_ensure,
            env_variables => $base_env_variables + $kafka_env_variables + $custom_env_variables,
            config_source => "profile/benthos/instances/${instance}.yaml",
            port          => $instance_config['port'],
        }
    }
}