ansible/roles/monitoring/tasks/grafana.yaml

46 lines
1.2 KiB
YAML

---
- name: Add key
ansible.builtin.get_url:
url: https://apt.grafana.com/gpg.key
dest: /etc/apt/keyrings/grafana.asc
notify: apt update
- name: Grafana source
ansible.builtin.copy:
dest: /etc/apt/sources.list.d/grafana.list
content: "deb [signed-by=/etc/apt/keyrings/grafana.asc] https://apt.grafana.com stable main"
notify: apt update
- ansible.builtin.meta: flush_handlers
- name: Install Grafana
ansible.builtin.apt:
name: grafana
- name: Configure grafana
ansible.builtin.template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
owner: root
group: root
mode: 0644
notify: restart grafana
with_items:
- { src: grafana.ini, dest: /etc/grafana/grafana.ini }
- { src: grafana-ldap.toml, dest: /etc/grafana/ldap.toml }
- name: Configure grafana data source
ansible.builtin.template:
src: grafana-data-source.yml
dest: "/etc/grafana/provisioning/datasources/{{ item.name | lower }}.yaml"
owner: root
group: root
mode: 0644
notify: restart grafana
with_items:
- name: Prometheus
type: prometheus
access: proxy
url: 'http://{{ prometheus_web_listen_address }}/prometheus'
basicAuth: false
isDefault: true