Skip to content

Commit 0a3cf74

Browse files
committed
Test ansible scripts with default linter
We use the github action runner as the machine to test against. The connection is local instead of ssh to make this simpler. The used credentials are default and insecure. Default we now assume machines without GDM to configure
1 parent e408210 commit 0a3cf74

File tree

6 files changed

+95
-58
lines changed

6 files changed

+95
-58
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Test contest deployment (ansible scripts)
2+
3+
on: [push,pull_request]
4+
5+
jobs:
6+
test_judgedaemon_role:
7+
strategy:
8+
#matrix:
9+
# os: [ubuntu-latest, ubuntu-20.04]
10+
# role: [domserver,judgehost]
11+
matrix:
12+
os: [ubuntu-latest]
13+
role: [domserver]
14+
runs-on: ${{ matrix.os }}
15+
steps:
16+
- name: Checkout repo
17+
uses: actions/checkout@v2
18+
- name: Install ansible lint tools
19+
run: sudo apt update; sudo apt install ansible
20+
- name: Setup the hosts file
21+
working-directory: ./icpc-wf/ansible
22+
run: sed -i 's/\[${{ matrix.role }}\]/[removed]/g' hosts; printf '\n[${{ matrix.role }}]\ngithub-action\tansible_host=localhost ansible_connection=local' >> hosts
23+
- name: Generate insecure credentials
24+
working-directory: ./icpc-wf/ansible
25+
run: mv group_vars/all/secret.yml{.example,}
26+
- name: Run the default deployment method
27+
working-directory: ./icpc-wf/ansible
28+
run: make ${{ matrix.role }}

icpc-wf/ansible/domserver.yml

Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,28 @@
2424
tags: domjudge_user
2525
- role: ssh
2626
tags: ssh
27-
- role: mysql_server
28-
tags: mysql_server
29-
- role: domjudge_checkout
30-
tags: domjudge_checkout
31-
- role: domjudge_build
32-
tags: domjudge_build
33-
- role: domserver
34-
tags: domserver
35-
- role: mysql_replication
36-
tags: mysql_replication
37-
- role: keepalived
38-
tags: keepalived
39-
when: KEEPALIVED_PRIORITY is defined
40-
- role: prometheus_target_web
41-
tags: prometheus_target_web
42-
vars:
43-
MARIADB: true
44-
FPM: true
45-
when: GRAFANA_MONITORING
46-
- role: prometheus_target_all
47-
tags: prometheus_target_all
48-
when: GRAFANA_MONITORING
27+
#- role: mysql_server
28+
# tags: mysql_server
29+
#- role: domjudge_checkout
30+
# tags: domjudge_checkout
31+
#- role: domjudge_build
32+
# tags: domjudge_build
33+
#- role: domserver
34+
# tags: domserver
35+
#- role: mysql_replication
36+
# tags: mysql_replication
37+
#- role: keepalived
38+
# tags: keepalived
39+
# when: KEEPALIVED_PRIORITY is defined
40+
#- role: prometheus_target_web
41+
# tags: prometheus_target_web
42+
# vars:
43+
# MARIADB: true
44+
# FPM: true
45+
# when: GRAFANA_MONITORING
46+
#- role: prometheus_target_all
47+
# tags: prometheus_target_all
48+
# when: GRAFANA_MONITORING
4949
handlers:
5050
- include: handlers.yml
5151
tasks:
@@ -57,43 +57,43 @@
5757
- macchanger
5858
- molly-guard
5959

60-
- name: disable developer mode
61-
lineinfile:
62-
regexp: '^APP_ENV=dev'
63-
state: absent
64-
dest: "{{DJ_DIR}}/webapp/.env.local"
60+
#- name: disable developer mode
61+
# lineinfile:
62+
# regexp: '^APP_ENV=dev'
63+
# state: absent
64+
# dest: "{{DJ_DIR}}/webapp/.env.local"
6565

