Skip to content

Commit

Permalink
Merge pull request #6 from caktus/collectstatic-as-handler
Browse files Browse the repository at this point in the history
Collectstatic as handler
  • Loading branch information
jbradberry authored Jul 21, 2017
2 parents 65a7167 + 917d814 commit 700de07
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 19 deletions.
8 changes: 8 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ Tequila-django

Changes

v 0.9.1 on July 20, 2017
------------------------

* Convert the collectstatic task into a handler. This is needed so
that it happens after the ``npm run build`` step, so that the files
generated from that are included.


v 0.9.0 on July 18, 2017
------------------------

Expand Down
10 changes: 9 additions & 1 deletion handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,12 @@
become_user: "{{ project_user }}"
vars:
ansible_ssh_pipelining: true
when: package_json.stat.exists == True and build_script.stdout != ""

- name: collectstatic
django_manage:
command: collectstatic
app_path: "{{ source_dir }}"
virtualenv: "{{ venv_dir }}"
become_user: "{{ project_user }}"
vars:
ansible_ssh_pipelining: true
35 changes: 17 additions & 18 deletions tasks/web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,11 @@

# TODO: let connections to 8000 through the firewall if we are load-balancing.

- name: collectstatic
django_manage: >
command=collectstatic
app_path={{ source_dir }}
virtualenv={{ venv_dir }}
become_user: "{{ project_user }}"
vars:
ansible_ssh_pipelining: true

- name: migrate
django_manage: >
command=migrate
app_path={{ source_dir }}
virtualenv={{ venv_dir }}
django_manage:
command: migrate
app_path: "{{ source_dir }}"
virtualenv: "{{ venv_dir }}"
become_user: "{{ project_user }}"
vars:
ansible_ssh_pipelining: true
Expand All @@ -50,12 +41,20 @@
group={{ project_name }}
mode=700

- name: change ownership of node modules
# Note: we want the npm build and collectstatic steps to happen at the
# very end of the roles section for the current playbook, so that
# they'll still happen in the order needed even if the playbook has a
# 3rd-party role after tequila-django, e.g. geerlingguy/nodejs. Thus,
# they are moved out into handlers.

- name: trigger build of npm artifacts
command: /bin/true
notify: chown node_modules
notify:
- chown node_modules
- npm run build
when: package_json.stat.exists == True and build_script.stdout != ""

- name: rebuild node modules
- name: trigger collectstatic
command: /bin/true
notify: npm run build
when: package_json.stat.exists == True and build_script.stdout != ""
notify:
- collectstatic

0 comments on commit 700de07

Please sign in to comment.