Skip to content

Commit fa3b55b

Browse files
nickygerritsenvmcj
authored andcommitted
Add Ansible role for setting up static scoreboard.
1 parent f156348 commit fa3b55b

File tree

8 files changed

+191
-3
lines changed

8 files changed

+191
-3
lines changed

icpc-wf/ansible/Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ default:
66
@echo " - make admin"
77
@echo " - make grafana"
88
@echo " - make cds"
9+
@echo " - make scoreboard"
910

1011
LIBVENDORTGZ=roles/domjudge_checkout/files/lib-vendor.tgz
1112
SSHKEY=roles/ssh/files/id_rsa
@@ -22,7 +23,7 @@ $(LIBVENDOR): $(LIBVENDORTGZ)
2223
-cd roles/domjudge_checkout/files && tar xzf $(notdir $<)
2324
endif
2425

25-
domserver judgehost admin grafana cds: %: %.yml hosts group_vars/all/secret.yml $(LIBVENDOR) $(SSHKEY) $(SSHKEY).pub
26+
domserver judgehost admin grafana cds scoreboard: %: %.yml hosts group_vars/all/secret.yml $(LIBVENDOR) $(SSHKEY) $(SSHKEY).pub
2627
ansible-playbook -i hosts $<
2728

2829
admin: $(SSL_LOCALHOST_FILES)
@@ -46,4 +47,4 @@ distclean: clean
4647
rm -f $(SSL_LOCALHOST_FILES)
4748
rm -f $(SSL_GRAFANA_FILES)
4849

49-
.PHONY: default clean distclean domserver judgehost admin grafana cds
50+
.PHONY: default clean distclean domserver judgehost admin grafana cds scoreboard

icpc-wf/ansible/group_vars/all/all.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,9 @@ CDS_HOSTNAME: cds
5454
# CDS SSL cert and key. Only needed when CDS_HOSTNAME is set
5555
CDS_SSL_CERT: /etc/ssl/certs/cds.crt
5656
CDS_SSL_KEY: /etc/ssl/private/cds.key
57+
58+
# Hostname of the static scoreboard
59+
STATIC_SCOREBOARD_HOSTNAME: scoreboard
60+
61+
STATIC_SCOREBOARD_SSL_CERT: /etc/ssl/certs/scoreboard.crt
62+
STATIC_SCOREBOARD_SSL_KEY: /etc/ssl/private/scoreboard.key

icpc-wf/ansible/hosts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,7 @@ domjudge-ccsadmin5 ansible_host=10.3.3.227
3737
domjudge-prometheus ansible_host=10.3.3.223
3838

