2019-04-11 17:20:56 +00:00
|
|
|
---
|
|
|
|
- name: install dependencies packages
|
2021-08-21 21:15:13 +00:00
|
|
|
ansible.builtin.package:
|
|
|
|
name:
|
|
|
|
- apt-transport-https
|
2021-08-21 21:21:52 +00:00
|
|
|
- gpg
|
|
|
|
- unzip
|
2019-04-11 17:20:56 +00:00
|
|
|
retries: 2
|
|
|
|
register: result
|
|
|
|
until: result is succeeded
|
|
|
|
tags: grafana
|
|
|
|
|
|
|
|
- name: add repository key
|
2021-08-21 21:15:13 +00:00
|
|
|
ansible.builtin.apt_key:
|
2019-04-11 17:20:56 +00:00
|
|
|
url: https://packages.grafana.com/gpg.key
|
|
|
|
retries: 2
|
|
|
|
register: result
|
|
|
|
until: result is succeeded
|
|
|
|
tags: grafana
|
|
|
|
|
|
|
|
- name: add repository
|
2021-08-21 21:15:13 +00:00
|
|
|
ansible.builtin.apt_repository:
|
2019-04-11 17:20:56 +00:00
|
|
|
repo: deb https://packages.grafana.com/oss/deb stable main
|
|
|
|
tags: grafana
|
|
|
|
|
|
|
|
- name: install grafana package
|
2021-08-21 21:15:13 +00:00
|
|
|
ansible.builtin.package:
|
|
|
|
name:
|
|
|
|
- grafana
|
2019-04-11 17:20:56 +00:00
|
|
|
retries: 2
|
|
|
|
register: result
|
|
|
|
until: result is succeeded
|
|
|
|
tags: grafana
|
|
|
|
|
2022-04-05 07:04:29 +00:00
|
|
|
- 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
|
|
|
|
|
2019-04-11 17:20:56 +00:00
|
|
|
- name: copy configuration file
|
2021-08-21 21:15:13 +00:00
|
|
|
ansible.builtin.template:
|
2019-04-11 17:20:56 +00:00
|
|
|
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
|
2021-08-21 21:15:13 +00:00
|
|
|
ansible.builtin.template:
|
2019-04-11 17:20:56 +00:00
|
|
|
src: ldap.toml.j2
|
|
|
|
dest: /etc/grafana/ldap.toml
|
|
|
|
owner: root
|
|
|
|
group: grafana
|
|
|
|
mode: 0640
|
|
|
|
notify: restart grafana
|
|
|
|
tags: grafana
|
|
|
|
|
2021-08-21 21:21:52 +00:00
|
|
|
- name: install official plugins
|
|
|
|
community.grafana.grafana_plugin:
|
2019-04-11 17:20:56 +00:00
|
|
|
name: '{{ item.name }}'
|
|
|
|
version: '{{ item.version|default("latest") }}'
|
|
|
|
state: '{{ item.state|default("present") }}'
|
2021-08-21 21:21:52 +00:00
|
|
|
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 }}'
|
2019-04-11 17:20:56 +00:00
|
|
|
notify: restart grafana
|
|
|
|
tags: grafana
|
|
|
|
|
|
|
|
- name: enable and start service
|
2021-08-21 21:15:13 +00:00
|
|
|
ansible.builtin.service:
|
2019-04-11 17:20:56 +00:00
|
|
|
name: grafana-server
|
|
|
|
state: started
|
2021-08-21 21:15:13 +00:00
|
|
|
enabled: true
|
2019-04-11 17:20:56 +00:00
|
|
|
tags: grafana
|