Puppet Class: profile::slothslos::report2drive

Defined in:
modules/profile/manifests/slothslos/report2drive.pp

Summary

Overview

SPDX-License-Identifier: Apache-2.0

Class: profile::slothslos::report2drive

Manage the top-level slothslos::report2drive class with simple parameter forwarding.

Manage multiple report2drive instances from a configuration hash.

This wrapper class provides a location to set the user and optional ensure parameters for the slothslos::report2drive defined class.

This class iterates over a hash of instance configurations and declares a slothslos::report2drive::instance resource for each entry.

Parameters:

  • ensure (Wmflib::Ensure) (defaults to: lookup('profile::slothslos::report2drive::enabled', {'default_value' => 'present' })) —

    Desired resource state for the slothslos::report2drive class. Defaults to present.

  • user (String) (defaults to: lookup('profile::slothslos::report2drive::user', { 'default_value' => 'report2drive' })) —

    The username the report2drive service runs as. Default is looked up from profile::slothslos::report2drive::user and falls back to 'report2drive' when not supplied.

  • active_host (Stdlib::Fqdn) (defaults to: lookup('profile::grafana::active_host')) —

    FQDN of the active Grafana host. Default value is looked up from profile::grafana::active_host.

  • configs (Profile::Slothslos::Report2drive::Instances) —

    A hash of instance configurations (typically produced by a deep merge so that secrets can come from a private data source).

  • instances (Profile::Slothslos::Report2drive::Instances) (defaults to: lookup('profile::slothslos::report2drive::instances'))


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

class profile::slothslos::report2drive (
    Wmflib::Ensure                              $ensure      = lookup('profile::slothslos::report2drive::enabled', {'default_value' => 'present' }),
    String                                      $user        = lookup('profile::slothslos::report2drive::user', { 'default_value' => 'report2drive' }),
    Stdlib::Fqdn                                $active_host = lookup('profile::grafana::active_host'),
    # The $configs variable is the result of a deep merge,
    # since secrets such as the Grafana bearer token and
    # the Google key come from private.git.
    Profile::Slothslos::Report2drive::Instances $instances   = lookup('profile::slothslos::report2drive::instances'),
) {
    class { 'slothslos::report2drive':
        ensure => $ensure,
        user   => $user,
    }

    $instances.each |$name, $params| {
        # drive_key must be converted from Hash[String, String] to JSON.
        # The enabled parameter is used in conjunction with active_host
        # to determine whether the report should be generated (and where).
        # The enabled parameter needs to be removed from the dict
        # since it's not a parameter of the class.
        slothslos::report2drive::instance { $name:
            * => delete(
                ($params + {
                    'drive_key' => $params['drive_key'].stdlib::to_json_pretty(),
                    'ensure'    => (($ensure == 'present') and ($active_host == $facts['networking']['fqdn']) and $params['enabled']) ? {
                        true  => present,
                        false => absent,
                    },
                    'user'      => $user,
                }),
                'enabled'
            ),
        }
    }
}