From 39fd3a247166833ed24dc5cfe774b82e8a1c9324 Mon Sep 17 00:00:00 2001 From: Pierre-antoine Comby Date: Fri, 30 Oct 2020 20:54:41 +0100 Subject: [PATCH] set DB_PASSWORD in env file --- ansible/roles/2-nk20/tasks/main.yml | 2 +- ansible/roles/2-nk20/templates/env.j2 | 24 ++++++++++++++++++++++++ ansible/roles/6-psql/tasks/main.yml | 4 ++-- 3 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 ansible/roles/2-nk20/templates/env.j2 diff --git a/ansible/roles/2-nk20/tasks/main.yml b/ansible/roles/2-nk20/tasks/main.yml index 9652359d..3852894d 100644 --- a/ansible/roles/2-nk20/tasks/main.yml +++ b/ansible/roles/2-nk20/tasks/main.yml @@ -16,7 +16,7 @@ - name: Use default env vars (should be updated!) template: - src: "env_example" + src: "env.j2" dest: "/var/www/note_kfet/.env" mode: 0644 force: false diff --git a/ansible/roles/2-nk20/templates/env.j2 b/ansible/roles/2-nk20/templates/env.j2 new file mode 100644 index 00000000..fbef052d --- /dev/null +++ b/ansible/roles/2-nk20/templates/env.j2 @@ -0,0 +1,24 @@ +DJANGO_APP_STAGE=prod +# Only used in dev mode, change to "postgresql" if you want to use PostgreSQL in dev +DJANGO_DEV_STORE_METHOD=sqlite +DJANGO_DB_HOST=localhost +DJANGO_DB_NAME=note_db +DJANGO_DB_USER=note +DJANGO_DB_PASSWORD={{ DB_PASSWORD }} +DJANGO_DB_PORT= +DJANGO_SECRET_KEY=CHANGE_ME +DJANGO_SETTINGS_MODULE=note_kfet.settings +CONTACT_EMAIL=tresorerie.bde@localhost +NOTE_URL=localhost +DOMAIN=localhost + +# Config for mails. Only used in production +NOTE_MAIL=notekfet@localhost +EMAIL_HOST=smtp.localhost +EMAIL_PORT=25 +EMAIL_USER=notekfet@localhost +EMAIL_PASSWORD=CHANGE_ME + +# Wiki configuration +WIKI_USER=NoteKfet2020 +WIKI_PASSWORD= diff --git a/ansible/roles/6-psql/tasks/main.yml b/ansible/roles/6-psql/tasks/main.yml index c4349f5e..91da9132 100644 --- a/ansible/roles/6-psql/tasks/main.yml +++ b/ansible/roles/6-psql/tasks/main.yml @@ -11,14 +11,14 @@ until: pkg_result is succeeded - name: Create role note - when: "DB_PASSWORD|bool" # If the password is not defined, skip the installation + when: DB_PASSWORD|length > 0 # If the password is not defined, skip the installation postgresql_user: name: note password: "{{ DB_PASSWORD }}" become_user: postgres - name: Create NK20 database - when: "DB_PASSWORD|bool" + when: DB_PASSWORD|length >0 postgresql_db: name: note_db owner: note