This repository has been archived by the owner on Mar 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
deploy.yml
70 lines (56 loc) · 2.18 KB
/
deploy.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
---
- hosts: all
vars_files:
- vars.yml
# We want the vault to be loaded conditionally, so we do if via the
# `--extra-args` command line flag
# - @vault.yml
gather_facts: true
become: true
become_user: "{{ project_name }}"
tasks:
- name: generate an id for the image
shell: date +%Y%m%d%H%M%S
register: image_id
- name: Pull sources from the repository.
git:
repo: "{{ project_repo }}"
dest: "{{ project_root }}/code/"
version: "{{ branch }}"
accept_hostkey: true
notify:
- restart web frontend
- name: Upload configuration.
template: src=webapp_settings/{{ nickname }}.py dest={{ project_root }}/code/{{ app_name }}/settings/local.py
notify:
- restart web frontend
- name: Upgrade the virtualenv.
pip:
requirements: "{{ project_root }}/code/requirements/production.txt"
virtualenv: "{{ project_root }}/env"
virtualenv_python: "python3"
- name: Install front-end dependencies.
npm: path={{ project_root }}/code
- name: Migrate Django database.
shell: "{{ project_root }}/env/bin/python {{ project_root }}/code/manage.py migrate --noinput"
- name: Generate Django media.
command: "./env/bin/python code/manage.py collectstatic --noinput --clear"
args:
chdir: "{{ project_root }}"
when: not packer
# If we are running via packer (i.e. on an AWS instance with the right permissions) then we can sync the assets to the S3 bucket
- name: Sync assets to S3 bucket
command: "/usr/local/bin/aws s3 sync --cache-control 'max-age=365000000:immutable' --metadata-directive REPLACE --acl public-read code/polling_stations/static/ s3://pollingstations-assets2/{{ image_id.stdout }}/ --quiet"
args:
chdir: "{{ project_root }}"
when: not packer
- name: Compile all translations from .po files into .mo files
shell: "{{ project_root }}/env/bin/python {{ project_root }}/code/manage.py compilemessages"
when: not packer
- name: Apply Misc Fixes
shell: "{{ project_root }}/env/bin/python {{ project_root }}/code/manage.py misc_fixes"
args:
chdir: "{{ project_root }}/code/"
when: not packer
handlers:
- import_tasks: handlers.yml