2018-12-06 02:59:47 +08:00
|
|
|
---
|
2019-05-23 16:26:36 +08:00
|
|
|
- name: install ceph-grafana-dashboards package on RedHat or SUSE
|
|
|
|
package:
|
|
|
|
name: ceph-grafana-dashboards
|
|
|
|
state: "{{ (upgrade_ceph_packages|bool) | ternary('latest','present') }}"
|
|
|
|
register: result
|
|
|
|
until: result is succeeded
|
|
|
|
when:
|
2019-07-31 04:09:47 +08:00
|
|
|
- not containerized_deployment | bool
|
2019-05-23 16:26:36 +08:00
|
|
|
- ansible_os_family in ['RedHat', 'Suse']
|
2019-07-04 17:43:39 +08:00
|
|
|
tags: package-install
|
2019-05-23 16:26:36 +08:00
|
|
|
|
2018-12-06 02:59:47 +08:00
|
|
|
- name: make sure grafana is down
|
|
|
|
service:
|
|
|
|
name: grafana-server
|
|
|
|
state: stopped
|
|
|
|
|
|
|
|
- name: wait for grafana to be stopped
|
|
|
|
wait_for:
|
2019-11-26 04:58:27 +08:00
|
|
|
host: '{{ grafana_server_addr if ip_version == "ipv4" else grafana_server_addr[1:-1] }}'
|
2019-07-11 05:15:45 +08:00
|
|
|
port: '{{ grafana_port }}'
|
2018-12-06 02:59:47 +08:00
|
|
|
state: stopped
|
|
|
|
|
|
|
|
- name: make sure grafana configuration directories exist
|
|
|
|
file:
|
|
|
|
path: "{{ item }}"
|
|
|
|
state: directory
|
|
|
|
recurse: yes
|
2019-07-31 04:09:47 +08:00
|
|
|
owner: "{{ grafana_uid }}"
|
|
|
|
group: "{{ grafana_uid }}"
|
2018-12-06 02:59:47 +08:00
|
|
|
with_items:
|
2019-07-31 04:09:47 +08:00
|
|
|
- "/etc/grafana/dashboards/ceph-dashboard"
|
2018-12-06 02:59:47 +08:00
|
|
|
- "/etc/grafana/provisioning/datasources"
|
|
|
|
- "/etc/grafana/provisioning/dashboards"
|
2019-07-12 17:03:57 +08:00
|
|
|
- "/etc/grafana/provisioning/notifiers"
|
2018-12-06 02:59:47 +08:00
|
|
|
|
2019-09-26 20:47:01 +08:00
|
|
|
- name: download ceph grafana dashboards
|
|
|
|
get_url:
|
|
|
|
url: "https://raw.githubusercontent.com/ceph/ceph/{{ grafana_dashboard_version }}/monitoring/grafana/dashboards/{{ item }}"
|
|
|
|
dest: "/etc/grafana/dashboards/ceph-dashboard/{{ item }}"
|
|
|
|
with_items: "{{ grafana_dashboard_files }}"
|
|
|
|
when:
|
|
|
|
- not containerized_deployment | bool
|
|
|
|
- not ansible_os_family in ['RedHat', 'Suse']
|
|
|
|
|
2018-12-06 02:59:47 +08:00
|
|
|
- name: write grafana.ini
|
|
|
|
template:
|
2019-05-13 22:21:16 +08:00
|
|
|
src: grafana.ini.j2
|
2018-12-06 02:59:47 +08:00
|
|
|
dest: /etc/grafana/grafana.ini
|
2019-07-31 04:09:47 +08:00
|
|
|
owner: "{{ grafana_uid }}"
|
|
|
|
group: "{{ grafana_uid }}"
|
2018-12-06 02:59:47 +08:00
|
|
|
mode: 0640
|
|
|
|
|
|
|
|
- name: write datasources provisioning config file
|
|
|
|
template:
|
2019-05-13 22:21:16 +08:00
|
|
|
src: datasources-ceph-dashboard.yml.j2
|
2018-12-06 02:59:47 +08:00
|
|
|
dest: /etc/grafana/provisioning/datasources/ceph-dashboard.yml
|
2019-07-31 04:09:47 +08:00
|
|
|
owner: "{{ grafana_uid }}"
|
|
|
|
group: "{{ grafana_uid }}"
|
2018-12-06 02:59:47 +08:00
|
|
|
mode: 0640
|
|
|
|
|
|
|
|
- name: Write dashboards provisioning config file
|
|
|
|
template:
|
2019-05-13 22:21:16 +08:00
|
|
|
src: dashboards-ceph-dashboard.yml.j2
|
2018-12-06 02:59:47 +08:00
|
|
|
dest: /etc/grafana/provisioning/dashboards/ceph-dashboard.yml
|
2019-07-31 04:09:47 +08:00
|
|
|
owner: "{{ grafana_uid }}"
|
|
|
|
group: "{{ grafana_uid }}"
|
2018-12-06 02:59:47 +08:00
|
|
|
mode: 0640
|
2019-07-12 17:03:57 +08:00
|
|
|
when: not containerized_deployment | bool
|
2018-12-06 02:59:47 +08:00
|
|
|
|
|
|
|
- name: copy grafana SSL certificate file
|
|
|
|
copy:
|
|
|
|
src: "{{ grafana_crt }}"
|
|
|
|
dest: "/etc/grafana/ceph-dashboard.crt"
|
2019-07-31 04:09:47 +08:00
|
|
|
owner: "{{ grafana_uid }}"
|
|
|
|
group: "{{ grafana_uid }}"
|
2018-12-06 02:59:47 +08:00
|
|
|
mode: 0640
|
2020-07-31 00:04:18 +08:00
|
|
|
remote_src: "{{ dashboard_tls_external | bool }}"
|
2018-12-06 02:59:47 +08:00
|
|
|
when:
|
2020-02-12 23:38:25 +08:00
|
|
|
- grafana_crt | length > 0
|
2018-12-06 02:59:47 +08:00
|
|
|
- dashboard_protocol == "https"
|
|
|
|
|
|
|
|
- name: copy grafana SSL certificate key
|
|
|
|
copy:
|
|
|
|
src: "{{ grafana_key }}"
|
|
|
|
dest: "/etc/grafana/ceph-dashboard.key"
|
2019-07-31 04:09:47 +08:00
|
|
|
owner: "{{ grafana_uid }}"
|
|
|
|
group: "{{ grafana_uid }}"
|
2019-05-15 20:38:46 +08:00
|
|
|
mode: 0440
|
2020-07-31 00:04:18 +08:00
|
|
|
remote_src: "{{ dashboard_tls_external | bool }}"
|
2018-12-06 02:59:47 +08:00
|
|
|
when:
|
2020-02-12 23:38:25 +08:00
|
|
|
- grafana_key | length > 0
|
2018-12-06 02:59:47 +08:00
|
|
|
- dashboard_protocol == "https"
|
|
|
|
|
|
|
|
- name: generate a Self Signed OpenSSL certificate for dashboard
|
|
|
|
shell: |
|
|
|
|
test -f /etc/grafana/ceph-dashboard.key -a -f /etc/grafana/ceph-dashboard.crt || \
|
2019-07-31 04:09:47 +08:00
|
|
|
(openssl req -new -nodes -x509 -subj '/O=IT/CN=ceph-grafana' -days 3650 -keyout /etc/grafana/ceph-dashboard.key -out /etc/grafana/ceph-dashboard.crt -extensions v3_ca && \
|
|
|
|
chown {{ grafana_uid }}:{{ grafana_uid }} /etc/grafana/ceph-dashboard.key /etc/grafana/ceph-dashboard.crt)
|
2018-12-06 02:59:47 +08:00
|
|
|
when:
|
|
|
|
- dashboard_protocol == "https"
|
2020-02-12 23:38:25 +08:00
|
|
|
- grafana_key | length == 0 or grafana_crt | length == 0
|
2018-12-06 02:59:47 +08:00
|
|
|
|
|
|
|
- name: enable and start grafana
|
|
|
|
service:
|
|
|
|
name: grafana-server
|
|
|
|
state: restarted
|
|
|
|
enabled: true
|
|
|
|
|
|
|
|
- name: wait for grafana to start
|
|
|
|
wait_for:
|
2019-11-26 04:58:27 +08:00
|
|
|
host: '{{ grafana_server_addr if ip_version == "ipv4" else grafana_server_addr[1:-1] }}'
|
2019-07-11 05:15:45 +08:00
|
|
|
port: '{{ grafana_port }}'
|