diff --git a/roles/app/tasks/main.yml b/roles/app/tasks/main.yml index e24e8cb..17898a1 100644 --- a/roles/app/tasks/main.yml +++ b/roles/app/tasks/main.yml @@ -1,3 +1,5 @@ +# Basic dependencies installation + - name: install app dependencies become: true apt: @@ -20,6 +22,8 @@ tags: - bootstrap +# User, directories, files and symlink creation + - name: should have a {{ appuser }} user become: true user: @@ -80,29 +84,6 @@ tags: - bootstrap -- name: install wheel and sqlparse in virtualenv - become: true - become_user: "{{ appuser }}" - pip: - name: - - wheel - - sqlparse - virtualenv: "{{ virtualenv }}" - virtualenv_command: /usr/bin/python3 -m venv - tags: - - bootstrap - -- name: install requirements in virtualenv - become: true - become_user: "{{ appuser }}" - pip: - requirements: "{{ appdir }}/requirements-prod.txt" - virtualenv: "{{ virtualenv }}" - virtualenv_command: /usr/bin/python3 -m venv - tags: - - bootstrap - - upgrade - - name: save version file become: true become_user: "{{ appuser }}" @@ -124,26 +105,6 @@ tags: - bootstrap -- name: create unit files - template: - src: templates/{{ item }}.j2 - dest: "/etc/systemd/system/{{ item }}" - with_items: - - zds.service - - zds.socket - - zds-es-index.service - - zds-es-index.timer - - zds-watchdog.service - tags: - - bootstrap -- name: add zmarkdown unit file - template: - src: zmd.service.j2 - dest: /etc/systemd/system/zmd.service - tags: - - bootstrap - - upgrade - - name: create app config file become: true become_user: "{{ appuser }}" @@ -165,6 +126,55 @@ - bootstrap - upgrade +- name: create webroot + file: + path: "{{ webroot }}" + state: directory + tags: + - bootstrap + +- name: create symlinks in webroot + file: + src: "{{ item.src }}" + dest: "{{ webroot }}/{{ item.dest }}" + state: link + with_items: + - src: "{{ appdir }}/errors" + dest: "errors" + - src: "{{ appdir }}/robots.txt" + dest: "robots.txt" + - src: "{{ datadir }}/media" + dest: "media" + - src: "{{ datadir }}/static" + dest: "static" + tags: + - bootstrap + +# Installation of backend, frontend and zmd dependencies + +- name: install wheel and sqlparse in virtualenv + become: true + become_user: "{{ appuser }}" + pip: + name: + - wheel + - sqlparse + virtualenv: "{{ virtualenv }}" + virtualenv_command: /usr/bin/python3 -m venv + tags: + - bootstrap + +- name: install requirements in virtualenv + become: true + become_user: "{{ appuser }}" + pip: + requirements: "{{ appdir }}/requirements-prod.txt" + virtualenv: "{{ virtualenv }}" + virtualenv_command: /usr/bin/python3 -m venv + tags: + - bootstrap + - upgrade + - include_role: name: common tasks_from: nodejs @@ -180,6 +190,18 @@ - bootstrap - upgrade +- name: install zmarkdown + become: true + become_user: zds + npm: + path: "{{ zmarkdown_dir }}" + production: yes + tags: + - bootstrap + - upgrade + +# Frontend building + - name: build frontend become: true become_user: "{{ appuser }}" @@ -204,39 +226,8 @@ - bootstrap - upgrade -- name: create webroot - file: - path: "{{ webroot }}" - state: directory - tags: - - bootstrap - -- name: create symlinks in webroot - file: - src: "{{ item.src }}" - dest: "{{ webroot }}/{{ item.dest }}" - state: link - with_items: - - src: "{{ appdir }}/errors" - dest: "errors" - - src: "{{ appdir }}/robots.txt" - dest: "robots.txt" - - src: "{{ datadir }}/media" - dest: "media" - - src: "{{ datadir }}/static" - dest: "static" - tags: - - bootstrap - -- name: install zmarkdown - become: true - become_user: zds - npm: - path: "{{ zmarkdown_dir }}" - production: yes - tags: - - bootstrap - - upgrade +# Database migration and cache clearing +# Start of maintenance, if needed - name: check if database migration is needed become: true @@ -292,6 +283,22 @@ - bootstrap - upgrade +# Services and timers + +- name: create services and timers files + template: + src: templates/{{ item }}.j2 + dest: "/etc/systemd/system/{{ item }}" + with_items: + - zmd.service + - zds.service + - zds.socket + - zds-es-index.service + - zds-es-index.timer + - zds-watchdog.service + tags: + - bootstrap + - name: start services and timers systemd: state: started @@ -299,6 +306,7 @@ enabled: yes daemon_reload: yes with_items: + - zmd.service - zds.service - zds.socket - zds-es-index.timer @@ -306,10 +314,13 @@ tags: - bootstrap -- name: reload zds +- name: reload zmarkdown and zds systemd: - name: zds + name: "{{ item }}" state: reloaded + with_items: + - zmd + - zds tags: - bootstrap - upgrade @@ -322,24 +333,6 @@ - bootstrap - upgrade -- name: start zmarkdown service - systemd: - name: zmd - state: started - enabled: yes - daemon_reload: true - tags: - - bootstrap - -- name: reload zmarkdown service - systemd: - name: zmd - state: reloaded - daemon_reload: true - tags: - - bootstrap - - upgrade - - name: ensure that zmarkdown is running uri: url: http://localhost:27272/ @@ -350,6 +343,9 @@ until: "'zmd is running' in this.content" tags: - bootstrap + - upgrade + +# End of maintenance, if needed - name: remove maintenance symlink file: