ceph-ansible/roles/ceph-grafana/tasks/configure_grafana.yml

97 lines
2.6 KiB
YAML
Raw Normal View History

---
- 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']
tags: package-install
- name: make sure grafana is down
service:
name: grafana-server
state: stopped
- name: wait for grafana to be stopped
wait_for:
port: '{{ grafana_port }}'
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"
- "/etc/grafana/provisioning/notifiers"
- name: write grafana.ini
template:
src: grafana.ini.j2
dest: /etc/grafana/grafana.ini
mode: 0640
- name: write datasources provisioning config file
template:
src: datasources-ceph-dashboard.yml.j2
dest: /etc/grafana/provisioning/datasources/ceph-dashboard.yml
mode: 0640
- name: Write dashboards provisioning config file
template:
src: dashboards-ceph-dashboard.yml.j2
dest: /etc/grafana/provisioning/dashboards/ceph-dashboard.yml
mode: 0640
when: not containerized_deployment | bool
- name: copy grafana SSL certificate file
copy:
src: "{{ grafana_crt }}"
dest: "/etc/grafana/ceph-dashboard.crt"
mode: 0640
when:
- grafana_crt | bool
- dashboard_protocol == "https"
- name: copy grafana SSL certificate key
copy:
src: "{{ grafana_key }}"
dest: "/etc/grafana/ceph-dashboard.key"
mode: 0440
when:
- grafana_key | bool
- 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"
- not grafana_key | bool or not grafana_crt | bool
- 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:
port: '{{ grafana_port }}'