From e4e1b386b051764c2e4d2383a881d556733bba2c Mon Sep 17 00:00:00 2001 From: Dimitri Savineau Date: Mon, 27 Jan 2020 14:47:00 -0500 Subject: [PATCH] dashboard: allow configuring multiple grafana host When using multiple grafana hosts then we push set the grafana and prometheus URL and push the dashboard layout to a single node. grafana_server_addrs is the list of all grafana nodes and used during the ceph-dashboard role (on mgr/mon nodes). grafana_server_addr is the current grafana node used during the ceph-grafana and ceph-prometheus role (on grafana-server nodes). We don't have the grafana_server_addr fact duplication code between external vs collocated nodes. Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1784011 Signed-off-by: Dimitri Savineau (cherry picked from commit c6e96699f71c634b3028d819bdc29aedd8b64ce9) --- .../tasks/configure_dashboard.yml | 22 ++++++------------- .../tasks/configure_grafana_layouts.yml | 13 +++++++++++ roles/ceph-facts/tasks/grafana.yml | 12 +++++----- 3 files changed, 26 insertions(+), 21 deletions(-) create mode 100644 roles/ceph-dashboard/tasks/configure_grafana_layouts.yml diff --git a/roles/ceph-dashboard/tasks/configure_dashboard.yml b/roles/ceph-dashboard/tasks/configure_dashboard.yml index b9249100e..1804c1e56 100644 --- a/roles/ceph-dashboard/tasks/configure_dashboard.yml +++ b/roles/ceph-dashboard/tasks/configure_dashboard.yml @@ -94,12 +94,6 @@ changed_when: false until: ac_result.rc == 0 -- name: set grafana url - command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} dashboard set-grafana-api-url {{ dashboard_protocol }}://{{ grafana_server_addr }}:{{ grafana_port }}" - delegate_to: "{{ groups[mon_group_name][0] }}" - run_once: true - changed_when: false - - name: set grafana api user command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} dashboard set-grafana-api-username {{ grafana_admin_user }}" delegate_to: "{{ groups[mon_group_name][0] }}" @@ -113,17 +107,22 @@ changed_when: false - name: set alertmanager host - command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} dashboard set-alertmanager-api-host {{ dashboard_protocol }}://{{ grafana_server_addr }}:{{ alertmanager_port }}" + command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} dashboard set-alertmanager-api-host {{ dashboard_protocol }}://{{ grafana_server_addrs | first }}:{{ alertmanager_port }}" delegate_to: "{{ groups[mon_group_name][0] }}" run_once: true changed_when: false - name: set prometheus host - command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} dashboard set-prometheus-api-host {{ dashboard_protocol }}://{{ grafana_server_addr }}:{{ prometheus_port }}" + command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} dashboard set-prometheus-api-host {{ dashboard_protocol }}://{{ grafana_server_addrs | first }}:{{ prometheus_port }}" delegate_to: "{{ groups[mon_group_name][0] }}" run_once: true changed_when: false +- include_tasks: configure_grafana_layouts.yml + with_items: '{{ grafana_server_addrs }}' + vars: + grafana_server_addr: '{{ item }}' + - name: dashboard object gateway management frontend when: groups.get(rgw_group_name, []) | length > 0 block: @@ -220,13 +219,6 @@ run_once: true when: ip_version == 'ipv6' -- name: inject grafana dashboard layouts - command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} dashboard grafana dashboards update" - delegate_to: "{{ groups[mon_group_name][0] }}" - run_once: true - changed_when: false - when: containerized_deployment | bool - - name: disable mgr dashboard module (restart) command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} mgr module disable dashboard" changed_when: false diff --git a/roles/ceph-dashboard/tasks/configure_grafana_layouts.yml b/roles/ceph-dashboard/tasks/configure_grafana_layouts.yml new file mode 100644 index 000000000..00e8eaacd --- /dev/null +++ b/roles/ceph-dashboard/tasks/configure_grafana_layouts.yml @@ -0,0 +1,13 @@ +--- +- name: set grafana url + command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} dashboard set-grafana-api-url {{ dashboard_protocol }}://{{ grafana_server_addr }}:{{ grafana_port }}" + delegate_to: "{{ groups[mon_group_name][0] }}" + run_once: true + changed_when: false + +- name: inject grafana dashboard layouts + command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} dashboard grafana dashboards update" + delegate_to: "{{ groups[mon_group_name][0] }}" + run_once: true + changed_when: false + when: containerized_deployment | bool diff --git a/roles/ceph-facts/tasks/grafana.yml b/roles/ceph-facts/tasks/grafana.yml index 03b695ee3..47bae2eac 100644 --- a/roles/ceph-facts/tasks/grafana.yml +++ b/roles/ceph-facts/tasks/grafana.yml @@ -16,20 +16,20 @@ - dashboard_enabled | bool - inventory_hostname in groups[grafana_server_group_name] -- name: set grafana_server_addr fact - ipv4 - (external instance) +- name: set grafana_server_addrs fact - ipv4 set_fact: - grafana_server_addr: "{{ hostvars[groups.get(grafana_server_group_name, []) | first]['ansible_all_ipv4_addresses'] | ips_in_ranges(public_network.split(',')) | first }}" + grafana_server_addrs: "{{ (grafana_server_addrs | default([]) + [hostvars[item]['ansible_all_ipv4_addresses'] | ips_in_ranges(public_network.split(',')) | first]) | unique }}" + with_items: "{{ groups.get(grafana_server_group_name, []) }}" when: - groups.get(grafana_server_group_name, []) | length > 0 - ip_version == 'ipv4' - dashboard_enabled | bool - - inventory_hostname not in groups[grafana_server_group_name] -- name: set grafana_server_addr fact - ipv6 - (external instance) +- name: set grafana_server_addrs fact - ipv6 set_fact: - grafana_server_addr: "{{ hostvars[groups.get(grafana_server_group_name, []) | first]['ansible_all_ipv6_addresses'] | ips_in_ranges(public_network.split(',')) | last | ipwrap }}" + grafana_server_addrs: "{{ (grafana_server_addrs | default([]) + [hostvars[item]['ansible_all_ipv6_addresses'] | ips_in_ranges(public_network.split(',')) | last | ipwrap]) | unique }}" + with_items: "{{ groups.get(grafana_server_group_name, []) }}" when: - groups.get(grafana_server_group_name, []) | length > 0 - ip_version == 'ipv6' - dashboard_enabled | bool - - inventory_hostname not in groups[grafana_server_group_name] -- 2.39.5