Compare commits

..

6 Commits

Author SHA1 Message Date
bc70766c19 Fix(domserver): docker compose mount point
All checks were successful
Ansible Playbook lint / ansible-lint (push) Successful in 17s
2025-04-10 21:58:00 +08:00
f09a7265af Rename(domserver): mysql config suffix
All checks were successful
Ansible Playbook lint / ansible-lint (push) Successful in 18s
2025-04-10 21:50:28 +08:00
f35efd19c4 Fix(judgehost): force rebuild chroot
All checks were successful
Ansible Playbook lint / ansible-lint (push) Successful in 16s
2025-04-10 03:14:19 +08:00
46b2e1d4b1 Feat(judgehost): add playbook for rebuild chroot
All checks were successful
Ansible Playbook lint / ansible-lint (push) Successful in 16s
2025-04-10 03:13:17 +08:00
935ae15ef3 Refactor(judgehost): add kotlin support
All checks were successful
Ansible Playbook lint / ansible-lint (push) Successful in 18s
2025-04-10 03:04:46 +08:00
055c70632e Fix(judgehost): permission of /opt/domjudge
All checks were successful
Ansible Playbook lint / ansible-lint (push) Successful in 17s
2025-04-08 13:07:44 +08:00
14 changed files with 116 additions and 105 deletions

3
hosts
View File

@@ -7,7 +7,8 @@ localhost ansible_connection=local
[judgehost] [judgehost]
10.4.2.227 10.4.2.227
#10.4.2.228 10.4.2.228
10.4.2.229
[all:vars] [all:vars]
ansible_python_interpreter=/usr/bin/python3 ansible_python_interpreter=/usr/bin/python3

View File

@@ -0,0 +1,9 @@
- name: Rebuild chroot environment for judgehosts
hosts: judgehost
tasks:
- name: Run misc-tools/dj_make_chroot
ansible.builtin.command: |
./misc-tools/dj_make_chroot -y -i kotlin
args:
chdir: "{{ domjudge_base_dir }}"
changed_when: true

View File

@@ -2,6 +2,6 @@
- name: Install judgehost - name: Install judgehost
hosts: judgehost hosts: judgehost
roles: roles:
# - role: install_packages_debian - role: install_packages_debian
# - role: configure_judgehost_legacy # - role: configure_judgehost_docker
- role: configure_judgehost - role: configure_judgehost

View File

@@ -21,11 +21,11 @@ services:
CONTAINER_TIMEZONE: Asia/Taipei CONTAINER_TIMEZONE: Asia/Taipei
restart: always restart: always
volumes: volumes:
- "restapi_secret:/opt/domjudge/domserver/etc/restapi.secret" - "domserver_etc:/opt/domjudge/domserver/etc/"
- "./config/php/domjudge.conf:/etc/php/8.2/fpm/pool.d/domjudge.conf" - "./config/php/domjudge.conf:/etc/php/8.2/fpm/pool.d/domjudge.conf"
depends_on: depends_on:
- mariadb - mariadb
ports: ports:
- "127.0.0.1:8080:80" - "127.0.0.1:8080:80"
volumes: volumes:
restapi_secret: {} domserver_etc: {}

View File

@@ -1,12 +1,14 @@
--- ---
- name: Reboot
ansible.builtin.reboot: {}
- name: Update grub - name: Update grub
ansible.builtin.command: | ansible.builtin.command: |
update-grub update-grub
changed_when: true changed_when: true
- name: Restart judgehost docker compose - name: Reboot
community.docker.docker_compose_v2: ansible.builtin.reboot:
project_src: "{{ domjudge_base_dir }}" - name: Systemd daemon-reload
ansible.builtin.systemd_service:
daemon_reload: true
- name: Restart judgehost
ansible.builtin.systemd_service:
name: domjudge-judgehost.target
state: restarted state: restarted
remove_orphans: true

View File

@@ -78,11 +78,12 @@
group: root group: root
- name: Run misc-tools/dj_make_chroot - name: Run misc-tools/dj_make_chroot
tags: [chroot]
ansible.builtin.command: | ansible.builtin.command: |
./misc-tools/dj_make_chroot ./misc-tools/dj_make_chroot -i kotlin
args: args:
chdir: "{{ domjudge_base_dir }}" chdir: "{{ domjudge_base_dir }}"
changed_when: true creates: /chroot/domjudge
- name: Modify boot options - name: Modify boot options
ansible.builtin.lineinfile: ansible.builtin.lineinfile:

View File

@@ -3,7 +3,7 @@
path: "{{ domjudge_base_dir | dirname }}" path: "{{ domjudge_base_dir | dirname }}"
state: directory state: directory
recurse: true recurse: true
mode: '0750' mode: '0755'
owner: domjudge owner: domjudge
group: domjudge group: domjudge
- name: Install domjudge by tarball - name: Install domjudge by tarball

View File

