Skip to content

Commit 054ecfb

Browse files
committed
Re-implement the grafana server
1 parent 611a8f6 commit 054ecfb

File tree

16 files changed

+23367
-129
lines changed

16 files changed

+23367
-129
lines changed

icpc-wf/ansible/Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ LIBVENDORTGZ=roles/domjudge_checkout/files/lib-vendor.tgz
1010
SSHKEY=roles/ssh/files/id_rsa
1111
SSL_LOCALHOST=roles/ssl/files/localhost
1212
SSL_LOCALHOST_FILES=$(addprefix $(SSL_LOCALHOST),.key .crt)
13+
SSL_GRAFANA=roles/grafana/files/ssl
14+
SSL_GRAFANA_FILES=$(addprefix $(SSL_GRAFANA),.key .crt)
1315

1416
ifeq ($(wildcard $(LIBVENDORTGZ)),)
1517
LIBVENDOR=
@@ -23,19 +25,24 @@ domserver judgehost admin grafana: %: %.yml hosts group_vars/all/secret.yml $(LI
2325
ansible-playbook -i hosts $<
2426

2527
admin: $(SSL_LOCALHOST_FILES)
28+
grafana: $(SSL_GRAFANA_FILES)
2629

2730
$(SSHKEY) $(SSHKEY).pub:
2831
ssh-keygen -t rsa -f $(SSHKEY) -P ''
2932

3033
$(SSL_LOCALHOST_FILES):
3134
openssl req -x509 -nodes -newkey rsa:4096 -subj "/O=DOMjudge/CN=localhost" \
3235
-sha256 -days 365 -keyout $(SSL_LOCALHOST).key -out $(SSL_LOCALHOST).crt
36+
$(SSL_GRAFANA_FILES):
37+
openssl req -x509 -nodes -newkey rsa:4096 -subj "/O=DOMjudge/CN=grafana" \
38+
-sha256 -days 365 -keyout $(SSL_GRAFANA).key -out $(SSL_GRAFANA).crt
3339

3440
clean:
3541
rm -rf $(LIBVENDOR)
3642

3743
distclean: clean
3844
rm -f $(SSHKEY) $(SSHKEY).pub
3945
rm -f $(SSL_LOCALHOST_FILES)
46+
rm -f $(SSL_GRAFANA_FILES)
4047

4148
.PHONY: default clean distclean domserver judgehost admin grafana

icpc-wf/ansible/grafana.yml

Lines changed: 12 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -4,76 +4,18 @@
44
vars:
55
host_type: grafana
66
become: yes
7-
tasks:
7+
roles:
8+
- role: base_packages
9+
tags: base_packages
10+
- role: icpc_fixes
11+
tags: icpc_fixes
12+
when: ICPC_IMAGE
13+
- role: system_fixes
14+
tags: system_fixes
15+
- role: hosts
16+
tags: hosts
817
- role: prometheus_target_all
918
tags: prometheus_target_all
1019
when: GRAFANA_MONITORING
11-
- name: include global variables
12-
include_vars: variables.yml
13-
- name: include global (secret) variables
14-
include_vars: variables-secret.yml
15-
16-
- name: install local DEB packages
17-
include: install-local-package.yml
18-
with_fileglob:
19-
- files/install-grafana/*.deb
20-
21-
- name: install dependencies
22-
apt:
23-
state: present
24-
install_recommends: no
25-
pkg:
26-
- nginx
27-
# We need these for our extra monitoring things
28-
- prometheus
29-
30-
- name: copy ssl cert
31-
copy: src=files/grafana/grafana.crt dest=/etc/ssl/certs/grafana.crt
32-
- name: copy ssl key
33-
copy: src=files/grafana/grafana.key dest=/etc/ssl/private/grafana.key
34-
35-
- name: copy default nginx config
36-
copy: src=files/grafana/nginx.conf dest=/etc/nginx/sites-enabled/grafana.conf
37-
38-
- name: restart nginx
39-
service: name=nginx state=restarted
40-
41-
- name: configure grafana
42-
copy:
43-
src: files/grafana/environment
44-
dest: /etc/default/grafana-server
45-
46-
- name: set up grafana dashboards
47-
copy:
48-
src: files/grafana/dashboards.yml
49-
dest: /etc/grafana/provisioning/dashboards/default.yml
50-
51-
- name: set up grafana datasources
52-
copy:
53-
src: files/grafana/datasources.yml
54-
dest: /etc/grafana/provisioning/datasources/default.yml
55-
56-
- name: set up prometheus scrapes
57-
template:
58-
src: files/grafana/prometheus.yml.j2
59-
dest: /etc/prometheus/prometheus.yml
60-
61-
- name: create dashboard directory
62-
file: path=/etc/grafana/dashboards state=directory
63-
64-
- name: restart prometheus
65-
service: name=prometheus state=restarted
66-
67-
- name: restart grafana
68-
service: name=grafana-server state=restarted
69-
70-
- name: copy grafana dashboards
71-
copy:
72-
src: files/grafana/dashboards/
73-
dest: /etc/grafana/dashboards/
74-
75-
- name: Start/enable our services
76-
service: name={{ item }} state=started enabled=yes
77-
with_items:
78-
- grafana-server.service
79-
- prometheus.service
20+
- role: grafana
21+
tags: grafana
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
Any `*.deb` package files placed here will be installed on the grafana host.
2+
3+
The grafana server package should be downloaded from grafana.com (https://grafana.com/grafana/download?pg=get&plcmt=selfmanaged-box1-cta1)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/ssl.*
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
- name: 'default' # name of this dashboard configuration (not dashboard itself)
2+
org_id: 1 # id of the org to hold the dashboard
3+
folder: '' # name of the folder to put the dashboard (http://docs.grafana.org/v5.0/reference/dashboard_folders/)
4+
type: 'file' # type of dashboard description (json files)
5+
options:
6+
folder: '/etc/grafana/dashboards' # where dashboards are

0 commit comments

Comments
 (0)