2020-07-24 00:05:25 +02:00
|
|
|
# @summary Observability using Grafana
|
|
|
|
#
|
2024-02-06 21:40:19 +01:00
|
|
|
class kandra::profile::grafana inherits kandra::profile::base {
|
2024-02-02 15:08:49 +01:00
|
|
|
|
2020-07-24 00:05:25 +02:00
|
|
|
include zulip::supervisor
|
|
|
|
|
2021-12-28 03:00:14 +01:00
|
|
|
$version = $zulip::common::versions['grafana']['version']
|
2021-12-28 02:08:41 +01:00
|
|
|
$dir = "/srv/zulip-grafana-${version}"
|
|
|
|
$bin = "${dir}/bin/grafana-server"
|
2021-12-28 02:49:35 +01:00
|
|
|
$data_dir = '/var/lib/grafana'
|
2021-12-09 05:25:49 +01:00
|
|
|
|
|
|
|
zulip::external_dep { 'grafana':
|
|
|
|
version => $version,
|
2022-02-11 20:37:31 +01:00
|
|
|
url => "https://dl.grafana.com/oss/release/grafana-${version}.linux-${zulip::common::goarch}.tar.gz",
|
2024-01-25 21:36:51 +01:00
|
|
|
tarball_prefix => "grafana-v${version}",
|
puppet: Stop relying on "tidy" ordering, which ignores metaparams.
The `tidy` parameter is buggy, and ignores all ordering
metaparameters. This is fixed in Puppet 7[^1], but it's helpful to
resolve it now. Specifically, this fixes bugs with tidy running too
early, and deleting the old version of a package before its new
version is installed or symlinked, leaving a race condition if
anything tries to run the binary in this window.
This is mostly not a problem for Supervisor-managed processes, since
the binary is already running, and can continue to run if it is tidied
out from under the running process. For stand-alone tools like wal-g,
which are run frequently by PostgreSQL, this may cause issues if
PostgreSQL tries to call them during a puppet run.
Remove all complicated uses of tidy, and replace them with an `exec`
which does the equivalent. We also generate `file` resources for
binaries, making them easier (and clearer) to specify as dependencies.
[^1]: https://puppet.atlassian.net/browse/PUP-10688
2024-04-15 20:11:08 +02:00
|
|
|
bin => [$bin],
|
|
|
|
cleanup_after => [Service[supervisor]],
|
2020-07-24 00:05:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
group { 'grafana':
|
|
|
|
ensure => present,
|
|
|
|
gid => '1070',
|
|
|
|
}
|
|
|
|
user { 'grafana':
|
|
|
|
ensure => present,
|
|
|
|
uid => '1070',
|
|
|
|
gid => '1070',
|
|
|
|
shell => '/bin/bash',
|
2021-12-28 02:50:36 +01:00
|
|
|
home => $data_dir,
|
2020-07-24 00:05:25 +02:00
|
|
|
managehome => false,
|
|
|
|
}
|
2021-12-28 02:49:35 +01:00
|
|
|
file { $data_dir:
|
2020-07-24 00:05:25 +02:00
|
|
|
ensure => directory,
|
|
|
|
owner => 'grafana',
|
|
|
|
group => 'grafana',
|
|
|
|
require => [ User[grafana], Group[grafana] ],
|
|
|
|
}
|
|
|
|
file { '/var/log/grafana':
|
|
|
|
ensure => directory,
|
|
|
|
owner => 'grafana',
|
|
|
|
group => 'grafana',
|
|
|
|
}
|
|
|
|
|
2024-02-06 21:40:19 +01:00
|
|
|
kandra::teleport::application { 'monitoring': port => '3000' }
|
|
|
|
kandra::firewall_allow { 'grafana': port => '3000' }
|
2021-06-11 22:37:36 +02:00
|
|
|
file { "${zulip::common::supervisor_conf_dir}/grafana.conf":
|
2020-07-24 00:05:25 +02:00
|
|
|
ensure => file,
|
|
|
|
require => [
|
|
|
|
Package[supervisor],
|
puppet: Stop relying on "tidy" ordering, which ignores metaparams.
The `tidy` parameter is buggy, and ignores all ordering
metaparameters. This is fixed in Puppet 7[^1], but it's helpful to
resolve it now. Specifically, this fixes bugs with tidy running too
early, and deleting the old version of a package before its new
version is installed or symlinked, leaving a race condition if
anything tries to run the binary in this window.
This is mostly not a problem for Supervisor-managed processes, since
the binary is already running, and can continue to run if it is tidied
out from under the running process. For stand-alone tools like wal-g,
which are run frequently by PostgreSQL, this may cause issues if
PostgreSQL tries to call them during a puppet run.
Remove all complicated uses of tidy, and replace them with an `exec`
which does the equivalent. We also generate `file` resources for
binaries, making them easier (and clearer) to specify as dependencies.
[^1]: https://puppet.atlassian.net/browse/PUP-10688
2024-04-15 20:11:08 +02:00
|
|
|
File[$bin],
|
2021-12-28 02:49:35 +01:00
|
|
|
File[$data_dir],
|
2020-07-24 00:05:25 +02:00
|
|
|
File['/var/log/grafana'],
|
|
|
|
],
|
|
|
|
owner => 'root',
|
|
|
|
group => 'root',
|
|
|
|
mode => '0644',
|
2024-02-06 21:40:19 +01:00
|
|
|
content => template('kandra/supervisor/conf.d/grafana.conf.erb'),
|
2020-07-24 00:05:25 +02:00
|
|
|
notify => Service[supervisor],
|
|
|
|
}
|
|
|
|
|
2024-03-21 22:28:10 +01:00
|
|
|
$email_host = zulipconf('grafana', 'email_host', '')
|
|
|
|
$email_from = zulipconf('grafana', 'email_from', '')
|
|
|
|
$email_user = zulipsecret('secrets', 'grafana_email_user', '')
|
|
|
|
$email_password = zulipsecret('secrets', 'grafana_email_password', '')
|
2020-07-24 00:05:25 +02:00
|
|
|
file { '/etc/grafana':
|
|
|
|
ensure => directory,
|
|
|
|
owner => 'root',
|
|
|
|
group => 'root',
|
2023-01-26 23:26:51 +01:00
|
|
|
mode => '0755',
|
2020-07-24 00:05:25 +02:00
|
|
|
}
|
|
|
|
file { '/etc/grafana/grafana.ini':
|
2024-03-21 22:28:10 +01:00
|
|
|
ensure => file,
|
|
|
|
owner => 'root',
|
|
|
|
group => 'root',
|
|
|
|
mode => '0644',
|
|
|
|
content => template('kandra/grafana.ini.template.erb'),
|
|
|
|
notify => Service[supervisor],
|
2020-07-24 00:05:25 +02:00
|
|
|
}
|
|
|
|
}
|