2018-12-06 02:59:47 +08:00
|
|
|
---
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Install ceph-grafana-dashboards package on RedHat or SUSE
|
|
|
|
ansible.builtin.package:
|
2019-05-23 16:26:36 +08:00
|
|
|
name: ceph-grafana-dashboards
|
2024-02-14 18:14:02 +08:00
|
|
|
state: "{{ (upgrade_ceph_packages | bool) | ternary('latest', 'present') }}"
|
2019-05-23 16:26:36 +08:00
|
|
|
register: result
|
|
|
|
until: result is succeeded
|
|
|
|
when:
|
2019-07-31 04:09:47 +08:00
|
|
|
- not containerized_deployment | bool
|
2021-03-03 22:43:50 +08:00
|
|
|
- ansible_facts['os_family'] in ['RedHat', 'Suse']
|
2019-07-04 17:43:39 +08:00
|
|
|
tags: package-install
|
2019-05-23 16:26:36 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Make sure grafana is down
|
|
|
|
ansible.builtin.service:
|
2018-12-06 02:59:47 +08:00
|
|
|
name: grafana-server
|
|
|
|
state: stopped
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Wait for grafana to be stopped
|
|
|
|
ansible.builtin.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
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Make sure grafana configuration directories exist
|
|
|
|
ansible.builtin.file:
|
2018-12-06 02:59:47 +08:00
|
|
|
path: "{{ item }}"
|
|
|
|
state: directory
|
2024-02-14 18:14:02 +08:00
|
|
|
recurse: true
|
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
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Download ceph grafana dashboards
|
|
|
|
ansible.builtin.get_url:
|
2022-06-10 23:10:23 +08:00
|
|
|
url: "https://raw.githubusercontent.com/ceph/ceph/{{ grafana_dashboard_version }}/monitoring/ceph-mixin/dashboards_out/{{ item }}"
|
2019-09-26 20:47:01 +08:00
|
|
|
dest: "/etc/grafana/dashboards/ceph-dashboard/{{ item }}"
|
2024-02-14 18:14:02 +08:00
|
|
|
mode: "0644"
|
2019-09-26 20:47:01 +08:00
|
|
|
with_items: "{{ grafana_dashboard_files }}"
|
|
|
|
when:
|
|
|
|
- not containerized_deployment | bool
|
2021-03-03 22:43:50 +08:00
|
|
|
- not ansible_facts['os_family'] in ['RedHat', 'Suse']
|
2019-09-26 20:47:01 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Write grafana.ini
|
2022-01-13 23:57:50 +08:00
|
|
|
openstack.config_template.config_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 }}"
|
2024-02-14 18:14:02 +08:00
|
|
|
mode: "0640"
|
2020-12-12 02:07:04 +08:00
|
|
|
config_type: ini
|
|
|
|
config_overrides: "{{ grafana_conf_overrides }}"
|
2018-12-06 02:59:47 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Write datasources provisioning config file
|
|
|
|
ansible.builtin.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 }}"
|
2024-02-14 18:14:02 +08:00
|
|
|
mode: "0640"
|
2018-12-06 02:59:47 +08:00
|
|
|
|
|
|
|
- name: Write dashboards provisioning config file
|
2024-02-14 18:14:02 +08:00
|
|
|
ansible.builtin.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 }}"
|
2024-02-14 18:14:02 +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
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Copy grafana SSL certificate file
|
|
|
|
ansible.builtin.copy:
|
2018-12-06 02:59:47 +08:00
|
|
|
src: "{{ grafana_crt }}"
|
|
|
|
dest: "/etc/grafana/ceph-dashboard.crt"
|
2019-07-31 04:09:47 +08:00
|
|
|
owner: "{{ grafana_uid }}"
|
|
|
|
group: "{{ grafana_uid }}"
|
2024-02-14 18:14:02 +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"
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Copy grafana SSL certificate key
|
|
|
|
ansible.builtin.copy:
|
2018-12-06 02:59:47 +08:00
|
|
|
src: "{{ grafana_key }}"
|
|
|
|
dest: "/etc/grafana/ceph-dashboard.key"
|
2019-07-31 04:09:47 +08:00
|
|
|
owner: "{{ grafana_uid }}"
|
|
|
|
group: "{{ grafana_uid }}"
|
2024-02-14 18:14:02 +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"
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Generate a Self Signed OpenSSL certificate for dashboard
|
|
|
|
ansible.builtin.shell: |
|
2018-12-06 02:59:47 +08:00
|
|
|
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)
|
2024-02-14 18:14:02 +08:00
|
|
|
changed_when: false
|
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
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Enable and start grafana
|
|
|
|
ansible.builtin.service:
|
2018-12-06 02:59:47 +08:00
|
|
|
name: grafana-server
|
|
|
|
state: restarted
|
|
|
|
enabled: true
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Wait for grafana to start
|
|
|
|
ansible.builtin.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 }}'
|