-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgameserver.yml
162 lines (131 loc) · 3.53 KB
/
gameserver.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
- hosts: web
tasks:
- name: install pip and python 2
raw: test -e /usr/bin/pip2 || (apt -y update && apt install -y python-pip)
become: true
- name: remove python3-pip
apt:
name: python3-pip
state: absent
become: yes
- name: Install packages
apt:
name:
- python-yaml # needed for scorebot
- python3-yaml
- redis-server
- python3-cryptography
- python3-pip
- python-bs4
- python-lxml
- python-requests
- openvpn
- libmysqlclient-dev
- libffi-dev
state: latest
update_cache: yes
become: yes
- hosts: web
tasks:
- name: add user ctf
user:
name: ctf
become: True
- name: Set authorized key taken from file for ctf user
authorized_key:
user: ctf
state: present
key: "{{ lookup('file', playbook_dir+'/sshkey/id_rsa_ctf.pub') }}"
become: yes
- name: set timezone to UTC
timezone:
name: UTC
become: yes
- name: sync project to container when not dev system
synchronize:
src: ./
dest: /srv/ctf
use_ssh_args: yes
when: in_vagrant is not defined
become: yes
- hosts: ctfserver
tasks:
- name: configure lxd to mount vagrant dir for development (subuid file)
lineinfile:
path: /etc/subuid
line: "root:1000:1"
when: in_vagrant is defined
become: yes
- name: configure lxd to mount vagrant dir for development (subgid file)
lineinfile:
path: /etc/subgid
line: "root:1000:1"
when: in_vagrant is defined
become: yes
- name: configure lxd to mount vagrant dir for development (raw.idmap)
command: lxc config set web raw.idmap "both 1000 1001"
when: in_vagrant is defined
become: yes
- name: configure lxd to mount vagrant dir for development (bind mount)
command: lxc config device add web vagrant disk source=/vagrant path=/srv/ctf
when: in_vagrant is defined
ignore_errors: yes
register: bind_mount
become: yes
- name: restart webcontainer
command: lxc restart web
when: in_vagrant is defined and bind_mount.rc == 0
become: yes
- pause:
seconds: 40
when: in_vagrant is defined and bind_mount.rc == 0
- hosts: web
tasks:
- name: Create a symbolic link
file:
src: /srv/ctf/ctfdbapi
dest: /opt/ctfdbapi
state: link
become: yes
- name: Create a symbolic link
file:
src: /srv/ctf/scorebot
dest: /opt/scorebot
state: link
become: yes
- name: log dir
file:
path: /var/log/ctf/
state: directory
owner: ctf
group: ctf
recurse: true
become: yes
- service: name=redis-server state=started
- name: install requirements for cryptography
apt:
name:
- python3-dev
- libffi-dev
- libssl-dev
- build-essential
become: yes
- name: Install requirements
pip:
requirements: /opt/ctfdbapi/requirements.txt
executable: pip3
#virtualenv: /home/{{role_path|basename}}/env
#virtualenv_python: python3
become: yes
- name: set owner/group for service files
file:
path: "/srv/ctf"
owner: "ctf"
group: "ctf"
recurse: yes
become: yes
- hosts: web
roles:
- mariadb
- lxctf.register
#- scorebot_deps_2019