64 lines
2.1 KiB
YAML
64 lines
2.1 KiB
YAML
---
|
|
- block:
|
|
- name: Ensure that grafana is stopped and disabled
|
|
service: name=grafana-server state=stopped enabled=no
|
|
|
|
- name: Remove the grafana deb packages
|
|
apt: name={{ grafana_packages }} state=absent
|
|
|
|
- name: Install the grafana deb repository
|
|
apt_repository: repo='{{ grafana_repo }}' state=absent update_cache=yes
|
|
|
|
when: not grafana_enabled
|
|
tags: [ 'grafana' ]
|
|
|
|
- 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
|
|
apt: name={{ grafana_packages }} state={{ grafana_pkg_state }} update_cache=yes cache_valid_time=1800
|
|
|
|
- name: Install the grafana configuration files
|
|
ansible.builtin.template:
|
|
src: '{{ item }}.j2'
|
|
dest: '/etc/grafana/{{ item }}'
|
|
mode: 0440
|
|
owner: root
|
|
group: grafana
|
|
loop: '{{ grafana_conf_files }}'
|
|
notify: Restart grafana
|
|
tags: [ 'grafana', 'grafana_conf' ]
|
|
|
|
- name: Install the grafana LDAP configuration files
|
|
ansible.builtin.template:
|
|
src: '{{ item }}.j2'
|
|
dest: '/etc/grafana/{{ item }}'
|
|
mode: 0440
|
|
owner: root
|
|
group: grafana
|
|
loop: '{{ grafana_ldap_conf_file }}'
|
|
notify: Restart grafana
|
|
when: grafana_ldap_auth
|
|
tags: [ 'grafana', 'grafana_conf', 'grafana_ldap' ]
|
|
|
|
- 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
|
|
community.grafana.grafana_plugin:
|
|
name: '{{ item.name }}'
|
|
state: '{{ item.state | default('present') }}'
|
|
grafana_repo: '{{ item.repo | default('https://grafana.com/api/plugins') }}'
|
|
loop: '{{ grafana_additional_plugins }}'
|
|
tags: [ 'grafana', 'grafana_plugins' ]
|
|
|
|
- name: Ensure that grafana is enabled and running
|
|
service: name=grafana-server state=started enabled=yes
|
|
|
|
when: grafana_enabled
|
|
tags: [ 'grafana' ]
|