Skip to content

Commit

Permalink
Quick rewrite with our conventions
Browse files Browse the repository at this point in the history
The way to determine if we have internet is actually nicer in the ICPC
config but for now prefer our style for consistency.
  • Loading branch information
vmcj committed Sep 12, 2024
1 parent d95b77f commit 5af9d1a
Showing 1 changed file with 39 additions and 23 deletions.
62 changes: 39 additions & 23 deletions provision-contest/ansible/roles/script_server/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,51 @@
---
- name: Install script-server dependencies
ansible.builtin.package:
pkg: "{{ item }}"
apt:
name:
- python3-tornado
- apache2-utils # for htpasswd auth
state: present
loop:
- python3-tornado
- apache2-utils # for htpasswd auth

- name: Create directory for script-server to live
ansible.builtin.file:
file:
path: /opt/script-server
mode: "0755"
owner: root
group: root
state: directory

- name: Download script-server
ansible.builtin.unarchive:
src: "{{ script_server_url }}"
- name: Install script-server
when: ICPC_IMAGE
unarchive:
src: "https://github.com/bugy/script-server/releases/download/1.18.0/script-server.zip"

name: Install script-server
when: ICPC_IMAGE
unarchive:
src: "script-server.zip"
dest: /opt/script-server
remote_src: "{{ true if script_server_url.startswith('http') else false }}"
remote_src: false
creates: /opt/script-server/launcher.py

- name: Install script-server
when: not ICPC_IMAGE
unarchive:
src: "https://github.com/bugy/script-server/releases/download/1.18.0/script-server.zip"
dest: /opt/script-server
remote_src: true
creates: /opt/script-server/launcher.py

- name: Configure the server
ansible.builtin.template:
template:
src: conf.json.j2
dest: /opt/script-server/conf/conf.json
mode: "0644"
owner: root
group: root

- name: Create systemd service for script-server
ansible.builtin.copy:
notify: Restart script-server
copy:
mode: "0644"
dest: /etc/systemd/system/script-server.service
content: |
Expand All @@ -46,16 +62,9 @@
[Install]
WantedBy=multi-user.target
notify: Restart script-server

- name: Start + enable script-server
ansible.builtin.service:
name: script-server
state: started
enabled: true
- name: Ensure required directories exist
ansible.builtin.file:
file:
state: directory
mode: "0755"
path: /opt/script-server/conf/{{ item }}
Expand All @@ -64,15 +73,22 @@
- runners

- name: Create scripts
ansible.builtin.copy:
copy:
content: "{{ item.content }}"
dest: /opt/script-server/conf/scripts/{{ item.name }}
mode: "0755"
with_items: "{{ script_server_commands }}"

- name: Create script config definitions
ansible.builtin.template:
src: command_template.yaml.j2
dest: /opt/script-server/conf/runners/{{ item.name }}.yaml
src: command_template.yml.j2
dest: /opt/script-server/conf/runners/{{ item.name }}.yml
mode: "0644"
with_items: "{{ script_server_commands }}"

- name: Start + enable script-server
service:
name: script-server
state: started
enabled: true

0 comments on commit 5af9d1a

Please sign in to comment.