This commit is contained in:
mwiegand 2021-07-01 22:03:45 +02:00
parent 9114e560ff
commit 76e02a243f
3 changed files with 49 additions and 3 deletions

View file

@ -1,3 +1,25 @@
files['/etc/grafana/test'] = {
'content': repo.libs.ini.dumps(repo.libs.ini.parse(c)),
assert node.has_bundle('redis')
assert node.has_bundle('postgresql')
from shlex import quote
files['/etc/grafana/grafana.ini'] = {
'content': repo.libs.ini.dumps(node.metadata.get('grafana/config')),
'triggers': [
'svc_systemd:grafana-server:restart',
]
}
svc_systemd['grafana-server'] = {
'needs': [
'pkg_apt:grafana',
],
}
actions['reset_grafana_admin_password'] = {
'command': f"grafana-cli admin reset-admin-password {quote(node.metadata.get('grafana/config/security/admin_password'))}",
'needs': [
'svc_systemd:grafana-server',
],
}

View file

@ -1,3 +1,5 @@
postgres_password = repo.vault.password_for(f'{node.name} postgres role grafana')
defaults = {
'apt': {
'packages': {
@ -7,6 +9,27 @@ defaults = {
'deb https://packages.grafana.com/oss/deb stable main',
],
},
'grafana': {
'config': {
'server': {
'http_port': 3370,
},
'database': {
'url': f'postgres://grafana:{postgres_password}@localhost:5432/grafana',
},
'remote_cache': {
'type': 'redis',
'connstr': 'addr=127.0.0.1:6379',
},
'security': {
'admin_user': 'admin',
'admin_password': str(repo.vault.password_for(f'{node.name} grafana admin')),
},
'users': {
'allow_signup': False,
},
},
},
'postgresql': {
'databases': {
'grafana': {
@ -15,7 +38,7 @@ defaults = {
},
'roles': {
'grafana': {
'password': repo.vault.password_for(f'{node.name} postgres role grafana'),
'password': postgres_password,
},
},
},

View file

@ -11,6 +11,7 @@
'grafana',
'influxdb2',
'postgresql',
'redis',
'wireguard',
'zfs',
],