3939
[cds]
40-
domjudge-cds ansible_host=10.2.2.228
40+
domjudge-cds ansible_host=10.2.2.228
41+
42+
[scoreboard]
43+
domjudge-scoreboard ansible_host=10.2.2.229
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
# Define here handlers associated to this role.
3+
4+
- name: restart nginx
5+
service: name=nginx enabled=yes state=restarted
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
---
2+
# These tasks configure a static scoreboard
3+
4+
- name: create directories for styling, scripts, fonts and flags
5+
file:
6+
path: /home/domjudge/scoreboard/{{ item }}
7+
state: directory
8+
owner: domjudge
9+
group: domjudge
10+
mode: 0755
11+
loop:
12+
- css
13+
- js
14+
- webfonts
15+
- flags
16+
17+
- name: download required assets
18+
get_url:
19+
url: "{{ DOMSERVER_URL }}/{{ item }}"
20+
dest: /home/domjudge/scoreboard/{{ item }}
21+
owner: domjudge
22+
group: domjudge
23+
mode: 0644
24+
loop:
25+
- favicon.ico
26+
- css/bootstrap.min.css
27+
- css/fontawesome-all.min.css
28+
- js/jquery.min.js
29+
- js/bootstrap.bundle.min.js
30+
- js/domjudge.js
31+
- style_domjudge.css
32+
- webfonts/fa-brands-400.ttf
33+
- webfonts/fa-brands-400.woff2
34+
- webfonts/fa-regular-400.ttf
35+
- webfonts/fa-regular-400.woff2
36+
- webfonts/fa-solid-900.ttf
37+
- webfonts/fa-solid-900.woff2
38+
- webfonts/fa-v4compatibility.ttf
39+
- webfonts/fa-v4compatibility.woff2
40+
41+
- name: install contest images
42+
synchronize:
43+
src: files/domjudge-public/
44+
dest: "/home/domjudge/scoreboard/"
45+
owner: no
46+
use_ssh_args: true
47+
become: yes
48+
become_user: domjudge
49+
50+
- name: download and unpack flag icons package
51+
unarchive:
52+
src: https://github.com/lipis/flag-icons/archive/refs/tags/3.5.0.zip
53+
dest: /tmp
54+
remote_src: true
55+
owner: domjudge
56+
group: domjudge
57+
58+
- name: copy flag icon SVG's
59+
copy:
60+
src: /tmp/flag-icons-3.5.0/flags/
61+
dest: /home/domjudge/scoreboard/flags/
62+
remote_src: true
63+
owner: domjudge
64+
group: domjudge
65+
66+
- name: create bin directory
67+
file:
68+
path: /home/domjudge/bin
69+
state: directory
70+
owner: domjudge
71+
group: domjudge
72+
mode: 0755
73+
74+
- name: install update scoreboard script
75+
template:
76+
src: update-scoreboard.sh.j2
77+
dest: "/home/domjudge/bin/update-scoreboard.sh"
78+
owner: domjudge
79+
group: domjudge
80+
mode: 0755
81+
82+
# Ansible cron task defaults to * for all cron parts
83+
- name: set up cron to update scoreboard
84+
cron:
85+
name: update public scoreboard
86+
job: /home/domjudge/bin/update-scoreboard.sh
87+
user: domjudge
88+
89+
- name: install nginx
90+
apt:
91+
state: present
92+
pkg:
93+
- nginx
94+
95+
- name: add scoreboard nginx conf
96+
template:
97+
src: scoreboard.conf.j2
98+
dest: /etc/nginx/sites-available/scoreboard.conf
99+
notify: restart nginx
100+
101+
- name: enable nginx conf for static scoreboard
102+
file:
103+
src: /etc/nginx/sites-available/scoreboard.conf
104+
dest: /etc/nginx/sites-enabled/scoreboard.conf
105+
state: link
106+
notify: restart nginx
107+
108+
- name: disable default nginx site
109+
file:
110+
path: /etc/nginx/sites-enabled/default
111+
state: absent
112+
notify: restart nginx
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# nginx configuration for the static scoreboard
2+
server {
3+
listen 80;
4+
listen [::]:80;
5+
6+
server_name {{STATIC_SCOREBOARD_HOSTNAME}};
7+
8+
return 301 https://$host$request_uri;
9+
}
10+
11+
server {
12+
listen 443 ssl http2;
13+
listen [::]:443 ssl http2;
14+
15+
server_name {{STATIC_SCOREBOARD_HOSTNAME}};
16+
17+
ssl_certificate {{STATIC_SCOREBOARD_SSL_CERT}};
18+
ssl_certificate_key {{STATIC_SCOREBOARD_SSL_KEY}};
19+
ssl_session_timeout 5m;
20+
ssl_prefer_server_ciphers on;
21+
22+
add_header Strict-Transport-Security max-age=31556952;
23+
24+
root /home/domjudge/scoreboard;
25+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
3+
for _ in $(seq 1 6)
4+
do
5+
wget -O /tmp/scoreboard-tmp.html '{{DOMSERVER_URL}}/public?static=1'
6+
mv /tmp/scoreboard-tmp.html /home/domjudge/scoreboard/index.html
7+
sleep 10
8+
done

icpc-wf/ansible/scoreboard.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
# This playbook installs the static scoreboard
3+
4+
- name: setup static scoreboard
5+
hosts: scoreboard
6+
vars:
7+
host_type: scoreboard
8+
become: yes
9+
roles:
10+
- role: base_packages
11+
tags: base_packages
12+
- role: icpc_fixes
13+
tags: icpc_fixes
14+
when: ICPC_IMAGE
15+
- role: system_fixes
16+
tags: system_fixes
17+
- role: hosts
18+
tags: hosts
19+
- role: ssl
20+
tags: ssl
21+
vars:
22+
INSTALL_SSL_PRIVATE_KEYS: true
23+
- role: domjudge_user
24+
tags: domjudge_user
25+
- role: ssh
26+
tags: ssh
27+
- role: scoreboard
28+
tags: scoreboard

0 commit comments

Comments
 (0)