---

- name: Install packages required by the Django app inside virtualenv
  pip: virtualenv={{ virtualenv_path }} requirements={{ requirements_file }}

- name: Run the Django syncdb command
  django_manage:
    command: syncdb
    app_path: "{{ project_path }}"
    virtualenv: "{{ virtualenv_path }}"
    settings: "{{ django_settings_file }}"
  environment: "{{ django_environment }}"
  when: run_django_syncdb is defined and run_django_syncdb
  tags: django.syncdb

- name: Run Django database migrations
  django_manage:
    command: migrate
    app_path: "{{ project_path }}"
    virtualenv: "{{ virtualenv_path }}"
    settings: "{{ django_settings_file }}"
  environment: "{{ django_environment }}"
  when: run_django_db_migrations is defined and run_django_db_migrations
  tags: django.migrate

- name: Run Django collectstatic
  django_manage:
    command: collectstatic
    app_path: "{{ project_path }}"
    virtualenv: "{{ virtualenv_path }}"
    settings: "{{ django_settings_file }}"
  environment: "{{ django_environment }}"
  when: run_django_collectstatic is defined and run_django_collectstatic
  tags: django.collectstatic

---

- name: Make sure the latest npm is installed
  apt: name={{ item }} state=latest
  with_items:
    - nodejs-legacy
    - npm
  tags:
    - bower
    - packages

- name: Ensure Bower installed
  npm: name=bower global=yes
  tags:
    - bower
    - packages

- debug: msg="Running Bower in {{ project_path }}"
  tags: bower

- name: Run Bower Install
  bower: path={{ project_path }}
  tags: bower

- name: Install packages required by the Django app inside virtualenv
  pip: virtualenv={{ virtualenv_path }} requirements={{ requirements_file }}

- name: Run the Django syncdb command
  django_manage:
    command: syncdb
    app_path: "{{ project_path }}"
    virtualenv: "{{ virtualenv_path }}"
    settings: "{{ django_settings_file }}"
  environment: "{{ django_environment }}"
  when: run_django_syncdb is defined and run_django_syncdb
  tags: django.syncdb

- name: Run Django database migrations
  django_manage:
    command: migrate
    app_path: "{{ project_path }}"
    virtualenv: "{{ virtualenv_path }}"
    settings: "{{ django_settings_file }}"
  environment: "{{ django_environment }}"
  when: run_django_db_migrations is defined and run_django_db_migrations
  tags: django.migrate

- name: Run Django collectstatic
  django_manage:
    command: collectstatic
    app_path: "{{ project_path }}"
    virtualenv: "{{ virtualenv_path }}"
    settings: "{{ django_settings_file }}"
  environment: "{{ django_environment }}"
  when: run_django_collectstatic is defined and run_django_collectstatic
  tags: django.collectstatic

Install Bower dependencies on webservers
Install Bower dependencies on webservers
