From 4761d466968fb85ae38a5f0f109555a3fab5a845 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Wed, 15 Jul 2020 11:32:08 +0200 Subject: [PATCH] :art: Apply Django migrations --- .env_example | 4 ++-- README.md | 2 +- ansible/base.yml | 2 +- ansible/hosts | 2 +- ansible/roles/2-nk20/tasks/main.yml | 4 +++- ansible/roles/5-psql/tasks/main.yml | 14 +++++++++++++- 6 files changed, 21 insertions(+), 7 deletions(-) diff --git a/.env_example b/.env_example index 0bf47c8a..91db0e31 100644 --- a/.env_example +++ b/.env_example @@ -1,4 +1,4 @@ -DJANGO_APP_STAGE=dev +DJANGO_APP_STAGE=prod # Only used in dev mode, change to "postgresql" if you want to use PostgreSQL in dev DJANGO_DEV_STORE_METHOD=sqllite DJANGO_DB_HOST=localhost @@ -13,6 +13,6 @@ NOTE_URL=localhost # Config for mails. Only used in production NOTE_MAIL=notekfet@localhost EMAIL_HOST=smtp.localhost -EMAIL_PORT=443 +EMAIL_PORT=465 EMAIL_USER=notekfet@localhost EMAIL_PASSWORD=CHANGE_ME diff --git a/README.md b/README.md index a334151e..c04c7321 100644 --- a/README.md +++ b/README.md @@ -121,7 +121,7 @@ On supposera pour la suite que vous utilisez Debian/Ubuntu sur un serveur tout n # Le reste n'est utile qu'en production, pour configurer l'envoi des mails NOTE_MAIL=notekfet@localhost EMAIL_HOST=smtp.localhost - EMAIL_PORT=443 + EMAIL_PORT=465 EMAIL_USER=notekfet@localhost EMAIL_PASSWORD=CHANGE_ME diff --git a/ansible/base.yml b/ansible/base.yml index 1212382b..16f7ec1e 100755 --- a/ansible/base.yml +++ b/ansible/base.yml @@ -1,7 +1,7 @@ #!/usr/bin/env ansible-playbook --- -- hosts: dt.adh.crans.org +- hosts: bde-nk20-beta.adh.crans.org roles: - 1-apt-basic - 2-nk20 diff --git a/ansible/hosts b/ansible/hosts index 5bbbdf69..beafcc55 100644 --- a/ansible/hosts +++ b/ansible/hosts @@ -1,5 +1,5 @@ [server] -dt.adh.crans.org +bde-nk20-beta.adh.crans.org [all:vars] ansible_python_interpreter=/usr/bin/python3 diff --git a/ansible/roles/2-nk20/tasks/main.yml b/ansible/roles/2-nk20/tasks/main.yml index b45308a8..0c6d0213 100644 --- a/ansible/roles/2-nk20/tasks/main.yml +++ b/ansible/roles/2-nk20/tasks/main.yml @@ -12,9 +12,11 @@ repo: https://gitlab.crans.org/bde/nk20.git dest: /var/www/note_kfet version: beta-soon - track_submodules: yes force: true +- name: Use default env vars (should be updated!) + command: cp /var/www/note_kfet/.env_example /var/www/note_kfet/.env + - name: Update permissions for note_kfet dir file: path: /var/www/note_kfet diff --git a/ansible/roles/5-psql/tasks/main.yml b/ansible/roles/5-psql/tasks/main.yml index 972164e5..2939b257 100644 --- a/ansible/roles/5-psql/tasks/main.yml +++ b/ansible/roles/5-psql/tasks/main.yml @@ -17,7 +17,7 @@ - name: Create role note postgresql_user: name: note - password: note # Fix it! + password: "CHANGE_ME" become_user: postgres - name: Create NK20 database @@ -25,3 +25,15 @@ name: note_db owner: note become_user: postgres + +- name: Make Django migrations + command: /var/www/note_kfet/env/bin/python manage.py makemigrations + args: + chdir: /var/www/note_kfet + become_user: www-data + +- name: Migrate Django database + command: /var/www/note_kfet/env/bin/python manage.py migrate + args: + chdir: /var/www/note_kfet + become_user: www-data