Skip to content

Commit

Permalink
Réorganisation des tâches du rôle app
Browse files Browse the repository at this point in the history
  • Loading branch information
Situphen committed Apr 11, 2021
1 parent 5316fb1 commit 01f2d86
Showing 1 changed file with 92 additions and 96 deletions.
188 changes: 92 additions & 96 deletions roles/app/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Basic dependencies installation

- name: install app dependencies
become: true
apt:
Expand All @@ -20,6 +22,8 @@
tags:
- bootstrap

# User, directories, files and symlink creation

- name: should have a {{ appuser }} user
become: true
user:
Expand Down Expand Up @@ -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 }}"
Expand All @@ -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 }}"
Expand All @@ -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
Expand All @@ -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 }}"
Expand All @@ -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
Expand Down Expand Up @@ -292,24 +283,44 @@
- 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
name: "{{ item }}"
enabled: yes
daemon_reload: yes
with_items:
- zmd.service
- zds.service
- zds.socket
- zds-es-index.timer
- zds-watchdog.service
tags:
- bootstrap

- name: reload zds
- name: reload zmarkdown and zds
systemd:
name: zds
name: "{{ item }}"
state: reloaded
with_items:
- zmd
- zds
tags:
- bootstrap
- upgrade
Expand All @@ -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/
Expand All @@ -350,6 +343,9 @@
until: "'zmd is running' in this.content"
tags:
- bootstrap
- upgrade

# End of maintenance, if needed

- name: remove maintenance symlink
file:
Expand Down

0 comments on commit 01f2d86

Please sign in to comment.