Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The WFLuxor blue network has DNS now #131

Draft
wants to merge 16 commits into
base: wfluxor
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion domlogo/domlogo.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,29 @@
import platform
import shlex
import yaml
from PIL import Image, ImageDraw, ImageFont


def generate_placeholder(text: str, path: str, background_color, width: int, height: int):
image = Image.new("RGB", (width, height), background_color)
draw = ImageDraw.Draw(image)
font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 72)
text_bbox = draw.textbbox((0, 0), text, font=font)
text_width = text_bbox[2] - text_bbox[0]
text_height = text_bbox[3] - text_bbox[1]
text_x = (width - text_width) / 2
text_y = (height - text_height) / 2
draw.text((text_x, text_y), text, fill=(255,255,255), font=font)

# Add some hint how to replace the image.
small_font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 16)
placeholder_text = f'(Replace this placeholder image at {path})'
text_bbox = draw.textbbox((0, 0), placeholder_text, font=small_font)
text_width = text_bbox[2] - text_bbox[0]
text_x = (width - text_width) / 2
text_y = text_y + 1.4*text_height
draw.text((text_x, text_y), placeholder_text, fill=(195,196,199), font=small_font)
image.save(path)


def download_image(image_type: str, entity_id: str, file: dict):
Expand All @@ -26,6 +49,7 @@ def download_image(image_type: str, entity_id: str, file: dict):

if existing_etag != etag:
print(f'Downloading and converting {image_type} for entity with ID {entity_id}...')
os.makedirs(os.path.dirname(temp_file), exist_ok=True)
with open(temp_file, 'wb') as f:
f.write(requests.get(f'{api_url}/{href}', auth=(user, passwd)).content)

Expand All @@ -39,6 +63,11 @@ def download_image(image_type: str, entity_id: str, file: dict):
host = platform.node()
host_bg_color = 'black'

idle_image = 'domlogo-files/photos/idle.png'
if not os.path.isfile(idle_image):
os.makedirs(os.path.dirname(idle_image), exist_ok=True)
generate_placeholder('judgehost idle', idle_image, (10,75,120), 1024, 768)

config_file = 'domlogo-files/config.yaml'
if os.path.isfile(config_file) and os.access(config_file, os.R_OK):
with open(config_file, 'r') as f:
Expand Down Expand Up @@ -172,7 +201,7 @@ def download_image(image_type: str, entity_id: str, file: dict):
last_seen = (submission_id, judging_id, team_id)
new_filename = f'domlogo-files/photos/{team_id}.png'
if not os.path.isfile(new_filename):
new_filename = f'domlogo-files/photos/crew.png'
generate_placeholder(f'team {team_id}', new_filename, (137,28,28), 1024, 768)
team_image.update(filename=new_filename)
metadata_text.update(f's{submission_id} / {submission_data["problem_id"]} / {submission_data["language_id"]}')
results_text.update('Busy compiling.')
Expand Down
15 changes: 12 additions & 3 deletions provision-contest/ansible/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ LIBVENDORTGZ=roles/domjudge_checkout/files/lib-vendor.tgz
SSHKEY=roles/ssh/files/id_ed25519
SSL_DOMSERVER=roles/ssl/files/domserver
SSL_DOMSERVER_FILES=$(addprefix $(SSL_DOMSERVER),.key .crt)
SSL_NODEEXPORT=roles/prometheus_target_all/files/node_exporter
SSL_NODEEXPORT_FILES=$(addprefix $(SSL_NODEEXPORT),.key .crt)
SSL_LOCALHOST=roles/ssl/files/localhost
SSL_LOCALHOST_FILES=$(addprefix $(SSL_LOCALHOST),.key .crt)
SSL_CDS=roles/ssl/files/cds
Expand Down Expand Up @@ -57,9 +59,12 @@ ansible-master:
done

admin: $(SSL_LOCALHOST_FILES)
grafana: $(SSL_GRAFANA_FILES)
domserver: $(SSL_DOMSERVER_FILES)
cds: $(SSL_CDS_FILES)
grafana: $(SSL_GRAFANA_FILES) $(SSL_NODEEXPORT)
domserver: $(SSL_DOMSERVER_FILES) $(SSL_NODEEXPORT)
judgehost: $(SSL_NODEEXPORT)
cds: $(SSL_CDS_FILES) $(SSL_NODEEXPORT)
scoreboard: $(SSL_NODEEXPORT)
mgmt: $(SSL_NODEEXPORT)

