From 6c928d87ca3bd2af445eef3be5430d987abcdaaa Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Mon, 26 Sep 2022 08:23:54 +0300 Subject: [PATCH] Configure Grafana's default_home_dashboard_path properly Using `matrix_synapse_*` variables within the `matrix-grafana` role is not a good practice. We now have a `matrix_grafana_default_home_dashboard_path` variable with a good universal default value and we override it via `group_vars/matrix_servers` based on enabled components, etc. This is a better fix for https://github.com/spantaleev/matrix-docker-ansible-deploy/pull/2133 --- group_vars/matrix_servers | 9 +++++++++ roles/matrix-grafana/defaults/main.yml | 4 ++++ roles/matrix-grafana/templates/grafana.ini.j2 | 6 +----- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/group_vars/matrix_servers b/group_vars/matrix_servers index 01e287a7b..68e524531 100755 --- a/group_vars/matrix_servers +++ b/group_vars/matrix_servers @@ -2484,6 +2484,15 @@ matrix_grafana_dashboard_download_urls_all: | (matrix_prometheus_postgres_exporter_dashboard_urls if matrix_prometheus_postgres_exporter_enabled else []) }} +matrix_grafana_default_home_dashboard_path: |- + {{ + { + 'synapse': ('/etc/grafana/dashboards/synapse.json' if matrix_synapse_metrics_enabled else '/etc/grafana/dashboards/node-exporter-full.json'), + 'dendrite': '/etc/grafana/dashboards/node-exporter-full.json', + 'conduit': '/etc/grafana/dashboards/node-exporter-full.json', + }[matrix_homeserver_implementation] + }} + matrix_grafana_systemd_wanted_services_list: | {{ [] diff --git a/roles/matrix-grafana/defaults/main.yml b/roles/matrix-grafana/defaults/main.yml index ffdfa1322..61d27839c 100644 --- a/roles/matrix-grafana/defaults/main.yml +++ b/roles/matrix-grafana/defaults/main.yml @@ -54,6 +54,10 @@ matrix_grafana_content_security_policy: true matrix_grafana_content_security_policy_customized: false matrix_grafana_content_security_policy_template: "script-src 'self' 'unsafe-eval' 'unsafe-inline' http: https: 'strict-dynamic' $NONCE;object-src 'none';font-src 'self';style-src 'self' 'unsafe-inline' blob:;img-src * data:;base-uri 'self';connect-src 'self' grafana.com ws://$ROOT_PATH wss://$ROOT_PATH;manifest-src 'self';media-src 'none';form-action 'self';" +# matrix_grafana_default_home_dashboard_path influences the `default_home_dashboard_path` grafana.ini setting, +# which is an in-container path for the default dashboard. +matrix_grafana_default_home_dashboard_path: /etc/grafana/dashboards/node-exporter-full.json + # A list of extra arguments to pass to the container matrix_grafana_container_extra_arguments: [] diff --git a/roles/matrix-grafana/templates/grafana.ini.j2 b/roles/matrix-grafana/templates/grafana.ini.j2 index 1e06683ee..ac609f914 100644 --- a/roles/matrix-grafana/templates/grafana.ini.j2 +++ b/roles/matrix-grafana/templates/grafana.ini.j2 @@ -26,8 +26,4 @@ enabled = {{ matrix_grafana_anonymous_access }} org_name = "{{ matrix_grafana_anonymous_access_org_name }}" [dashboards] -{% if matrix_synapse_metrics_enabled %} -default_home_dashboard_path = /etc/grafana/dashboards/synapse.json -{% else %} -default_home_dashboard_path = /etc/grafana/dashboards/node-exporter-full.json -{% endif %} +default_home_dashboard_path = {{ matrix_grafana_default_home_dashboard_path }}