neoloc/grafana #37
2
hieradata/roles/infra/metrics/grafana.yaml
Normal file
2
hieradata/roles/infra/metrics/grafana.yaml
Normal file
@ -0,0 +1,2 @@
|
||||
---
|
||||
#profile::metrics::grafana
|
||||
58
site/profiles/manifests/metrics/grafana.pp
Normal file
58
site/profiles/manifests/metrics/grafana.pp
Normal 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,
|
||||
}
|
||||
|
||||
}
|
||||
@ -2,4 +2,5 @@
|
||||
class roles::infra::metrics::grafana {
|
||||
include profiles::defaults
|
||||
include profiles::base
|
||||
include profiles::metrics::grafana
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user