From 159db72269296126d8896d836671f89ed39f7edd Mon Sep 17 00:00:00 2001 From: fmount Date: Fri, 23 Aug 2019 10:00:30 +0200 Subject: [PATCH] Add http_addr option to grafana config We have no reason to make grafana container listen on *:, so this change adds the http_addr option to the grafana config file and adds the related option on the wait_for tasks. Since grafana_server_addr should exists, we shouldn't rely on the _current_monitor_addr default on prometheus/grafana templates. This change also remove this default value that is not necessary anymore. Signed-off-by: fmount (cherry picked from commit 8a666bfd1554267859a39c0f87fe3fb1ea1c7418) --- roles/ceph-grafana/tasks/configure_grafana.yml | 2 ++ roles/ceph-grafana/templates/datasources-ceph-dashboard.yml.j2 | 2 +- roles/ceph-grafana/templates/grafana.ini.j2 | 1 + roles/ceph-prometheus/templates/prometheus.yml.j2 | 2 +- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/roles/ceph-grafana/tasks/configure_grafana.yml b/roles/ceph-grafana/tasks/configure_grafana.yml index bfec46574..70963491c 100644 --- a/roles/ceph-grafana/tasks/configure_grafana.yml +++ b/roles/ceph-grafana/tasks/configure_grafana.yml @@ -17,6 +17,7 @@ - name: wait for grafana to be stopped wait_for: + host: '{{ grafana_server_addr }}' port: '{{ grafana_port }}' state: stopped @@ -97,4 +98,5 @@ - name: wait for grafana to start wait_for: + host: '{{ grafana_server_addr }}' port: '{{ grafana_port }}' diff --git a/roles/ceph-grafana/templates/datasources-ceph-dashboard.yml.j2 b/roles/ceph-grafana/templates/datasources-ceph-dashboard.yml.j2 index 4746fb312..0ff13ad57 100644 --- a/roles/ceph-grafana/templates/datasources-ceph-dashboard.yml.j2 +++ b/roles/ceph-grafana/templates/datasources-ceph-dashboard.yml.j2 @@ -17,7 +17,7 @@ datasources: # org id. will default to orgId 1 if not specified orgId: 1 # url - url: 'http://{{ grafana_server_addr | default(_current_monitor_address) }}:{{ prometheus_port }}' + url: 'http://{{ grafana_server_addr }}:{{ prometheus_port }}' # enable/disable basic auth basicAuth: false # mark as default datasource. Max one per org diff --git a/roles/ceph-grafana/templates/grafana.ini.j2 b/roles/ceph-grafana/templates/grafana.ini.j2 index ff5f69457..4c897b2de 100644 --- a/roles/ceph-grafana/templates/grafana.ini.j2 +++ b/roles/ceph-grafana/templates/grafana.ini.j2 @@ -21,6 +21,7 @@ cert_key = /etc/grafana/ceph-dashboard.key domain = {{ ansible_fqdn }} protocol = {{ dashboard_protocol }} http_port = {{ grafana_port }} +http_addr = {{ grafana_server_addr }} [security] admin_user = {{ grafana_admin_user }} diff --git a/roles/ceph-prometheus/templates/prometheus.yml.j2 b/roles/ceph-prometheus/templates/prometheus.yml.j2 index 1afc9ee81..3530357e5 100644 --- a/roles/ceph-prometheus/templates/prometheus.yml.j2 +++ b/roles/ceph-prometheus/templates/prometheus.yml.j2 @@ -52,4 +52,4 @@ alerting: alertmanagers: - scheme: http static_configs: - - targets: ['{{ grafana_server_addr | default(_current_monitor_address) }}:{{ alertmanager_port }}'] + - targets: ['{{ grafana_server_addr }}:{{ alertmanager_port }}']