@@ -1,68 +1,10 @@
--- ---
- name: Add boot parameters (Archlinux) - name: Add domjudge user
ansible.builtin.lineinfile: ansible.builtin.user:
path: /boot/loader/entries/arch.conf name: domjudge
line: >- create_home: true
options cgroup_enable=memory - name: Import domjudge download
notify: Reboot ansible.builtin.import_tasks: download.yml
when: ansible_facts['distribution'] == "Archlinux" - name: Import domjudge configure
- name: Add boot parameters (Debian) ansible.builtin.import_tasks: configure.yml
ansible.builtin.lineinfile: notify: Restart judgehost
path: /etc/default/grub
regexp: '^GRUB_CMDLINE_LINUX_DEFAULT='
line: >-
GRUB_CMDLINE_LINUX_DEFAULT="quiet
cgroup_enable=memory swapaccount=1 isolcpus=0
systemd.unified_cgroup_hierarchy=0"
notify:
- Update grub
- Reboot
when: ansible_facts['distribution'] == "Debian"
- name: Flush handlers
ansible.builtin.meta: flush_handlers
- name: Fetch judgehost password
community.docker.docker_compose_v2_exec:
project_src: "{{ domjudge_base_dir }}"
service: domserver
command: >-
sed -nr 's/^.*\W+judgehost\W+(.+)$/\1/p'
/opt/domjudge/domserver/etc/restapi.secret
delegate_to: "{{ groups['domserver'] | first }}"
run_once: true
register: fetch_reg
- name: Set judgehost facts
ansible.builtin.set_fact:
domserver_url: "{{ domserver_url }}"
judgehost_password: "{{ fetch_reg['stdout'] }}"
run_once: true
- name: Show judgehost password
ansible.builtin.debug:
var: judgehost_password
- name: Install judgehost directory
ansible.builtin.file:
path: "{{ domjudge_base_dir }}"
state: directory
mode: '0750'
owner: root
group: docker
- name: Install judgehost docker compose
notify:
- Restart judgehost docker compose
block:
- name: Install docker-compose.yml
ansible.builtin.template:
src: docker-compose.yml.jinja
dest: "{{ domjudge_base_dir }}/docker-compose.yml"
mode: '0644'
owner: root
group: root
- name: Enable and start docker
ansible.builtin.systemd_service:
name: docker.service
state: started
enabled: true
- name: Run docker compose up
community.docker.docker_compose_v2:
project_src: "{{ domjudge_base_dir }}"

View File

@@ -0,0 +1,12 @@
---
- name: Reboot
ansible.builtin.reboot: {}
- name: Update grub
ansible.builtin.command: |
update-grub
changed_when: true
- name: Restart judgehost docker compose
community.docker.docker_compose_v2:
project_src: "{{ domjudge_base_dir }}"
state: restarted
remove_orphans: true

View File

@@ -0,0 +1,68 @@
---
- name: Add boot parameters (Archlinux)
ansible.builtin.lineinfile:
path: /boot/loader/entries/arch.conf
line: >-
options cgroup_enable=memory
notify: Reboot
when: ansible_facts['distribution'] == "Archlinux"
- name: Add boot parameters (Debian)
ansible.builtin.lineinfile:
path: /etc/default/grub
regexp: '^GRUB_CMDLINE_LINUX_DEFAULT='
line: >-
GRUB_CMDLINE_LINUX_DEFAULT="quiet
cgroup_enable=memory swapaccount=1 isolcpus=0
systemd.unified_cgroup_hierarchy=0"
notify:
- Update grub
- Reboot
when: ansible_facts['distribution'] == "Debian"
- name: Flush handlers
ansible.builtin.meta: flush_handlers
- name: Fetch judgehost password
community.docker.docker_compose_v2_exec:
project_src: "{{ domjudge_base_dir }}"
service: domserver
command: >-
sed -nr 's/^.*\W+judgehost\W+(.+)$/\1/p'
/opt/domjudge/domserver/etc/restapi.secret
delegate_to: "{{ groups['domserver'] | first }}"
run_once: true
register: fetch_reg
- name: Set judgehost facts
ansible.builtin.set_fact:
domserver_url: "{{ domserver_url }}"
judgehost_password: "{{ fetch_reg['stdout'] }}"
run_once: true
- name: Show judgehost password
ansible.builtin.debug:
var: judgehost_password
- name: Install judgehost directory
ansible.builtin.file:
path: "{{ domjudge_base_dir }}"
state: directory
mode: '0750'
owner: root
group: docker
- name: Install judgehost docker compose
notify:
- Restart judgehost docker compose
block:
- name: Install docker-compose.yml
ansible.builtin.template:
src: docker-compose.yml.jinja
dest: "{{ domjudge_base_dir }}/docker-compose.yml"
mode: '0644'
owner: root
group: root
- name: Enable and start docker
ansible.builtin.systemd_service:
name: docker.service
state: started
enabled: true
- name: Run docker compose up
community.docker.docker_compose_v2:
project_src: "{{ domjudge_base_dir }}"

View File

@@ -1,14 +0,0 @@
---
- name: Update grub
ansible.builtin.command: |
update-grub
changed_when: true
- name: Reboot
ansible.builtin.reboot:
- name: Systemd daemon-reload
ansible.builtin.systemd_service:
daemon_reload: true
- name: Restart judgehost
ansible.builtin.systemd_service:
name: domjudge-judgehost.target
state: restarted

View File

@@ -1,10 +0,0 @@
---
- name: Add domjudge user
ansible.builtin.user:
name: domjudge
create_home: true
- name: Import domjudge download
ansible.builtin.import_tasks: download.yml
- name: Import domjudge configure
ansible.builtin.import_tasks: configure.yml
notify: Restart judgehost