ansible-role-grafana/tasks/main.yml

93 lines
2.2 KiB
YAML

---
- name: install dependencies packages
ansible.builtin.package:
name:
- apt-transport-https
- gpg
- unzip
retries: 2
register: result
until: result is succeeded
tags: grafana
- name: add repository key
ansible.builtin.apt_key:
url: https://packages.grafana.com/gpg.key
retries: 2
register: result
until: result is succeeded
tags: grafana
- name: add repository
ansible.builtin.apt_repository:
repo: deb https://packages.grafana.com/oss/deb stable main
tags: grafana
- name: install grafana package
ansible.builtin.package:
name:
- grafana
retries: 2
register: result
until: result is succeeded
tags: grafana
- name: copy default environment variables file
ansible.builtin.template:
src: default.j2
dest: /etc/default/grafana-server
owner: root
group: root
mode: 0644
notify: restart grafana
tags: grafana
- name: copy configuration file
ansible.builtin.template:
src: grafana.ini.j2
dest: /etc/grafana/grafana.ini
owner: root
group: grafana
mode: 0640
notify: restart grafana
tags: grafana
- name: copy ldap configuration file
ansible.builtin.template:
src: ldap.toml.j2
dest: /etc/grafana/ldap.toml
owner: root
group: grafana
mode: 0640
notify: restart grafana
tags: grafana
- name: install official plugins
community.grafana.grafana_plugin:
name: '{{ item.name }}'
version: '{{ item.version|default("latest") }}'
state: '{{ item.state|default("present") }}'
loop: '{{ grafana_plugins|selectattr("url", "undefined") }}'
loop_control:
label: '{{ item.name }}'
notify: restart grafana
tags: grafana
- name: install unofficial plugins
community.grafana.grafana_plugin:
name: '{{ item.name }}'
grafana_plugin_url: '{{ item.url }}'
version: '{{ item.version|default("latest") }}'
state: '{{ item.state|default("present") }}'
loop: '{{ grafana_plugins|selectattr("url", "defined") }}'
loop_control:
label: '{{ item.name }}'
notify: restart grafana
tags: grafana
- name: enable and start service
ansible.builtin.service:
name: grafana-server
state: started
enabled: true
tags: grafana