Skip to content

Commit a1e191b

Browse files
Make Ansible work with recent ICPC images, i.e. Ubuntu 24.04 based ones
1 parent 4e7bcc8 commit a1e191b

File tree

9 files changed

+131
-10
lines changed

9 files changed

+131
-10
lines changed

provision-contest/ansible/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ $(VENDOR): $(VENDORTGZ)
3333
endif
3434

3535
ROLES=domserver judgehost admin grafana cds presclient presadmin scoreboard mgmt autoanalyst
36-
$(ROLES): %: %.yml hosts group_vars/all/secret.yml $(VENDOR) $(SSHKEY) $(SSHKEY).pub
36+
$(ROLES): %: %.yml hosts group_vars/onprem/secret.yml $(VENDOR) $(SSHKEY) $(SSHKEY).pub
3737
ansible-playbook -i hosts $<
3838

3939
FAILED_ROLES=$(addprefix failed-,$(ROLES))

provision-contest/ansible/domserver.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121
group: domjudge
122122
mode: 0755
123123
loop:
124-
- htop
124+
- btop
125125
- taillog-domserver-nginx-error
126126
when: GRAPHICAL
127127

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[Desktop Entry]
22
Name=htop
33
Type=Application
4-
Exec=gnome-terminal --window --geometry 150x18+0+0 -e 'bash -c "sudo htop"'
4+
Exec=gnome-terminal --window --geometry 150x18+0+0 -e 'bash -c "sudo btop"'

provision-contest/ansible/roles/base_packages/defaults/main.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ REMOVED_PACKAGES:
33
- ntp
44

55
INSTALLED_PACKAGES:
6+
- yarnpkg
67
- ack
78
- acl
89
- apache2-utils
@@ -24,6 +25,7 @@ INSTALLED_PACKAGES:
2425
- git-gui
2526
- gitk
2627
- htop
28+
- btop
2729
- httpie
2830
- jq
2931
- latexmk
@@ -53,3 +55,9 @@ INSTALLED_PACKAGES:
5355
- tree
5456
- unzip
5557
- zip
58+
59+
GRAPHICAL_INSTALLED_PACKAGES:
60+
- dconf-cli
61+
- python3-psutil
62+
- gnome-terminal
63+
- fonts-noto-color-emoji

provision-contest/ansible/roles/base_packages/tasks/main.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@
5757
state: present
5858
pkg: "{{ INSTALLED_PACKAGES }}"
5959

60+
- name: Install common required/useful graphical packages
61+
apt:
62+
state: present
63+
pkg: "{{ GRAPHICAL_INSTALLED_PACKAGES }}"
64+
when: GRAPHICAL
65+
6066
- name: Install local DEB packages
6167
include_tasks: install-local-package.yml
6268
with_fileglob:

provision-contest/ansible/roles/domjudge_user/handlers/main.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,9 @@
44
name: gdm3
55
enabled: true
66
state: restarted
7+
8+
- name: Restart lightdm
9+
service:
10+
name: lightdm
11+
enabled: true
12+
state: restarted

provision-contest/ansible/roles/domjudge_user/tasks/main.yml

Lines changed: 77 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,13 @@
2222
loop_control:
2323
loop_var: user_item
2424

25+
- name: Detect display manager
26+
shell: basename $(cat /etc/X11/default-display-manager 2>/dev/null || systemctl get-default 2>/dev/null | grep -oP '^\w+-dm' || echo "unknown")
27+
register: detected_dm
28+
changed_when: false
29+
2530
- name: Setup autologin on desktop installs
31+
when: GRAPHICAL
2632
block:
2733
- name: Enable GDM autologin
2834
lineinfile:
@@ -32,13 +38,26 @@
3238
create: true
3339
mode: 0644
3440
notify: Restart gdm
41+
when: detected_dm.stdout == 'gdm3' or detected_dm.stdout == 'gdm'
3542

36-
- name: Automatically login domjudge user
43+
- name: Automatically login domjudge user (GDM)
3744
lineinfile:
3845
path: /etc/gdm3/custom.conf
3946
regexp: 'AutomaticLogin\s*='
4047
line: 'AutomaticLogin=domjudge'
4148
notify: Restart gdm
49+
when: detected_dm.stdout == 'gdm3' or detected_dm.stdout == 'gdm'
50+
51+
- name: Enable LightDM autologin
52+
lineinfile:
53+
path: /etc/lightdm/lightdm.conf
54+
regexp: 'autologin-user='
55+
line: 'autologin-user=domjudge'
56+
insertafter: '\[Seat:\*\]'
57+
create: true
58+
mode: 0644
59+
notify: Restart lightdm
60+
when: detected_dm.stdout == 'lightdm'
4261

