-
Notifications
You must be signed in to change notification settings - Fork 43
/
single_box.yml
312 lines (252 loc) · 9.13 KB
/
single_box.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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
# Algospot ansible settings
# vim: set et ts=2 sts=2 sw=2
- name: "update apt repository cache"
apt: update_cache=yes cache_valid_time=3600
sudo: yes
- name: "install apt packages"
apt: name={{item}} state=present
sudo: yes
with_items:
- python-setuptools
- python-dev
- build-essential
- git-core
- libjpeg-dev
- rabbitmq-server
- redis-server
- postgresql-9.3
- postgresql-contrib-9.3
- postgresql-server-dev-9.3
- lxc
- aufs-tools
- golang
- ghc
- ruby
- luajit
- pypy
- python3
- name: "install pip"
sudo: yes
easy_install: name=pip
- name: "install python dependencies"
sudo: yes
pip: name={{item}}
with_items:
- Django==1.6.5
- Pygments==2.0.2
- South==0.8.1
- Whoosh==2.6.0
- celery==3.1.12
- django-appconf==0.6
- django-attachments==0.3.1
- django-avatar==2.0
- django-celery==3.1.10
- django-debug-toolbar==1.2.1
- django-extensions==1.3.8
- django-guardian==1.2.0
- django-haystack==2.1.0
- django-picklefield==0.3.1
- django-staticfiles==1.2.1
- django-tagging==0.3.2
- ipdb==0.7
- ipython==0.13.2
- redis==2.7.6
- pygooglechart==0.4.0
- uwsgi
- Pillow
- psycopg2
- dogslow
- icalendar
- pytz
- python-apt
# Java
- name: "oracle java ppa"
sudo: yes
apt_repository: repo='ppa:webupd8team/java'
- name: "disable interactive installer for oracle java"
sudo: yes
shell: echo debconf shared/accepted-oracle-license-v1-1 select true | debconf-set-selections
- name: "disable interactive installer for oracle java"
sudo: yes
shell: echo debconf shared/accepted-oracle-license-v1-1 seen true | debconf-set-selections
- name: "install oracle java"
sudo: yes
apt: name=oracle-java8-installer
# Scala
- name: "checking wheter scala exists ..."
command: scalac -version
register: scala_version
ignore_errors: True
- name: "download scala 2.11.1"
when: scala_version|failed or scala_version.stderr.find('2.11.1') == -1
sudo: yes
get_url: url=http://downloads.typesafe.com/scala/2.11.1/scala-2.11.1.deb dest=/tmp
- name: "install scala 2.11.1"
when: scala_version|failed or scala_version.stderr.find('2.11.1') == -1
sudo: yes
shell: dpkg --skip-same-version -i /tmp/scala-2.11.1.deb
# .NET Core SDK
- name: "add apt repository for .net core"
sudo: yes
apt_repository: repo='deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ trusty main' filename='dotnetdev'
- name: "add apt key for .net core "
sudo: yes
apt_key: keyserver=apt-mo.trafficmanager.net id=417A0893
- name: "install .net core"
sudo: yes
apt: name=dotnet-dev-1.0.0-preview2-003121 update_cache=yes # update 해야 key 가 반영됨
# Rust
- name: "checking whether rust exists ..."
command: rustc --version
register: rustc_version
ignore_errors: True
- name: "download and install rust 1.0.0 (64bit binary)"
when: rustc_version|failed or rustc_version.stderr.find('rustc 1.0.0') == -1
sudo: yes
shell: curl -s https://static.rust-lang.org/rustup.sh > /tmp/rustup.sh && chmod +x /tmp/rustup.sh && /tmp/rustup.sh --yes
# -----------------
- name: "add nginx stable"
sudo: yes
apt_repository: repo='ppa:nginx/stable'
- name: "install nginx"
sudo: yes
apt: name=nginx
- name: "install modified misaka"
sudo: yes
shell: cd {{home_dir}}/libs/misaka; python setup.py install
- name: "install django-registration"
sudo: yes
shell: cd {{home_dir}}/libs/django-registration; python setup.py install
- name: "create postgres user"
postgresql_user: name={{user}} role_attr_flags=SUPERUSER
sudo_user: postgres
sudo: yes
- name: "create postgres user root"
postgresql_user: name=root role_attr_flags=SUPERUSER
sudo_user: postgres
sudo: yes
- name: "create algospot database"
postgresql_db: name=algospot
sudo: yes
sudo_user: postgres
- name: "add permission for root (used for celeryd)"
postgresql_privs: database=algospot privs=ALL type=database role=root
sudo: yes
sudo_user: postgres
- name: "django syncdb"
django_manage: command=syncdb app_path={{django_dir}}
- name: "load base data (must come before migrate!)"
django_manage: command=loaddata app_path={{django_dir}} fixtures=base/fixtures/group_fixtures.json
- name: "migrate base first"
shell: ./manage.py migrate base chdir={{django_dir}}
- name: "django migrate"
django_manage: command=migrate app_path={{django_dir}}
- name: "load superuser"
django_manage: command=loaddata app_path={{django_dir}} fixtures=base/fixtures/superuser_fixtures.json
- name: "load all remaining fixutres"
django_manage: command=loaddata app_path={{django_dir}} fixtures={{item}}
with_items:
- base/fixtures/guardian_fixtures.json
- forum/fixtures/fixtures.json
- judge/fixtures/fixtures.json
- wiki/fixtures/fixtures.json
ignore_errors: True # there might be a duplicated load
- name: "collectstatic"
django_manage: command=collectstatic app_path={{django_dir}}
- name: "make media directory/whoosh index directory"
sudo: yes
file: path={{item}} owner=www-data group=www-data state=directory
with_items:
- /www-media
- /www-media/judge-attachments
- /whoosh_index
- /var/log/dogslow
- name: "make user part of www-data group (dev only)"
sudo: yes
user: name={{user}} groups=www-data append=yes
- name: "change permission for dogslow logging dir"
shell: chmod go+rwx /var/log/dogslow
sudo: yes
- name: "make judge file directory"
file: path={{item}} state=directory owner=www-data group=www-data
sudo: yes
sudo_user: www-data
with_items:
- /www-media/judge-attachments/997880217dc5432e5425aca9fab8c317
- /www-media/judge-attachments/67dfd95b87cff6ac5af6af76fc18f38e
- /www-media/judge-attachments/232c7247113c383f420354144212679d
- /www-media/judge-attachments/62684055ea23fd739ee1071724794592
- name: "copy judging data for example problem"
copy: src=../dev_data/plus.in dest=/www-media/judge-attachments/997880217dc5432e5425aca9fab8c317/plus.in owner=www-data
sudo: yes
- name: "copy judging data for example problem (output)"
copy: src=../dev_data/plus.out dest=/www-media/judge-attachments/67dfd95b87cff6ac5af6af76fc18f38e/plus.out owner=www-data
sudo: yes
- name: "copy judging data for example problem"
copy: src=../dev_data/helloworld.in dest=/www-media/judge-attachments/232c7247113c383f420354144212679d/helloworld.in owner=www-data
sudo: yes
- name: "copy judging data for example problem (output)"
copy: src=../dev_data/helloworld.out dest=/www-media/judge-attachments/62684055ea23fd739ee1071724794592/helloworld.out owner=www-data
sudo: yes
- name: "include everyone in 'everyone' group"
shell: ./manage.py include_everyone chdir={{django_dir}}
- name: "patch psql table for guardian"
shell: psql algospot < base/queries/patch_psql_table.sql chdir={{django_dir}}
- name: "copy psql configurations (so root can access database, needed for celeryd)"
copy: src={{item}} dest=/etc/postgresql/9.3/main/ backup=yes
sudo: yes
with_items:
- ../configs/{{config_name}}/pg_hba.conf
- ../configs/{{config_name}}/pg_ident.conf
- name: "copy celery runner"
copy: src=../configs/{{config_name}}/celeryd_initd dest=/etc/init.d/celeryd
sudo: yes
- name: "change permission for celery runner"
shell: chmod go+rwx /etc/init.d/celeryd
sudo: yes
- name: "copy celery config"
copy: src=../configs/{{config_name}}/celeryd_config dest=/etc/default/celeryd
sudo: yes
- name: "make celery directories"
file: path={{item}} state=directory
with_items:
- /var/run/celery
- /var/log/celery
sudo: yes
- name: "install celeryd service"
shell: update-rc.d celeryd defaults 99 01
sudo: yes
- name: "create runner account for sandboxing"
user: name=runner
sudo: yes
- name: "copy nginx conf"
copy: src=../configs/{{config_name}}/nginx dest=/etc/nginx/sites-available/default backup=yes
sudo: yes
- name: "make uwsgi conf dir"
file: path=/etc/uwsgi/apps-enabled state=directory
sudo: yes
- name: "copy uwsgi conf"
copy: src=../configs/{{config_name}}/uwsgi.ini dest=/etc/uwsgi/apps-enabled backup=yes
sudo: yes
- name: "copy uwsgi upstart conf"
copy: src=../configs/{{config_name}}/uwsgi.conf dest=/etc/init/ backup=yes
sudo: yes
- name: "make /var/www"
file: path=/var/www state=directory
sudo: yes
- name: "make /var/www open for www-data"
shell: chmod go+rwx /var/www
sudo: yes
- name: "install linux-image-extra (needed for aufs)"
shell: apt-get install -y linux-image-extra-`uname -r`
sudo: yes
- name: "register cron entry for update_index"
cron: name="update search index" minute="0,30" job="cd {{django_dir}}; ./manage.py update_index" user="www-data" cron_file="update-index-job"
sudo: yes
# runner user 를 위해 .NET Core 필수 패키지를 미리 다운로드 한다.
# 이 단계가 없으면 서밋마다 패키지를 다운로드해서 매우 느리게 된다. c#.py 파일 참고.
# 현재까지는 임시로 프로젝트를 생성하는 우회 방법밖에 없다. (1.0.0-preview2-sdk)
# 개선되면 반영하기 - https://github.com/dotnet/cli/issues/3692
- name: "download .net core packages to prevent slow judge"
sudo: yes
shell: export NUGET_PACKAGES=/var/runner-nuget-packages && mkdir -p $NUGET_PACKAGES && cd `mktemp -d` && dotnet new && chown -R runner:runner $NUGET_PACKAGES