aboutsummaryrefslogtreecommitdiff
path: root/roles/services/monitoring/grafana/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'roles/services/monitoring/grafana/tasks')
-rw-r--r--roles/services/monitoring/grafana/tasks/main.yml125
1 files changed, 125 insertions, 0 deletions
diff --git a/roles/services/monitoring/grafana/tasks/main.yml b/roles/services/monitoring/grafana/tasks/main.yml
new file mode 100644
index 0000000..e9f824e
--- /dev/null
+++ b/roles/services/monitoring/grafana/tasks/main.yml
@@ -0,0 +1,125 @@
1- name: install extrepo
2 package:
3 name: extrepo
4 state: latest
5
6- name: add Grafana repo
7 register: result
8 changed_when: result.stdout | regex_search("skipped") | bool
9 notify: update repos
10 command:
11 cmd: extrepo enable grafana
12 creates: /etc/apt/sources.list.d/extrepo_grafana.sources
13
14- meta: flush_handlers
15
16- name: update Grafana repo
17 changed_when: false
18 command:
19 cmd: extrepo update grafana
20
21- name: install grafana
22 package:
23 name: "{{ grafana_package }}"
24
25- name: deploy grafana config
26 notify: restart grafana
27 template:
28 src: "{{ grafana_config }}"
29 dest: /etc/grafana/grafana.ini
30 owner: root
31 group: grafana
32 mode: '0640'
33
34- name: deploy nginx configuration
35 notify: restart nginx
36 copy:
37 src: "{{ grafana_nginx_config }}"
38 dest: /etc/nginx/sites-available/grafana.conf
39 owner: root
40 group: root
41 mode: '0644'
42
43- name: symlink site
44 notify: restart nginx
45 file:
46 src: /etc/nginx/sites-available/grafana.conf
47 dest: /etc/nginx/sites-enabled/grafana.conf
48 owner: root
49 group: root
50 state: link
51
52- name: allow http (80/tcp) traffic
53 ufw:
54 rule: allow
55 port: '80'
56 proto: tcp
57
58- name: allow https (443/tcp) traffic
59 ufw:
60 rule: allow
61 port: '443'
62 proto: tcp
63
64- name: enable grafana
65 systemd:
66 daemon_reload: yes
67 enabled: yes
68 masked: no
69 name: grafana-server
70
71- meta: flush_handlers
72
73- name: add grafana user
74 ignore_errors: yes
75 community.grafana.grafana_user:
76 name: "{{ grafana_admin }}"
77 email: "{{ grafana_email }}"
78 url: "{{ grafana_url }}"
79 login: "{{ grafana_admin }}"
80 password: "{{ grafana_password }}"
81 is_admin: true
82 state: present
83
84- name: add prometheus datasource
85 community.grafana.grafana_datasource:
86 grafana_url: "{{ grafana_url }}"
87 grafana_user: "{{ grafana_admin }}"
88 grafana_password: "{{ grafana_password }}"
89 name: "Prometheus"
90 ds_type: prometheus
91 ds_url: "{{ prometheus_url }}"
92 access: proxy
93
94- name: add influxdb datasource
95 community.grafana.grafana_datasource:
96 grafana_url: "{{ grafana_url }}"
97 grafana_user: "{{ grafana_admin }}"
98 grafana_password: "{{ grafana_password }}"
99 name: "Proxmox InfluxDB"
100 ds_type: influxdb
101 ds_url: "{{ influxdb_url }}"
102 database: "{{ influx_database }}"
103 user: "{{ influx_user }}"
104 password: "{{ influx_password }}"
105 access: proxy
106
107- name: add loki datasource
108 community.grafana.grafana_datasource:
109 grafana_url: "{{ grafana_url }}"
110 grafana_user: "{{ grafana_admin }}"
111 grafana_password: "{{ grafana_password }}"
112 name: "Loki"
113 ds_type: loki
114 ds_url: "{{ loki_url }}"
115 access: proxy
116
117- name: import main custom dashboard
118 delegate_to: localhost
119 become: no
120 community.grafana.grafana_dashboard:
121 grafana_url: "{{ grafana_url }}"
122 grafana_user: "{{ grafana_admin }}"
123 grafana_password: "{{ grafana_password }}"
124 path: "{{ grafana_dashboard_main }}"
125 overwrite: yes