Puppet Class: puppet_metrics_dashboard::post_start_configs
- Defined in:
- manifests/post_start_configs.pp
Summary
InfluxDB post-start configsOverview
Some InfluxDB configuration requires the InfluxDB service to first be running. Configs that fall into that category are contained here.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 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 |
# File 'manifests/post_start_configs.pp', line 7
class puppet_metrics_dashboard::post_start_configs {
# Fix a timing issue where influxdb does not start fully before creating users
exec { 'wait for influxdb':
command => '/bin/sleep 10',
unless => '/usr/bin/influx -execute "SHOW DATABASES"',
require => Service[$puppet_metrics_dashboard::influx_db_service_name],
}
# lint:ignore:140chars
exec { 'create influxdb admin user':
command => "/usr/bin/influx -execute \"CREATE USER admin WITH PASSWORD '${puppet_metrics_dashboard::influx_db_password}' WITH ALL PRIVILEGES\"",
unless => "/usr/bin/influx -username admin -password ${puppet_metrics_dashboard::influx_db_password} -execute \'show users\' | grep \'admin true\'",
require => Exec['wait for influxdb'],
}
# lint:endignore
$puppet_metrics_dashboard::influxdb_database_name.each |$db_name| {
# lint:ignore:140chars
exec { "create influxdb puppet_metrics database ${db_name}":
command => "/usr/bin/influx -username admin -password ${puppet_metrics_dashboard::influx_db_password} -execute \"create database ${db_name}\"",
unless => "/usr/bin/influx -username admin -password ${puppet_metrics_dashboard::influx_db_password} -execute \'show databases\' | grep ${db_name}",
require => Exec['create influxdb admin user'],
}
# lint:endignore
}
$_uri = $puppet_metrics_dashboard::use_dashboard_ssl ? {
true => 'https',
default => 'http',
}
# Configure grafana to use InfluxDB with any number of database names
$puppet_metrics_dashboard::influxdb_database_name.each |$db_name| {
grafana_datasource { "influxdb_${db_name}":
grafana_url => "${_uri}://localhost:${puppet_metrics_dashboard::grafana_http_port}",
type => 'influxdb',
database => $db_name,
url => 'http://localhost:8086',
access_mode => 'proxy',
is_default => false,
user => 'admin',
password => $puppet_metrics_dashboard::influx_db_password,
grafana_user => 'admin',
grafana_password => $puppet_metrics_dashboard::grafana_password,
require => [
Service['grafana-server'],
Exec["create influxdb puppet_metrics database ${db_name}"]
],
}
}
}
|