Skip to content

Commit 5515f5b

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. We also fix the bug that when the service does not exist we cannot start the ansible books anymore. The used credentials are default and insecure.
1 parent ed1f823 commit 5515f5b

File tree

2 files changed

+33
-0
lines changed

2 files changed

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

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:

0 commit comments

Comments
 (0)