From dda90628f83517bf224aa9a4d0c1fd3cb97bb360 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Wed, 24 Mar 2021 16:55:17 +0100 Subject: [PATCH] [constellation] Run manage.py commands separately according to front mode Signed-off-by: Yohann D'ANELLO --- roles/constellation-front/tasks/main.yml | 31 +++++++++++++++++++++++- roles/constellation/tasks/main.yml | 10 +++++--- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/roles/constellation-front/tasks/main.yml b/roles/constellation-front/tasks/main.yml index b7001e03..96d0b5d4 100644 --- a/roles/constellation-front/tasks/main.yml +++ b/roles/constellation-front/tasks/main.yml @@ -5,7 +5,7 @@ update_cache: true name: - python3-django-crispy-forms - python3-django-filters + - python3-django-filters - python3-djangorestframework - python3-django-tables2 - python3-docutils @@ -48,7 +48,36 @@ ignore_errors: "{{ ansible_check_mode }}" notify: Reload uWSGI +# In the future, migrations will be included in the repository. +- name: Make Django migrations + django_manage: + command: makemigrations + project_path: "/var/local/constellation" + notify: Reload uWSGI + +- name: Migrate database + django_manage: + command: migrate + project_path: "/var/local/constellation" + notify: Reload uWSGI + +- name: Load initial data + django_manage: + command: loaddata initial + project_path: "/var/local/constellation" + notify: Reload uWSGI + +- name: Create static files directory + file: + path: /var/local/constellation/static + state: directory + mode: '2775' + owner: "www-data" + group: "{{ constellation.group }}" + recurse: true + - name: Collect static files django_manage: command: collectstatic project_path: "/var/local/constellation" + notify: Reload uWSGI diff --git a/roles/constellation/tasks/main.yml b/roles/constellation/tasks/main.yml index 8902ad42..403e351d 100644 --- a/roles/constellation/tasks/main.yml +++ b/roles/constellation/tasks/main.yml @@ -62,22 +62,26 @@ group: "{{ constellation.settings_local_group }}" - name: Compile messages + when: not constellation.front django_manage: command: compilemessages project_path: "/var/local/constellation" # In the future, migrations will be included in the repository. -- name: Make Django migrations +- name: Make Django migrations (non-front app) + when: not constellation.front django_manage: command: makemigrations project_path: "/var/local/constellation" -- name: Migrate database +- name: Migrate database (non-front app) + when: not constellation.front django_manage: command: migrate project_path: "/var/local/constellation" -- name: Load initial data +- name: Load initial data (non-front app) + when: not constellation.front django_manage: command: loaddata initial project_path: "/var/local/constellation"