$(SSHKEY) $(SSHKEY).pub:
ssh-keygen -t ed25519 -f $(SSHKEY) -P ''
Expand All @@ -68,6 +73,9 @@ $(SSL_DOMSERVER_FILES):
openssl req -x509 -nodes -newkey rsa:4096 -subj "/O=DOMjudge/CN=domjudge" \
-addext "subjectAltName = DNS:wf46-domjudge,DNS:wf47-domjudge,DNS:analyst" \
-sha256 -days 365 -keyout $(SSL_DOMSERVER).key -out $(SSL_DOMSERVER).crt
$(SSL_NODEEXPORT_FILES):
openssl req -x509 -nodes -newkey rsa:4096 -subj "/O=DOMjudge/CN=metricexporter" \
-sha256 -days 365 -keyout $(SSL_NODEEXPORT).key -out $(SSL_NODEEXPORT).crt
$(SSL_LOCALHOST_FILES):
openssl req -x509 -nodes -newkey rsa:4096 -subj "/O=DOMjudge/CN=localhost" \
-sha256 -days 365 -keyout $(SSL_LOCALHOST).key -out $(SSL_LOCALHOST).crt
Expand All @@ -84,6 +92,7 @@ clean:
distclean: clean
rm -f $(SSHKEY) $(SSHKEY).pub
rm -f $(SSL_DOMSERVER_FILES)
rm -f $(SSL_NODEEXPORT)
rm -f $(SSL_LOCALHOST_FILES)
rm -f $(SSL_CDS_FILES)
rm -f $(SSL_GRAFANA_FILES)
Expand Down
2 changes: 2 additions & 0 deletions provision-contest/ansible/group_vars/admin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ PHP_FPM_MAX_CHILDREN: 5

DOMSERVER_SSL_CERT: /etc/ssl/certs/localhost.crt
DOMSERVER_SSL_KEY: /etc/ssl/private/localhost.key

DB_DUMP_PREFIX: admin
28 changes: 14 additions & 14 deletions provision-contest/ansible/group_vars/all/all.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
DJ_DIR: /opt/domjudge

# Branch to checkout and use.
DJ_BRANCH: main
DJ_BRANCH: wfluxor

# Whether to force-pull changes to the checkout, overwriting any local changes.
DJ_FORCE_UPDATE: true
Expand All @@ -16,25 +16,25 @@ LOCAL_GIT_IP: "{{SERVER_IP_PREFIX}}.207"
# URL and IP of domserver from judgehosts. A hostname 'domserver' with
# DOMSERVER_IP will be added to the judgehost /etc/hosts file.
DOMSERVER: https://domjudge
DOMSERVER_IP: "{{SERVER_IP_PREFIX}}.215"
DOMSERVER_URL: "{{DOMSERVER}}"
DOMSERVER_URL: "{{ DOMSERVER }}"
DOMSERVER_SSL_CERT: /etc/ssl/certs/domserver.crt
DOMSERVER_SSL_KEY: /etc/ssl/private/domserver.key

# Set this to true when you are using the ICPC World Finals Contest Image
ICPC_IMAGE: false
ICPC_IMAGE: true

# Set this to true when you are using a graphical desktop
GRAPHICAL: false
GRAPHICAL: true

# Set this to true when you use an (ICPC) AWS machine
AWS: true

# Set this when on the blue network at the World Finals where no
# internet access is available and "packages" must be used as APT repo
# server.
WF_RESTRICTED_NETWORK: false
WF_RESTRICTED_NETWORK: true
WF_GREEN: false
HOSTS_DNS: false

# Static IP address configuration. Uses the ansible_host variable as the static
# IP address. Only configured if STATIC_IP_ENABLED is true.
Expand All @@ -55,7 +55,7 @@ HOSTS:
domjudge-laptop: 10.3.3.200
pc2: 10.3.3.241

TIMEZONE: "Europe/Amsterdam"
TIMEZONE: "Africa/Cairo"

PHP_FPM_MAX_CHILDREN: 400
PHP_FPM_MAX_REQUESTS: 500
Expand All @@ -65,17 +65,17 @@ PHP_POST_MAX_SIZE: 256M
PHP_MAX_FILE_UPLOADS: 101

