Skip to content

Commit c6165fb

Browse files
committed
Quick rewrite with our conventions
The way to determine if we have internet is actually nicer in the ICPC config but for now prefer our style for consistency.
1 parent d881f31 commit c6165fb

File tree

1 file changed

+39
-23
lines changed
  • provision-contest/ansible/roles/script_server/tasks

1 file changed

+39
-23
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,51 @@
11
---
22
- name: Install script-server dependencies
3-
ansible.builtin.package:
4-
pkg: "{{ item }}"
3+
apt:
4+
name:
5+
- python3-tornado
6+
- apache2-utils # for htpasswd auth
57
state: present
6-
loop:
7-
- python3-tornado
8-
- apache2-utils # for htpasswd auth
98

109
- name: Create directory for script-server to live
11-
ansible.builtin.file:
10+
file:
1211
path: /opt/script-server
1312
mode: "0755"
1413
owner: root
1514
group: root
1615
state: directory
1716

18-
- name: Download script-server
19-
ansible.builtin.unarchive:
20-
src: "{{ script_server_url }}"
17+
- name: Install script-server
18+
when: ICPC_IMAGE
19+
unarchive:
20+
src: "https://github.com/bugy/script-server/releases/download/1.18.0/script-server.zip"
21+
22+
name: Install script-server
23+
when: ICPC_IMAGE
24+
unarchive:
25+
src: "script-server.zip"
2126
dest: /opt/script-server
22-
remote_src: "{{ true if script_server_url.startswith('http') else false }}"
27+
remote_src: false
28+
creates: /opt/script-server/launcher.py
29+
30+
- name: Install script-server
31+
when: not ICPC_IMAGE
32+
unarchive:
33+
src: "https://github.com/bugy/script-server/releases/download/1.18.0/script-server.zip"
34+
dest: /opt/script-server
35+
remote_src: true
2336
creates: /opt/script-server/launcher.py
2437

2538
- name: Configure the server
26-
ansible.builtin.template:
39+
template:
2740
src: conf.json.j2
2841
dest: /opt/script-server/conf/conf.json
2942
mode: "0644"
43+
owner: root
44+
group: root
3045

3146
- name: Create systemd service for script-server
32-
ansible.builtin.copy:
47+
notify: Restart script-server
48+
copy:
3349
mode: "0644"
3450
dest: /etc/systemd/system/script-server.service
3551
content: |
@@ -46,16 +62,9 @@
4662
4763
[Install]
4864
WantedBy=multi-user.target
49-
notify: Restart script-server
50-
51-
- name: Start + enable script-server
52-
ansible.builtin.service:
53-
name: script-server
54-
state: started
55-
enabled: true
5665
5766
- name: Ensure required directories exist
58-
ansible.builtin.file:
67+
file:
5968
state: directory
6069
mode: "0755"
6170
path: /opt/script-server/conf/{{ item }}
@@ -64,15 +73,22 @@
6473
- runners
6574

6675
- name: Create scripts
67-
ansible.builtin.copy:
76+
copy:
6877
content: "{{ item.content }}"
6978
dest: /opt/script-server/conf/scripts/{{ item.name }}
7079
mode: "0755"
7180
with_items: "{{ script_server_commands }}"
7281

7382
- name: Create script config definitions
7483
ansible.builtin.template:
75-
src: command_template.yaml.j2
76-
dest: /opt/script-server/conf/runners/{{ item.name }}.yaml
84+
src: command_template.yml.j2
85+
dest: /opt/script-server/conf/runners/{{ item.name }}.yml
7786
mode: "0644"
7887
with_items: "{{ script_server_commands }}"
88+
89+
- name: Start + enable script-server
90+
service:
91+
name: script-server
92+
state: started
93+
enabled: true
94+

0 commit comments

Comments
 (0)