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.
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'
),
}
}
}
|