Skip to content

Commit 1d01dc8

Browse files
Update CDS role to work with new 2.5 CDS with accounts.json.
Also fix some small issues.
1 parent 9f8eb1e commit 1d01dc8

File tree

4 files changed

+37
-17
lines changed

4 files changed

+37
-17
lines changed

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,36 @@ ADMIN_PASSWORD: some-admin-password
1818
# created on the domserver and judgehosts.
1919
#DJ_SHELL_USER_PW: some-hashed-password
2020

21-
# Users to create when setting up the CDS
22-
CDS_USERS:
21+
# Accounts to create when setting up the CDS
22+
CDS_ACCOUNTS:
2323
- username: admin
2424
password: adm1n
25+
type: admin
2526
- username: presAdmin
2627
password: padm1n
28+
type: admin
2729
- username: blue
2830
password: blu3
31+
type: staff
2932
- username: balloon
3033
password: balloonPr1nter
34+
type: balloon
3135
- username: public
3236
password: publ1c
37+
type: public
3338
- username: presentation
3439
password: presentat1on
40+
type: public
3541
- username: myicpc
3642
password: my1cpc
43+
type: spectator
3744
- username: live
3845
password: l1ve
46+
type: analyst
3947
- username: team1
4048
password: t3am
49+
type: team
50+
team_id: 1
4151

4252
# Contest(s) to configure in the CDS
4353
CDS_CONTESTS:

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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
---
22
# These tasks configure the CDS
33

4-
- name: Get the latest CDS release
4+
- name: Get the CDS release
55
uri:
6-
url: https://api.github.com/repos/icpctools/icpctools/releases/latest
6+
url: https://api.github.com/repos/icpctools/icpctools/releases?per_page=1
77
method: GET
88
return_content: yes
99
status_code: 200
1010
body_format: json
11-
register: latest_cds_release
11+
register: latest_cds_release_array
1212

1313
- name: Set CDS latest version
1414
set_fact:
15-
cds_version: "{{ latest_cds_release.json.name | replace('v', '') }}"
15+
cds_version: "{{ latest_cds_release_array.json[0].name | replace('v', '') }}"
16+
17+
- name: Set CDS minor version
18+
set_fact:
19+
cds_version_minor: "{{ cds_version | regex_replace('\\.\\d+$', '') }}"
1620

1721
- name: Check if CDS is installed
1822
stat:
@@ -46,18 +50,18 @@
4650

4751
- name: Copy new CDS war
4852
copy:
49-
src: /root/CDS-2.3/CDS.war
53+
src: /root/CDS-{{ cds_version_minor }}/CDS.war
5054
dest: /home/domjudge/cds/wlp/usr/servers/cds/apps/CDS.war
5155
remote_src: yes
5256
owner: domjudge
5357
group: domjudge
5458
when: cds_war.stat.exists
5559
notify: restart cds
5660

57-
- name: Populate CDS users.xml
61+
- name: Populate CDS accounts.json
5862
template:
59-
src: users.xml.j2
60-
dest: /home/domjudge/cds/wlp/usr/servers/cds/users.xml
63+
src: accounts.json.j2
64+
dest: /home/domjudge/cds/wlp/usr/servers/cds/config/accounts.json
6165
owner: domjudge
6266
group: domjudge
6367
mode: 0600
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[
2+
{% for account in CDS_ACCOUNTS %}
3+
{
4+
"id": "{{ account.username }}",
5+
"username": "{{ account.username }}",
6+
"password": "{{ account.password }}",
7+
"type": "{{ account.type }}"{% if account.team_id is defined %},
8+
"team_id": "{{ account.team_id }}"{% endif %}
9+
10+
}{% if not loop.last %},{% endif %}
11+
12+
{% endfor %}
13+
]

icpc-wf/ansible/roles/cds/templates/users.xml.j2

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)