-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcheckers-playbook.yml
77 lines (64 loc) · 2.41 KB
/
checkers-playbook.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
---
- name: Deploy services
hosts: gameservers
# become: true
vars:
checker_py_folder: "/usr/lib/python3/dist-packages/ctf_gameserver/checker/"
checker_env_folder: "/etc/ctf-gameserver/checker/"
tasks:
- name: Create checker_py_folder if it doesn't exist
file:
path: "{{ checker_py_folder }}"
state: directory
mode: '0755'
recurse: yes
owner: root
group: root
setype: s0
- name: Create checker_env_folder if it doesn't exist
file:
path: "{{ checker_env_folder }}"
state: directory
mode: '0755'
recurse: yes
owner: root
group: root
setype: s0
- name: Read services to install
command: "cat {{ playbook_dir }}/services2install.txt"
register: services_to_install
delegate_to: localhost
- name: Copy checker subfolders
copy:
src: "{{ item }}/checker/"
dest: "{{ checker_py_folder }}{{ item }}"
loop: "{{ services_to_install.stdout_lines }}"
- name: move env file
shell: mv {{ checker_py_folder }}{{ item }}/{{ item }}.env {{ checker_env_folder }}
loop: "{{ services_to_install.stdout_lines }}"
- name: Set py files executable
shell: chmod +x {{ checker_py_folder }}{{ item }}/*
loop: "{{ services_to_install.stdout_lines }}"
# #- name: Get all lines of apt_requirements.txt files located in service/checker subfolders
# shell: "cat {{ playbook_dir }}/{{ item }}/checker/apt_requirement.txt"
# register: apt_requirements
# loop: "{{ services_to_install.stdout_lines }}"
# delegate_to: localhost
# - name: Install apt requirements in all checker subfolders
# apt:
# name: "{{ item }}"
# state: present
# loop: "{{ apt_requirements.results }}"
- name: Enable checker service
command: "systemctl enable ctf-checkermaster@{{ item }}"
loop: "{{ services_to_install.stdout_lines }}"
- name: Restart checker service
command: "systemctl restart ctf-checkermaster@{{ item }}"
loop: "{{ services_to_install.stdout_lines }}"
- name: create db entries for services
become: true
become_user: postgres
shell: psql -d ctf_gameserver -c "INSERT INTO scoring_service (name, slug) VALUES ('{{ item }}', '{{ item }}');"
loop: "{{ services_to_install.stdout_lines }}"
ignore_errors: yes
# Add more tasks as needed