application.yaml 2.81 KB
Newer Older
jaywink's avatar
jaywink committed
1 2 3 4 5 6
---
- name: Make sure home directory is owned by user
  file: path=/home/{{ socialhome_os_user }}/socialhome owner="{{ socialhome_os_user }}" group="{{ socialhome_os_user }}" recurse=yes state=directory
- name: Make sure venv directory is owned by user
  file: path=/home/{{ socialhome_os_user }}/venv owner="{{ socialhome_os_user }}" group="{{ socialhome_os_user }}" recurse=yes state=directory
- name: Get latest application code
7
  git: accept_hostkey=yes dest=/home/{{ socialhome_os_user }}/socialhome repo="{{ socialhome_repo }}" force=yes version="{{ socialhome_repo_version }}"
jaywink's avatar
jaywink committed
8 9
  become_user: "{{ socialhome_os_user }}"
  notify:
jaywink's avatar
jaywink committed
10
    - restart circus
11

jaywink's avatar
jaywink committed
12 13
- name: Stop socialhome Circus
  service: name="{{ socialhome_domain }}-circus" state=stopped
14
  notify:
jaywink's avatar
jaywink committed
15
    - restart circus
jaywink's avatar
jaywink committed
16
- name: Install app OS requirements
17
  shell: chdir=/home/{{ socialhome_os_user }}/socialhome/ executable=/bin/bash ./install_ubuntu_dependencies.sh install
jaywink's avatar
jaywink committed
18
  notify:
jaywink's avatar
jaywink committed
19
    - restart circus
jaywink's avatar
jaywink committed
20 21 22

- name: Sync app requirements
  command: chdir=/home/{{ socialhome_os_user }}/socialhome /home/{{ socialhome_os_user }}/venv/bin/pip-sync
jaywink's avatar
jaywink committed
23 24
  become_user: "{{ socialhome_os_user }}"
  notify:
jaywink's avatar
jaywink committed
25
    - restart circus
jaywink's avatar
jaywink committed
26

jaywink's avatar
jaywink committed
27
- name: Create env file
jaywink's avatar
jaywink committed
28
  template: dest=/home/{{ socialhome_os_user }}/socialhome/.env src=env mode=0600
jaywink's avatar
jaywink committed
29 30
  become_user: "{{ socialhome_os_user }}"
  notify:
jaywink's avatar
jaywink committed
31
    - restart circus
jaywink's avatar
jaywink committed
32
- name: Migrate db
33
  django_manage: app_path=/home/{{ socialhome_os_user }}/socialhome command="migrate --noinput" virtualenv=/home/{{ socialhome_os_user }}/venv
jaywink's avatar
jaywink committed
34 35
  become_user: "{{ socialhome_os_user }}"
  notify:
jaywink's avatar
jaywink committed
36
    - restart circus
jaywink's avatar
jaywink committed
37

38 39 40 41 42 43 44 45 46
# Search index if first time
- name: Check for existing search index
  stat: path=/home/{{ socialhome_os_user }}/socialhome/var/whoosh
  register: _whoosh
- name: Create initial search index
  django_manage: app_path=/home/{{ socialhome_os_user }}/socialhome command="rebuild_index --noinput" virtualenv=/home/{{ socialhome_os_user }}/venv
  become_user: "{{ socialhome_os_user }}"
  when: not _whoosh.stat.exists

jaywink's avatar
jaywink committed
47
# Web stuff
48 49 50 51 52
- name: Do NPM install for root package json
  npm: path=/home/{{ socialhome_os_user }}/socialhome state=present
  become_user: "{{ socialhome_os_user }}"

- name: Do NPM install for frontend
jaywink's avatar
jaywink committed
53
  npm: path=/home/{{ socialhome_os_user }}/socialhome state=present
jaywink's avatar
jaywink committed
54
  become_user: "{{ socialhome_os_user }}"
jaywink's avatar
jaywink committed
55

jaywink's avatar
jaywink committed
56
- name: Do bowering
jaywink's avatar
jaywink committed
57
  bower: path=/home/{{ socialhome_os_user }}/socialhome state=latest relative_execpath=node_modules/.bin
jaywink's avatar
jaywink committed
58
  become_user: "{{ socialhome_os_user }}"
jaywink's avatar
jaywink committed
59 60

- name: Webpack
jaywink's avatar
jaywink committed
61
  command: chdir=/home/{{ socialhome_os_user }}/socialhome npm run build
jaywink's avatar
jaywink committed
62 63
  become_user: "{{ socialhome_os_user }}"

jaywink's avatar
jaywink committed
64
- name: Collect statics
65
  django_manage: app_path=/home/{{ socialhome_os_user }}/socialhome command="collectstatic --no-input" virtualenv=/home/{{ socialhome_os_user }}/venv
jaywink's avatar
jaywink committed
66
  become_user: "{{ socialhome_os_user }}"
jaywink's avatar
jaywink committed
67
  notify:
jaywink's avatar
jaywink committed
68
    - restart circus