Defined Type: benthos::instance

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

Overview

SPDX-License-Identifier: Apache-2.0

define: benthos::instance

Deploy a self-contained Benthos instance.

Please note: the 'port' parameter is used by prometheus to figure out which ports to scrape, even if it's unused here.

Parameters:

  • config_source (String)
  • port (Stdlib::Port)
  • env_variables (Hash[String, Any]) (defaults to: undef)
  • ensure (Wmflib::Ensure) (defaults to: present)


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

define benthos::instance(
    String $config_source,
    Stdlib::Port $port,
    Hash[String, Any] $env_variables = undef,
    Wmflib::Ensure $ensure = present,
) {

    require benthos

    $config_path = "/etc/benthos/${title}.yaml"
    $env_config_path = "/etc/benthos/${title}.env"
    $exec_path = '/usr/bin/benthos'
    $service_name = "benthos@${title}"

    file { $config_path:
        ensure       => stdlib::ensure($ensure, 'file'),
        owner        => 'benthos',
        group        => 'benthos',
        mode         => '0755',
        source       => "puppet:///modules/${config_source}",
        validate_cmd => '/usr/bin/benthos lint --skip-env-var-check %',
    }

    if $env_variables {
        file { $env_config_path:
            ensure  => stdlib::ensure($ensure, 'file'),
            owner   => 'benthos',
            group   => 'benthos',
            mode    => '0755',
            content => template('benthos/env_variables.erb'),
            notify  => Service[$service_name],
        }
    }

    systemd::service { $service_name:
        ensure  => present,
        content => systemd_template('benthos@'),
        restart => true,
        require => File[$config_path],
    }
}