|
1 --- |
|
2 - hosts: all |
|
3 tasks: |
|
4 - name: Print some debug information |
|
5 vars: |
|
6 msg: | |
|
7 Module Variables ("vars"): |
|
8 -------------------------------- |
|
9 {{ vars | to_nice_json }} |
|
10 |
|
11 Environment Variables ("environment"): |
|
12 -------------------------------- |
|
13 {{ environment | to_nice_json }} |
|
14 |
|
15 GROUP NAMES Variables ("group_names"): |
|
16 -------------------------------- |
|
17 {{ group_names | to_nice_json }} |
|
18 |
|
19 GROUPS Variables ("groups"): |
|
20 -------------------------------- |
|
21 {{ groups | to_nice_json }} |
|
22 |
|
23 HOST Variables ("hostvars"): |
|
24 -------------------------------- |
|
25 {{ hostvars | to_nice_json }} |
|
26 |
|
27 debug: |
|
28 msg: "{{ msg.split('\n') }}" |
|
29 tags: debug_info |
|
30 # |
|
31 # Localhost actions |
|
32 # |
|
33 - hosts: localhost |
|
34 vars_files: |
|
35 - "{{playbook_dir}}/deploy_vars.yml" |
|
36 vars: |
|
37 isso_build_dir: "{{playbook_dir}}/build/tmp/isso" |
|
38 dashboard_build_dir: "{{playbook_dir}}/build/tmp/dashboard" |
|
39 clientjs_dir: "{{playbook_dir}}/build/tmp/dashboard/clientjs" |
|
40 tasks: |
|
41 |
|
42 - name: mkdir build folder |
|
43 file: |
|
44 path: "{{playbook_dir}}/build/tmp" |
|
45 state: directory |
|
46 |
|
47 - name: clear dashboard checkout dir if exists |
|
48 file: |
|
49 path: "{{dashboard_build_dir}}" |
|
50 state: absent |
|
51 |
|
52 - name: checkout dashboard |
|
53 hg: |
|
54 repo: "{{dashboard_repo}}" |
|
55 version: "{{dashboard_version}}" |
|
56 force: yes |
|
57 dest: "{{dashboard_build_dir}}" |
|
58 |
|
59 - name: clear isso checkout dir if exists |
|
60 file: |
|
61 path: "{{isso_build_dir}}" |
|
62 state: absent |
|
63 |
|
64 - name: set discussions repo url |
|
65 set_fact: |
|
66 discussion_repo_url: "{{lookup('file', dashboard_build_dir+'/server/isso/requirements.txt').split('\n')[1]}}" |
|
67 |
|
68 - name: check discussions repo url |
|
69 fail: msg="discussions repo specification in wrong format." |
|
70 when: discussion_repo_url is not match("^\#-e git\+.+@[\w\-]*\#egg\=isso$") |
|
71 |
|
72 - name: get discussion chechout url and version |
|
73 set_fact: |
|
74 discussion_repo: "{{discussion_repo_url | regex_replace('^\\#-e git\\+(.+)@[\\w\\-]*\\#egg\\=isso$', '\\1')}}" |
|
75 discussion_version: "{{discussion_repo_url | regex_replace('^\\#-e git\\+.+@([\\w\\-]*)\\#egg\\=isso$', '\\1')}}" |
|
76 |
|
77 - name: checkout isso |
|
78 git: |
|
79 repo: "{{discussion_repo}}" |
|
80 version: "{{discussion_version}}" |
|
81 force: yes |
|
82 dest: "{{isso_build_dir}}" |
|
83 |
|
84 - name: call npm install |
|
85 command: npm install chdir="{{isso_build_dir}}" |
|
86 |
|
87 - name: call make init |
|
88 make: |
|
89 chdir: "{{isso_build_dir}}" |
|
90 target: init |
|
91 |
|
92 - name: call make js |
|
93 make: |
|
94 chdir: "{{isso_build_dir}}" |
|
95 target: js |
|
96 |
|
97 - name: make isso package |
|
98 command: python setup.py sdist chdir="{{isso_build_dir}}" |
|
99 |
|
100 # |
|
101 # all actions |
|
102 # |
|
103 - hosts: remote_discussions |
|
104 vars_files: |
|
105 - "{{playbook_dir}}/deploy_vars.yml" |
|
106 vars: |
|
107 isso_build_dir: "{{playbook_dir}}/build/tmp/isso" |
|
108 dashboard_build_dir: "{{playbook_dir}}/build/tmp/dashboard" |
|
109 clientjs_dir: "{{playbook_dir}}/build/tmp/dashboard/clientjs" |
|
110 tasks: |
|
111 |
|
112 - name: get isso version |
|
113 local_action: command python setup.py -V chdir="{{isso_build_dir}}" |
|
114 register: isso_version |
|
115 |
|
116 - name: get discussion package version |
|
117 set_fact: |
|
118 discussions_pkg_version: "{{isso_version.stdout}}" |
|
119 |
|
120 # |
|
121 # Localhost actions |
|
122 # |
|
123 - hosts: localhost |
|
124 vars_files: |
|
125 - "{{playbook_dir}}/deploy_vars.yml" |
|
126 vars: |
|
127 isso_build_dir: "{{playbook_dir}}/build/tmp/isso" |
|
128 dashboard_build_dir: "{{playbook_dir}}/build/tmp/dashboard" |
|
129 clientjs_dir: "{{playbook_dir}}/build/tmp/dashboard/clientjs" |
|
130 tasks: |
|
131 |
|
132 # build client js |
|
133 - name: remove build |
|
134 file: path="{{clientjs_dir}}/packages/{{item}}" state=absent |
|
135 with_items: |
|
136 - annotation-dashboard-explorunivers/build |
|
137 - dashboard-components/lib |
|
138 |
|
139 - name: clientjs npm install |
|
140 command: npm install |
|
141 args: |
|
142 chdir: "{{clientjs_dir}}" |
|
143 |
|
144 - name: clientjs lerna bootstrap |
|
145 command: npx lerna bootstrap |
|
146 args: |
|
147 chdir: "{{clientjs_dir}}" |
|
148 |
|
149 - name: clientjs dashboard-components build |
|
150 command: npm run build |
|
151 args: |
|
152 chdir: "{{clientjs_dir}}/packages/dashboard-components" |
|
153 |
|
154 - name: clientjs annotation-dashboard-explorunivers build |
|
155 command: npm run build |
|
156 args: |
|
157 chdir: "{{clientjs_dir}}/packages/annotation-dashboard-explorunivers" |
|
158 environment: |
|
159 REACT_APP_API_URL: "{{annotations_api_url}}/annotations" |
|
160 REACT_APP_VIA_BASE_URL: "{{via_base_url}}" |
|
161 REACT_APP_DISCUSSION_URL: "{{discussions_url}}/" |
|
162 |
|
163 # |
|
164 # Static server |
|
165 # |
|
166 - hosts: remote_static |
|
167 become: yes |
|
168 vars_files: |
|
169 - "{{playbook_dir}}/deploy_vars.yml" |
|
170 vars: |
|
171 isso_build_dir: "{{playbook_dir}}/build/tmp/isso" |
|
172 dashboard_build_dir: "{{playbook_dir}}/build/tmp/dashboard" |
|
173 clientjs_dir: "{{playbook_dir}}/build/tmp/dashboard/clientjs" |
|
174 tasks: |
|
175 |
|
176 - name: create dest static directory content |
|
177 file: |
|
178 path: "{{remote_static_path}}" |
|
179 state: directory |
|
180 owner: "{{static_http_user}}" |
|
181 group: "{{static_http_group}}" |
|
182 |
|
183 - name: remove dest static directory content |
|
184 command: /bin/rm -fr "{{remote_static_path}}/*" warn=False |
|
185 when: remote_static_path != "" |
|
186 |
|
187 # TODO : set dashboard name in setting |
|
188 - name: transfert static dist to remote |
|
189 copy: |
|
190 src: "{{clientjs_dir}}/{{dashboard_name}}/build/" |
|
191 dest: "{{remote_static_path}}/" |
|
192 owner: "{{static_http_user}}" |
|
193 group: "{{static_http_group}}" |
|
194 notify: |
|
195 - restart static nginx |
|
196 |
|
197 - name: create refresh nginx config |
|
198 template: |
|
199 src: netrights.iri-research.org.j2 |
|
200 dest: "{{static_nginx_config | default('/etc/nginx/site-available/'+static_server_name, true)}}" |
|
201 notify: |
|
202 - restart static nginx |
|
203 |
|
204 handlers: |
|
205 - name: restart static nginx |
|
206 service: |
|
207 name: "{{static_http_service}}" |
|
208 state: restarted |
|
209 ignore_errors: yes |
|
210 |
|
211 # |
|
212 # Annotations and discussion servers |
|
213 # |
|
214 - hosts: remote_annotations_api:remote_discussions |
|
215 become: yes |
|
216 vars_files: |
|
217 - "{{playbook_dir}}/deploy_vars.yml" |
|
218 vars: |
|
219 isso_build_dir: "{{playbook_dir}}/build/tmp/isso" |
|
220 clientjs_dir: "{{playbook_dir}}/../clientjs" |
|
221 annotation_api_dir: "{{playbook_dir}}/../server/sbin" |
|
222 tasks: |
|
223 |
|
224 - name: add iri group |
|
225 group: |
|
226 name: iri |
|
227 |
|
228 - name: add uwsgi user |
|
229 user: |
|
230 name: uwsgi |
|
231 group: iri |
|
232 home: /var/www |
|
233 create_home: no |
|
234 system: yes |
|
235 |
|
236 - name: create log dir |
|
237 file: |
|
238 path: "{{log_base_path}}" |
|
239 state: directory |
|
240 owner: uwsgi |
|
241 group: iri |
|
242 mode: 0755 |
|
243 |
|
244 # |
|
245 # Annotations server |
|
246 # |
|
247 - hosts: remote_annotations_api |
|
248 become: yes |
|
249 vars_files: |
|
250 - "{{playbook_dir}}/deploy_vars.yml" |
|
251 vars: |
|
252 isso_build_dir: "{{playbook_dir}}/build/tmp/isso" |
|
253 clientjs_dir: "{{playbook_dir}}/../clientjs" |
|
254 annotation_api_dir: "{{playbook_dir}}/../server/sbin" |
|
255 tasks: |
|
256 |
|
257 - name: create config dir |
|
258 file: |
|
259 path: "{{annotations_api_config_base}}" |
|
260 state: directory |
|
261 owner: uwsgi |
|
262 group: iri |
|
263 mode: 0755 |
|
264 |
|
265 - name: register annotation api virtualenv stats |
|
266 stat: path="{{annotations_api_venv}}" |
|
267 register: annotations_api_venv_stats |
|
268 |
|
269 - name: copy annotation api requirement file |
|
270 copy: |
|
271 src: "{{annotation_api_dir}}/requirements.txt" |
|
272 dest: "{{annotations_api_config_base}}/annotation_api_requirements.txt" |
|
273 register: copy_annotation_api_requirements |
|
274 |
|
275 - name: remove annotation api venv |
|
276 file: |
|
277 path: "{{annotations_api_venv}}" |
|
278 state: absent |
|
279 when: copy_annotation_api_requirements.changed |
|
280 |
|
281 - name: create annotations api virtualenv |
|
282 pip: |
|
283 virtualenv_command: /usr/bin/python3 -m venv |
|
284 virtualenv: "{{annotations_api_venv}}" |
|
285 requirements: "{{annotations_api_config_base}}/annotation_api_requirements.txt" |
|
286 when: copy_annotation_api_requirements.changed or (not annotations_api_venv_stats.stat.exists) |
|
287 notify: restart annotations api service |
|
288 |
|
289 - name: copy annotations api module |
|
290 copy: |
|
291 src: "{{annotation_api_dir}}/hypothesis_proxy.py" |
|
292 dest: "{{annotations_api_venv}}/bin/" |
|
293 notify: restart annotations api service |
|
294 |
|
295 - name: copy annotation api config |
|
296 template: |
|
297 src: "annotation_api_configuration.ini.j2" |
|
298 dest: "{{annotations_api_config_base}}/annotation_api_configuration.ini" |
|
299 notify: restart annotations api service |
|
300 |
|
301 - name: copy annotations api uwsgi config |
|
302 template: |
|
303 src: "dashboard-nextleap-annotations.yml.j2" |
|
304 dest: "{{annotations_api_config_base}}/uwsgi-dashboard-annotations.yml" |
|
305 notify: restart annotations api service |
|
306 |
|
307 - name: copy annotations api supervisor config |
|
308 template: |
|
309 src: "dashboard-nextleap-annotations.ini.j2" |
|
310 dest: "{{annotations_api_supervisor_conf_path}}/{{annotations_api_service}}.ini" |
|
311 notify: restart annotations api service |
|
312 |
|
313 handlers: |
|
314 - name: reload annotations api service supervisorctl |
|
315 listen: "restart annotations api service" |
|
316 supervisorctl: |
|
317 name: "{{annotations_api_service}}" |
|
318 state: present |
|
319 ignore_errors: yes |
|
320 |
|
321 - name: restart annotations api service supervisorctl |
|
322 listen: "restart annotations api service" |
|
323 supervisorctl: |
|
324 name: "{{annotations_api_service}}" |
|
325 state: restarted |
|
326 ignore_errors: yes |
|
327 |
|
328 # |
|
329 # Discussion servers |
|
330 # |
|
331 - hosts: remote_discussions |
|
332 |
|
333 become: yes |
|
334 |
|
335 vars_files: |
|
336 - "{{playbook_dir}}/deploy_vars.yml" |
|
337 |
|
338 vars: |
|
339 isso_build_dir: "{{playbook_dir}}/build/tmp/isso" |
|
340 dashboard_build_dir: "{{playbook_dir}}/build/tmp/dashboard" |
|
341 clientjs_dir: "{{playbook_dir}}/build/tmp/dashboard/clientjs" |
|
342 dicussions_pkg_archive: "isso-{{discussions_pkg_version}}.tar.gz" |
|
343 |
|
344 tasks: |
|
345 |
|
346 - name: create discussion build tmp dir |
|
347 tempfile: |
|
348 state: directory |
|
349 register: discussions_build_tmp_dir |
|
350 |
|
351 - name: create config dir |
|
352 file: |
|
353 path: "{{discussions_config_base}}" |
|
354 state: directory |
|
355 owner: uwsgi |
|
356 group: iri |
|
357 mode: 0755 |
|
358 |
|
359 - name: register discussion virtualenv stats |
|
360 stat: path="{{discussions_venv}}" |
|
361 register: discussions_venv_stats |
|
362 |
|
363 - name: copy discussion requirement file |
|
364 copy: |
|
365 src: "{{dashboard_build_dir}}/server/isso/requirements.txt" |
|
366 dest: "{{discussions_config_base}}/discussions_requirements.txt" |
|
367 register: copy_discussions_requirements |
|
368 |
|
369 - name: remove annotation api venv |
|
370 file: |
|
371 path: "{{discussions_venv}}" |
|
372 state: absent |
|
373 when: copy_discussions_requirements.changed |
|
374 |
|
375 - name: copy discussions build |
|
376 copy: |
|
377 src: "{{isso_build_dir}}/dist/{{dicussions_pkg_archive}}" |
|
378 dest: "{{discussions_build_tmp_dir.path}}" |
|
379 when: copy_discussions_requirements.changed or (not discussions_venv_stats.stat.exists) |
|
380 |
|
381 - name: create discussions virtualenv |
|
382 pip: |
|
383 virtualenv_command: /usr/bin/python3 -m venv |
|
384 virtualenv: "{{discussions_venv}}" |
|
385 requirements: "{{discussions_config_base}}/discussions_requirements.txt" |
|
386 when: copy_discussions_requirements.changed or (not discussions_venv_stats.stat.exists) |
|
387 notify: restart discussions service |
|
388 |
|
389 - name: install discussions pkg in venv |
|
390 pip: |
|
391 virtualenv: "{{discussions_venv}}" |
|
392 name: "file://{{discussions_build_tmp_dir.path}}/{{dicussions_pkg_archive}}" |
|
393 when: copy_discussions_requirements.changed or (not discussions_venv_stats.stat.exists) |
|
394 notify: restart discussions service |
|
395 |
|
396 - name: copy discussions uwsgi config |
|
397 template: |
|
398 src: "dashboard-nextleap-discussions.yml.j2" |
|
399 dest: "{{annotations_api_config_base}}/uwsgi-dashboard-discussions.yml" |
|
400 notify: restart discussions service |
|
401 |
|
402 - name: copy discussions isso config |
|
403 template: |
|
404 src: "dashboard-nextleap-discussions-isso.cfg.j2" |
|
405 dest: "{{annotations_api_config_base}}/dashboard-nextleap-discussions-isso.cfg" |
|
406 notify: restart discussions service |
|
407 |
|
408 - name: copy discussions supervisor config |
|
409 template: |
|
410 src: "dashboard-nextleap-discussions.ini.j2" |
|
411 dest: "{{discussions_supervisor_conf_path}}/{{discussions_service}}.ini" |
|
412 notify: restart discussions service |
|
413 |
|
414 - name: create discussions data folder |
|
415 file: |
|
416 path: "{{discussions_db_dir}}" |
|
417 state: directory |
|
418 owner: uwsgi |
|
419 group: iri |
|
420 mode: 0755 |
|
421 |
|
422 post_tasks: |
|
423 - name: clean discussions build temp dir |
|
424 file: |
|
425 path: "{{discussions_build_tmp_dir.path}}" |
|
426 state: absent |
|
427 |
|
428 handlers: |
|
429 |
|
430 - name: reload discussions service supervisorctl |
|
431 listen: "restart discussions service" |
|
432 supervisorctl: |
|
433 name: "{{discussions_service}}" |
|
434 state: present |
|
435 ignore_errors: yes |
|
436 |
|
437 - name: restart discussions service supervisorctl |
|
438 listen: "restart discussions service" |
|
439 supervisorctl: |
|
440 name: "{{discussions_service}}" |
|
441 state: restarted |
|
442 ignore_errors: yes |