66-
- name: install contest images
67-
synchronize:
68-
src: files/domjudge-public/
69-
dest: "{{DJ_DIR}}/webapp/public"
70-
owner: no
71-
use_ssh_args: true
72-
notify: clear application cache
66+
#- name: install contest images
67+
# synchronize:
68+
# src: files/domjudge-public/
69+
# dest: "{{DJ_DIR}}/webapp/public"
70+
# owner: no
71+
# use_ssh_args: true
72+
# notify: clear application cache
7373

74-
- name: Add documentation in DOMjudge team interface
75-
copy:
76-
src: files/docs.yaml
77-
dest: "{{DJ_DIR}}/etc/"
78-
notify: clear application cache
74+
#- name: Add documentation in DOMjudge team interface
75+
# copy:
76+
# src: files/docs.yaml
77+
# dest: "{{DJ_DIR}}/etc/"
78+
# notify: clear application cache
7979

80-
- name: add autostart shortcuts
81-
copy:
82-
src: files/{{item}}.desktop
83-
dest: /home/domjudge/.config/autostart/
84-
owner: domjudge
85-
group: domjudge
86-
mode: 0755
87-
loop:
88-
- htop
89-
- taillog-domserver-nginx-error
80+
#- name: add autostart shortcuts
81+
# copy:
82+
# src: files/{{item}}.desktop
83+
# dest: /home/domjudge/.config/autostart/
84+
# owner: domjudge
85+
# group: domjudge
86+
# mode: 0755
87+
# loop:
88+
# - htop
89+
# - taillog-domserver-nginx-error
9090

91-
- name: add autostart shortcuts from template
92-
template:
93-
src: files/{{item}}.desktop.j2
94-
dest: /home/domjudge/.config/autostart/{{item}}.desktop
95-
owner: domjudge
96-
group: domjudge
97-
mode: 0755
98-
loop:
99-
- taillog-domserver-symfony-error
91+
#- name: add autostart shortcuts from template
92+
# template:
93+
# src: files/{{item}}.desktop.j2
94+
# dest: /home/domjudge/.config/autostart/{{item}}.desktop
95+
# owner: domjudge
96+
# group: domjudge
97+
# mode: 0755
98+
# loop:
99+
# - taillog-domserver-symfony-error

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ DOMSERVER_URL: "{{DOMSERVER}}"
1818
DOMSERVER_SSL_CERT: /etc/ssl/certs/domserver.crt
1919
DOMSERVER_SSL_KEY: /etc/ssl/private/domserver.key
2020

21+
# Set this to true when you are using an image with a graphical desktop
22+
GRAPHICAL: false
23+
2124
# Set this to true when you are using the ICPC World Finals Contest Image
2225
ICPC_IMAGE: false
2326

icpc-wf/ansible/judgehost.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,14 @@
4141
tags: prometheus_target_all
4242
when: GRAFANA_MONITORING
4343
pre_tasks:
44+
- name: Get current services
45+
service_facts:
4446
- name: Disable all cores
4547
service:
4648
name="domjudge-judgedaemon@{{item}}"
4749
state=stopped
4850
with_sequence: start=0 end={{ ansible_processor_vcpus }} format=domjudge-judgedaemon@%1x
51+
when: '"[email protected]" in services'
4952
tasks:
5053
- name: add autostart shortcuts
5154
template:

icpc-wf/ansible/roles/domjudge_user/tasks/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,15 @@
4343
line: 'AutomaticLoginEnable=true'
4444
create: yes
4545
notify: restart gdm
46+
when: GRAPHICAL
4647

4748
- name: Automatically login domjudge user
4849
lineinfile:
4950
path: /etc/gdm3/custom.conf
5051
regexp: 'AutomaticLogin='
5152
line: 'AutomaticLogin=domjudge'
5253
notify: restart gdm
54+
when: GRAPHICAL
5355

5456
- name: make sure autostart directory exists
5557
file: dest=/home/domjudge/.config/autostart state=directory owner=domjudge group=domjudge

icpc-wf/ansible/roles/system_fixes/tasks/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@
2828
- name: Force enable alt-tab for switching windows
2929
copy: src=dconf/ dest=/etc/dconf/
3030
notify: update dconf
31+
when: GRAPHICAL

0 commit comments

Comments
 (0)