forked from OBOFoundry/purl.obolibrary.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
site.yml
77 lines (60 loc) · 2.23 KB
/
site.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
---
# This is an Ansible playbook specifying the instructions for deploying the purl.obolibrary.org site.
- hosts: all
user: ubuntu
become: True
become_method: sudo
gather_facts: True
vars:
mode: production
domain: purl.obolibrary.org
owner: OBOFoundry
repo: purl.obolibrary.org
repo_dir: "/var/www/{{ repo }}"
repo_url: "https://github.com/{{ owner }}/{{ repo }}.git"
cron_job: "cd {{ repo_dir }} && make safe-update"
handlers:
- name: restart apache
service: name=apache2 state=restarted
tasks:
- name: Update apt-get cache
shell: "apt-get update"
- name: Install system-wide packages (not Travis)
when: mode != "travis"
apt: pkg={{ item }} state=present
with_items:
- ntp
- git
- python3
- name: Install system-wide packages (All)
apt: pkg={{ item }} state=present
with_items:
- apache2
- python3-pip
- name: Install PyYAML
pip: name=PyYAML executable=pip3
- name: Install pathlib2 for jsonschema
pip: name=pathlib2 executable=pip3
- name: Install jsonschema
pip: name=jsonschema==3.0.2 executable=pip3
- name: Clone the Git repo
when: mode == "production"
git: repo={{ repo_url }} dest={{ repo_dir }}
- name: Build Apache Config
when: mode == "production"
shell: "cd {{ repo_dir }} && make all"
- name: Immediately update the PURLs
when: mode == "production"
shell: "{{ cron_job }}; exit 0"
- name: Set cron to update PURLs every 10 minutes
when: mode == "production"
cron: name="update PURLs" minute="*/10" job="PATH=/usr/local/bin:$PATH; {{ cron_job }} >> /var/log/obo-purl-cron 2>&1"
- name: Disable default Apache site
command: a2dissite 000-default removes=/etc/apache2/sites-enabled/000-default.conf
notify: restart apache
- name: Make the PURL site available
template: src=etc_apache2_sites-available_site.j2 dest="/etc/apache2/sites-available/{{ repo }}.conf" group=root owner=root force=yes
notify: restart apache
- name: Enable the PURL site
command: "a2ensite {{ repo }}.conf creates=/etc/apache2/sites-enabled/{{ repo }}.conf"
notify: restart apache