2016-05-10 16:31:42 +02:00
|
|
|
---
|
2017-12-21 14:25:33 +01:00
|
|
|
- block:
|
|
|
|
- name: Ensure that grafana is stopped and disabled
|
|
|
|
service: name=grafana-server state=stopped enabled=no
|
2016-05-10 16:31:42 +02:00
|
|
|
|
2017-12-21 14:25:33 +01:00
|
|
|
- name: Remove the grafana deb packages
|
2019-08-05 12:06:32 +02:00
|
|
|
apt: name={{ grafana_packages }} state=absent
|
2017-12-21 14:25:33 +01:00
|
|
|
|
|
|
|
- name: Install the grafana deb repository
|
|
|
|
apt_repository: repo='{{ grafana_repo }}' state=absent update_cache=yes
|
2016-05-10 16:31:42 +02:00
|
|
|
|
2017-12-21 14:25:33 +01:00
|
|
|
when: not grafana_enabled
|
2016-05-31 19:29:31 +02:00
|
|
|
tags: [ 'grafana' ]
|
2017-12-21 14:25:33 +01:00
|
|
|
|
|
|
|
- block:
|
|
|
|
- name: Install the grafana repo key
|
|
|
|
apt_key: url={{ grafana_repo_key }} state=present
|
|
|
|
|
|
|
|
- name: Install the grafana deb repository
|
|
|
|
apt_repository: repo='{{ grafana_repo }}' state=present update_cache=yes
|
|
|
|
|
|
|
|
- name: Install the grafana deb packages
|
2019-08-05 12:06:32 +02:00
|
|
|
apt: name={{ grafana_packages }} state={{ grafana_pkg_state }} update_cache=yes cache_valid_time=1800
|
2016-05-10 16:31:42 +02:00
|
|
|
|
2017-12-21 14:25:33 +01:00
|
|
|
- name: Install the grafana configuration files
|
|
|
|
template: src={{ item }}.j2 dest=/etc/grafana/{{ item }} mode=0440 owner=root group=grafana
|
|
|
|
with_items: '{{ grafana_conf_files }}'
|
|
|
|
notify: Restart grafana
|
|
|
|
|
|
|
|
- name: Create the local dashboards directory
|
|
|
|
file: dest=/var/lib/grafana/dashboards state=directory mode=0755 owner=grafana group=grafana
|
|
|
|
|
|
|
|
- name: Install additional plugins, if any
|
|
|
|
command: grafana-cli plugins {{ item.cmd | default('install') }} {% if item.repo is defined %} --repo {{ item.repo }} {% endif %} {% if item.url is defined %} --pluginUrl {{ item.url }} {% else %} {{ item.name }} {% endif %}
|
|
|
|
with_items: '{{ grafana_additional_plugins }}'
|
|
|
|
when: grafana_additional_plugins is defined
|
|
|
|
tags: [ 'grafana', 'grafana_plugins' ]
|
|
|
|
|
|
|
|
- name: Ensure that grafana is enabled and running
|
|
|
|
service: name=grafana-server state=started enabled=yes
|
|
|
|
|
2016-05-10 16:31:42 +02:00
|
|
|
when: grafana_enabled
|
2016-05-31 19:29:31 +02:00
|
|
|
tags: [ 'grafana' ]
|