bundles/grafana: add support for custom managed dashboards

This commit is contained in:
Franzi 2021-05-02 17:49:40 +02:00
parent fe668fd5d4
commit c1b1dc1a29
Signed by: kunsi
GPG key ID: 12E3D2136B818350

View file

@ -1,5 +1,6 @@
from itertools import count from itertools import count
from os.path import join from os import listdir
from os.path import isdir, isfile, join
from pathlib import Path from pathlib import Path
from uuid import UUID from uuid import UUID
@ -113,3 +114,17 @@ for rnode in repo.nodes:
'svc_systemd:grafana-server:restart', 'svc_systemd:grafana-server:restart',
}, },
} }
additional_path = join(repo.path, 'data', 'grafana', 'files', node.name, 'dashboards')
if isdir(additional_path):
for file in listdir(additional_path):
if not isfile(join(additional_path, file)) or file.startswith('.') or file.startswith('_'):
continue
files[f'/var/lib/grafana/dashboards/{file}'] = {
'source': join(node.name, 'dashboards', file),
'triggers': {
'svc_systemd:grafana-server:restart',
},
}