neoloc/grafana #37

Merged
unkinben merged 4 commits from neoloc/grafana into develop 2024-06-16 18:51:08 +10:00
3 changed files with 61 additions and 0 deletions
Showing only changes of commit 254c9f1358 - Show all commits

View File

@ -0,0 +1,2 @@
---
#profile::metrics::grafana

View File

@ -0,0 +1,58 @@
# profiles::metrics::grafana
class profiles::metrics::grafana (
Integer $http_port = 8080,
String $app_mode = 'production',
Boolean $allow_sign_up = false,
Boolean $mysql_backend = true,
String $mysql_host = '127.0.0.1:3306',
String $mysql_user = 'grafana',
Sensitive $mysql_pass = 'grafana',
Sensitive $mysql_name = 'grafana',
) {
# set the fqdn
$fqdn = $::facts['networking']['fqdn']
# when using mysql backend
if $mysql_backend {
# create a db for grafana
@@mysql::db { "mydb_${fqdn}":
user => $mysql_user,
password => $mysql_pass,
dbname => $mysql_name,
host => $fqdn,
grant => ['SELECT', 'UPDATE'],
#tag => $domain,
}
$database_config = {
type => 'mysql',
host => $mysql_host,
name => $mysql_name,
user => $mysql_user,
password => $mysql_pass.unwrap,
}
$sensitive_database_config = Sensitive($database_config)
}
# build the grafana config hash
$cfg = {
app_mode => $app_mode,
server => {
http_port => $http_port,
},
database => $sensitive_database_config,
users => {
allow_sign_up => $allow_sign_up,
},
}
# deploy grafana
class { 'grafana':
cfg => $cfg,
}
}

View File

@ -2,4 +2,5 @@
class roles::infra::metrics::grafana { class roles::infra::metrics::grafana {
include profiles::defaults include profiles::defaults
include profiles::base include profiles::base
include profiles::metrics::grafana
} }