# Git repo URL
DJ_GIT_HOST: "{{LOCAL_GIT_IP}}"
DJ_GIT_HOST: "{{ LOCAL_GIT_IP }}"
DJ_GIT_REPO: "https://github.com/domjudge/domjudge.git"
DJ_GIT_REPO_RESTRICTED: "domjudge@{{DJ_GIT_HOST}}:domjudge"
DJ_GIT_REPO_RESTRICTED: "domjudge@{{ DJ_GIT_HOST }}:domjudge"
DJ_GIT_REPO_SCRIPTS: "https://github.com/domjudge/domjudge-scripts.git"
DJ_GIT_REPO_SCRIPTS_RESTRICTED: "domjudge@{{DJ_GIT_HOST}}:domjudge-scripts-bare"
CONTEST_REPO: "wf2021"
DJ_GIT_REPO_SCRIPTS_RESTRICTED: "domjudge@{{ DJ_GIT_HOST }}:domjudge-scripts-bare"
CONTEST_REPO: "wfluxor"

PHPSTORM_VERSION: 2022.2
PHPSTORM_FULL_VERSION: 222.4345.15
PHPSTORM_VERSION: 2024.1
PHPSTORM_FULL_VERSION: 241.14494.237

GRAFANA_MONITORING: false
GRAFANA_MONITORING: true

# Hostname of the CDS. If set, will add an nginx in front of the CDS
# If not set, will only expose CDS directly
Expand Down
47 changes: 0 additions & 47 deletions provision-contest/ansible/group_vars/all/secret.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
# Adding `strong` in the template will create longer passwords and is used for the
# passwords which almost never need to be manually typed.

# Password for the MySQL replication user.
# Set this to enable master-master replication between two domservers.
#REPLICATION_PASSWORD: {some-strong-replication-password}

# Database user password.
DB_PASSWORD: {some-strong-database-password}

Expand All @@ -24,48 +20,5 @@ ADMIN_PASSWORD: {some-admin-password}
# created on the domserver and judgehosts.
#DJ_SHELL_USER_PW: {some-hashed-password}

# Accounts to create when setting up the CDS
CDS_ACCOUNTS:
- username: admin
password: {some-adm1n-password}
type: admin
- username: presAdmin
password: {some-presentation-adm1n-password}
type: admin
- username: presentation
password: {some-public-presentation-password}
type: public
#- username: blue
# password: blu3
# type: staff
#- username: balloon
# password: balloonPr1nter
# type: balloon
#- username: public
# password: publ1c
# type: public
#- username: myicpc
# password: my1cpc
# type: spectator
#- username: live
# password: l1ve
# type: analyst
#- username: team1
# password: t3am
# type: team
# team_id: 1

# Contest(s) to configure in the CDS
CDS_CONTESTS:
- path: nwerc18 # Path in the contest directory
ccs:
id: nwerc18 # ID of the contest if hosted at DOMJUDGE_URL
# Or provide a absolute URL
# url: https://www.domjudge.org/demoweb/api/contests/nwerc18
username: admin
password: admin

PRESCLIENT_CONTEST: nwerc18

# Sentry DSN URL
# SENTRY_DSN:
1 change: 1 addition & 0 deletions provision-contest/ansible/group_vars/analyst-domserver
1 change: 1 addition & 0 deletions provision-contest/ansible/group_vars/analyst-judgehost
2 changes: 2 additions & 0 deletions provision-contest/ansible/group_vars/analyst/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/secret.yml
/all.yml
15 changes: 15 additions & 0 deletions provision-contest/ansible/group_vars/analyst/all.yml.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Server VLAN IP prefix.
SERVER_IP_PREFIX: 172.29.1

# URL and IP of domserver from judgehosts. A hostname 'domserver' with
# DOMSERVER_IP will be added to the judgehost /etc/hosts file.
DOMSERVER: https://domjudge
DOMSERVER_IP: "{{SERVER_IP_PREFIX}}.240"

# Set this when on the blue network at the World Finals where no
# internet access is available and "packages" must be used as APT repo
# server.
WF_GREEN: true
HOSTS_DNS: true

DB_DUMP_PREFIX: analyst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DB_PASSWORD: {some-strong-database-password-analyst}
JUDGEHOST_PASSWORD: {some-strong-judgehost-password-analyst}
1 change: 1 addition & 0 deletions provision-contest/ansible/group_vars/online-domserver
1 change: 1 addition & 0 deletions provision-contest/ansible/group_vars/online-judgehost
2 changes: 2 additions & 0 deletions provision-contest/ansible/group_vars/online/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/secret.yml
/all.yml
95 changes: 95 additions & 0 deletions provision-contest/ansible/group_vars/online/all.yml.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Directory of the domjudge repository checkout.
DJ_DIR: /opt/domjudge

# Branch to checkout and use.
DJ_BRANCH: wfonline

