summaryrefslogtreecommitdiffstats
path: root/modules/tozt
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2021-07-01 23:35:30 -0400
committerJesse Luehrs <doy@tozt.net>2021-07-01 23:35:30 -0400
commit4e5410017e38ad0d425c68d032bc4c908c5dbded (patch)
tree7e4c1fefc843edd902166289d361da9ee004558f /modules/tozt
parent737acd4a3b38773979ff1fc0c192a703655eb46c (diff)
downloadpuppet-tozt-4e5410017e38ad0d425c68d032bc4c908c5dbded.tar.gz
puppet-tozt-4e5410017e38ad0d425c68d032bc4c908c5dbded.zip
install grafana
Diffstat (limited to 'modules/tozt')
-rw-r--r--modules/tozt/files/grafana.ini13
-rw-r--r--modules/tozt/files/nginx/grafana-tls.conf14
-rw-r--r--modules/tozt/files/nginx/grafana.conf10
-rw-r--r--modules/tozt/manifests/prometheus.pp35
4 files changed, 72 insertions, 0 deletions
diff --git a/modules/tozt/files/grafana.ini b/modules/tozt/files/grafana.ini
new file mode 100644
index 0000000..0c13f1c
--- /dev/null
+++ b/modules/tozt/files/grafana.ini
@@ -0,0 +1,13 @@
+[server]
+http_port = 3001
+domain = grafana.tozt.net
+root_url = https://grafana.tozt.net/
+
+[database]
+type = postgres
+host = 127.0.0.1:5432
+name = grafana
+user = grafana
+
+[users]
+allow_sign_up = false
diff --git a/modules/tozt/files/nginx/grafana-tls.conf b/modules/tozt/files/nginx/grafana-tls.conf
new file mode 100644
index 0000000..5fc5de4
--- /dev/null
+++ b/modules/tozt/files/nginx/grafana-tls.conf
@@ -0,0 +1,14 @@
+server {
+ listen 443 ssl;
+ server_name grafana.tozt.net;
+
+ access_log /var/log/nginx/grafana.access.log;
+ error_log /var/log/nginx/grafana.error.log;
+
+ include ssl;
+
+ location / {
+ proxy_pass http://127.0.0.1:3001/;
+ }
+}
+# vim:ft=nginx
diff --git a/modules/tozt/files/nginx/grafana.conf b/modules/tozt/files/nginx/grafana.conf
new file mode 100644
index 0000000..3d5aca8
--- /dev/null
+++ b/modules/tozt/files/nginx/grafana.conf
@@ -0,0 +1,10 @@
+server {
+ listen 80;
+ server_name grafana.tozt.net;
+
+ access_log /var/log/nginx/grafana.access.log;
+ error_log /var/log/nginx/grafana.error.log;
+
+ rewrite ^(.*) https://$host$1 permanent;
+}
+# vim:ft=nginx
diff --git a/modules/tozt/manifests/prometheus.pp b/modules/tozt/manifests/prometheus.pp
index 444ac67..8120cdc 100644
--- a/modules/tozt/manifests/prometheus.pp
+++ b/modules/tozt/manifests/prometheus.pp
@@ -1,5 +1,7 @@
class tozt::prometheus {
+ include postgres;
include prometheus
+ include grafana
file { "/media/persistent/prometheus":
ensure => directory,
@@ -15,11 +17,44 @@ class tozt::prometheus {
source => 'puppet:///modules/tozt/prometheus-override.conf';
}
+ file { "/etc/grafana.ini":
+ source => "puppet:///modules/tozt/grafana.ini",
+ require => Package["grafana"];
+ }
+
+ exec { "create grafana db user":
+ provider => shell,
+ command => "createuser -d grafana",
+ user => 'postgres',
+ unless => "psql -Atc 'select usename from pg_catalog.pg_user' | grep -F grafana",
+ require => [
+ Package["postgresql"],
+ Service["postgresql"],
+ ];
+ }
+
+ exec { "create grafana db":
+ provider => shell,
+ command => "createdb -U grafana grafana",
+ user => 'postgres',
+ unless => "psql -Atc 'select datname from pg_catalog.pg_database' | grep -F grafana",
+ require => [
+ Exec["create grafana db user"],
+ Package["postgresql"],
+ Service["postgresql"],
+ ];
+ }
+
nginx::site {
"prometheus-tls":
source => 'puppet:///modules/tozt/nginx/prometheus-tls.conf',
require => Class['certbot'];
"prometheus":
source => 'puppet:///modules/tozt/nginx/prometheus.conf';
+ "grafana-tls":
+ source => 'puppet:///modules/tozt/nginx/grafana-tls.conf',
+ require => Class['certbot'];
+ "grafana":
+ source => 'puppet:///modules/tozt/nginx/grafana.conf';
}
}