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:
|
|
|
|
- not containerized_deployment
|
|
|
|
- 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-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
|
|
|
|
with_items:
|
|
|
|
- "/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
|
|
|
|
|
|
|
- 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
|
|
|
|
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
|
|
|
|
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
|
|
|
|
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"
|
|
|
|
mode: 0640
|
|
|
|
when:
|
2019-05-22 16:02:42 +08:00
|
|
|
- grafana_crt | bool
|
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-05-15 20:38:46 +08:00
|
|
|
mode: 0440
|
2018-12-06 02:59:47 +08:00
|
|
|
when:
|
2019-05-22 16:02:42 +08:00
|
|
|
- grafana_key | bool
|
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 || \
|
|
|
|
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
|
|
|
|
when:
|
|
|
|
- dashboard_protocol == "https"
|
2019-05-22 16:02:42 +08:00
|
|
|
- not grafana_key | bool or not grafana_crt | bool
|
2018-12-06 02:59:47 +08:00
|
|
|
|
|
|
|
- name: set owner/group on /etc/grafana
|
|
|
|
file:
|
|
|
|
path: /etc/grafana
|
|
|
|
state: directory
|
|
|
|
# This is the UID used by the grafana container
|
|
|
|
owner: "{{ grafana_uid }}"
|
|
|
|
# This group is used by the grafana rpm
|
|
|
|
group: "grafana"
|
|
|
|
recurse: true
|
|
|
|
|
|
|
|
- name: enable and start grafana
|
|
|
|
service:
|
|
|
|
name: grafana-server
|
|
|
|
state: restarted
|
|
|
|
enabled: true
|
|
|
|
|
|
|
|
- name: wait for grafana to start
|
|
|
|
wait_for:
|
2019-07-11 05:15:45 +08:00
|
|
|
port: '{{ grafana_port }}'
|