4362
- name: Make sure autostart directory exists
4463
file:
@@ -47,4 +66,60 @@
4766
owner: domjudge
4867
group: domjudge
4968
mode: 0755
50-
when: GRAPHICAL
69+
70+
- name: Get default GNOME Terminal profile
71+
command: dconf read /org/gnome/terminal/legacy/profiles:/default
72+
register: terminal_profile
73+
changed_when: false
74+
become: true
75+
become_user: domjudge
76+
77+
- name: Get default GNOME Terminal profile
78+
command: dconf read /org/gnome/terminal/legacy/profiles:/default
79+
register: terminal_profile
80+
changed_when: false
81+
failed_when: false
82+
become: true
83+
become_user: domjudge
84+
85+
- name: Generate profile UUID
86+
set_fact:
87+
profile_uuid: "{{ 'domjudge-terminal' | to_uuid }}"
88+
when: terminal_profile.stdout == ''
89+
90+
- name: Use existing profile UUID
91+
set_fact:
92+
profile_uuid: "{{ terminal_profile.stdout | replace(\"'\", '') }}"
93+
when: terminal_profile.stdout != ''
94+
95+
- name: Set default profile
96+
community.general.dconf:
97+
key: /org/gnome/terminal/legacy/profiles:/default
98+
value: "'{{ profile_uuid }}'"
99+
become: true
100+
become_user: domjudge
101+
when: terminal_profile.stdout == ''
102+
103+
- name: Add profile to list
104+
community.general.dconf:
105+
key: /org/gnome/terminal/legacy/profiles:/list
106+
value: "['{{ profile_uuid }}']"
107+
become: true
108+
become_user: domjudge
109+
when: terminal_profile.stdout == ''
110+
111+
- name: Configure GNOME Terminal colors
112+
community.general.dconf:
113+
key: "/org/gnome/terminal/legacy/profiles:/:{{ profile_uuid }}/{{ item.key }}"
114+
value: "{{ item.value }}"
115+
loop:
116+
- key: background-color
117+
value: "'rgb(0,43,54)'"
118+
- key: foreground-color
119+
value: "'rgb(131,148,150)'"
120+
- key: use-theme-colors
121+
value: "false"
122+
- key: visible-name
123+
value: "'Default'"
124+
become: true
125+
become_user: domjudge

provision-contest/ansible/roles/domlogo/templates/domlogo.service.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Type=simple
88
Environment=REQUESTS_CA_BUNDLE=/usr/local/share/ca-certificates/domserver.crt
99
Environment=DISPLAY=:0
1010
WorkingDirectory={{ DJ_DIR }}
11-
ExecStart=domlogo.py
11+
ExecStart=python3 domlogo.py
1212
User=domjudge
1313

1414
Restart=always

provision-contest/ansible/roles/judgedaemon/tasks/main.yml

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,52 @@
3333
src: chroot-list
3434
dest: /tmp/dj_ansible/
3535

36+
- name: Convert ASC key to GPG format for debootstrap
37+
shell: gpg --dearmor < /etc/apt/trusted.gpg.d/pc2packages.asc > /tmp/pc2packages.gpg
38+
args:
39+
creates: /tmp/pc2packages.gpg
40+
when: ICPC_IMAGE
41+
3642
- name: Create chroot
3743
shell: "set -o pipefail &&
3844
{{ DJ_DIR }}/misc-tools/dj_make_chroot -y -H
39-
-i icpc-kotlinc,openjdk-17-jdk-headless
45+
-i openjdk-21-jdk-headless
4046
-l \"$(ls /tmp/dj_ansible/install-chroot/*.deb 2>/dev/null | tr '\n' ',')\"
4147
-s \"$(ls /tmp/dj_ansible/chroot-list/*.list 2>/dev/null | tr '\n' ',')\"
4248
2>&1 | tee /tmp/dj_make_chroot.log;
4349
grep '^Done building chroot in' /tmp/dj_make_chroot.log"
4450
environment:
45-
DEBMIRROR: "{%- if WF_RESTRICTED_NETWORK and ICPC_IMAGE -%}https://packages/ubuntu
46-
{%- elif ICPC_IMAGE -%}https://sysopspackages.icpc.global/ubuntu
51+
DEBMIRROR: "{%- if WF_RESTRICTED_NETWORK and ICPC_IMAGE -%}https://packages/ubuntu/noble
52+
{%- elif ICPC_IMAGE -%}https://sysopspackages.icpc.global/ubuntu/noble
4753
{%- else -%}
4854
{%- endif -%}"
4955
args:
5056
executable: /bin/bash
5157
creates: "/chroot/domjudge"
5258

59+
- name: ICPC Kotlin setup in chroot
60+
when: ICPC_IMAGE
61+
block:
62+
- name: Sync kotlinc to chroot
63+
ansible.posix.synchronize:
64+
src: /opt/kotlinc/
65+
dest: /chroot/domjudge/usr/lib/kotlinc/
66+
delegate_to: "{{ inventory_hostname }}"
67+
68+
- name: Create kotlin symlinks in chroot
69+
ansible.builtin.file:
70+
src: /usr/lib/kotlinc/bin/{{ item }}
71+
dest: /chroot/domjudge/usr/local/bin/{{ item }}
72+
state: link
73+
force: true
74+
follow: false
75+
loop:
76+
- kotlin
77+
- kotlinc
78+
5379
- name: Pre-generate the kernel flags for ansible usage
5480
set_fact:
55-
procline: "apparmor=0 systemd.unified_cgroup_hierarchy=0 cgroup_enable=memory swapaccount=1 isolcpus={{ cpucore | join(',') }}"
81+
procline: "apparmor=0 cgroup_enable=memory swapaccount=1 isolcpus={{ cpucore | join(',') }}"
5682

5783
- name: Add cgroup kernel parameters
5884
lineinfile:

0 commit comments

Comments
 (0)