# Whether to force-pull changes to the checkout, overwriting any local changes.
DJ_FORCE_UPDATE: true

# Server VLAN IP prefix.
SERVER_IP_PREFIX: 10.3.3

# IP address of the git server.
LOCAL_GIT_IP: "{{SERVER_IP_PREFIX}}.207"

# URL and IP of domserver from judgehosts. A hostname 'domserver' with
# DOMSERVER_IP will be added to the judgehost /etc/hosts file.
DOMSERVER: https://domjudge
DOMSERVER_URL: "{{ DOMSERVER }}"
DOMSERVER_SSL_CERT: /etc/ssl/certs/domserver.crt
DOMSERVER_SSL_KEY: /etc/ssl/private/domserver.key

# Set this to true when you are using the ICPC World Finals Contest Image
ICPC_IMAGE: false

# Set this to true when you are using a graphical desktop
GRAPHICAL: false

# Set this when on the blue network at the World Finals where no
# internet access is available and "packages" must be used as APT repo
# server.
WF_RESTRICTED_NETWORK: false
WF_GREEN: false

# Static IP address configuration. Uses the ansible_host variable as the static
# IP address. Only configured if STATIC_IP_ENABLED is true.
STATIC_IP_ENABLED: false
STATIC_IP_NETMASK: 255.255.252.0
STATIC_IP_GATEWAY: 172.29.0.1
STATIC_IP_INTERFACE: enp1s0

# Additional entries for the /etc/hosts file.
HOSTS:
cds: 10.3.3.207
packages: 10.3.3.209
ntp1: 10.3.3.208
ntp2: 10.3.3.209
nisprint: 10.3.3.211
nismaster: 10.3.3.211
printsrv: 10.3.3.211
domjudge-laptop: 10.3.3.200
pc2: 10.3.3.241

TIMEZONE: "Asia/Dhaka"

PHP_FPM_MAX_CHILDREN: 400
PHP_FPM_MAX_REQUESTS: 500
PHP_MEMORY_LIMIT: 1024M
PHP_UPLOAD_MAX_FILESIZE: 256M
PHP_POST_MAX_SIZE: 256M
PHP_MAX_FILE_UPLOADS: 101

# Git repo URL
DJ_GIT_HOST: "{{ LOCAL_GIT_IP }}"
DJ_GIT_REPO: "https://github.com/domjudge/domjudge.git"
DJ_GIT_REPO_RESTRICTED: "domjudge@{{ DJ_GIT_HOST }}:domjudge"
DJ_GIT_REPO_SCRIPTS: "https://github.com/domjudge/domjudge-scripts.git"
DJ_GIT_REPO_SCRIPTS_RESTRICTED: "domjudge@{{ DJ_GIT_HOST }}:domjudge-scripts-bare"
CONTEST_REPO: "wfluxor"

PHPSTORM_VERSION: 2022.2
PHPSTORM_FULL_VERSION: 222.4345.15

GRAFANA_MONITORING: true

# Hostname of the CDS. If set, will add an nginx in front of the CDS
# If not set, will only expose CDS directly
CDS_HOSTNAME: cds
CDS_PORT: 80
CDS_PORT_SECURE: 443

# CDS SSL cert and key. Only needed when CDS_HOSTNAME is set
CDS_SSL_CERT: /etc/ssl/certs/cds.crt
CDS_SSL_KEY: /etc/ssl/private/cds.key

# Hostname of the static scoreboard
STATIC_SCOREBOARD_HOSTNAME: scoreboard

STATIC_SCOREBOARD_SSL_CERT: /etc/ssl/certs/scoreboard.crt
STATIC_SCOREBOARD_SSL_KEY: /etc/ssl/private/scoreboard.key

# Block access to the CDS for IPs other than these
#CDS_IP_FILTER:
# - 127.0.0.1-127.0.0.1
# - 192.168.0.0-192.168.255.255
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
DB_PASSWORD: {some-strong-database-password-online}

# Credentials for the judgehost.
JUDGEHOST_USER: judgehost
JUDGEHOST_PASSWORD: {some-strong-judgehost-password-online}

# Username and password to be used in .netrc files on admin machines
ADMIN_USER: admin
ADMIN_PASSWORD: {some-admin-password-online}
1 change: 1 addition & 0 deletions provision-contest/ansible/group_vars/wf46-domserver
1 change: 1 addition & 0 deletions provision-contest/ansible/group_vars/wf46-judgehost
2 changes: 2 additions & 0 deletions provision-contest/ansible/group_vars/wf46/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/secret.yml
/all.yml
Loading
Loading