From 2b13ed0703ee22f38e0df71725486fc046469205 Mon Sep 17 00:00:00 2001 From: Matthieu Serrepuy Date: Mon, 16 Jan 2017 22:44:43 +0100 Subject: [PATCH] Add a POPULAtE_DATABASE env to use an existing wallabag DB --- README.md | 1 + root/etc/ansible/entrypoint.yml | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9c29888..852038c 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ Default login is `wallabag:wallabag`. - `-e SYMFONY__ENV__MAILER_PASSWORD=...`(defaults to "~", the SMTP password) - `-e SYMFONY__ENV__FROM_EMAIL=...`(defaults to "wallabag@example.com", the address wallabag uses for outgoing emails) - `-e SYMFONY__ENV__FOSUSER_REGISTRATION=...`(defaults to "true", enable or disable public user registration) +- `-e POPULATE_DATABASE=...`(defaults to "True". Does the DB has to be populated or is it an existing one) ## SQLite diff --git a/root/etc/ansible/entrypoint.yml b/root/etc/ansible/entrypoint.yml index 9f44a4d..7f49f9d 100644 --- a/root/etc/ansible/entrypoint.yml +++ b/root/etc/ansible/entrypoint.yml @@ -13,6 +13,7 @@ database_root_user_postgres: "{{ lookup('env', 'POSTGRES_USER') }}" database_root_password_postgres: "{{ lookup('env', 'POSTGRES_PASSWORD') }}" database_user: "{{ lookup('env', 'SYMFONY__ENV__DATABASE_USER')|default('root', true) }}" + populate_database: "{{ lookup('env', 'POPULATE_DATABASE')|default(True, true) }}" secret: "{{ lookup('env', 'SYMFONY__ENV__SECRET')|default('ovmpmAWXRCabNlMgzlzFXDYmCFfzGv', true) }}" mailer_host: "{{ lookup('env', 'SYMFONY__ENV__MAILER_HOST')|default('127.0.0.1', true) }}" mailer_user: "{{ lookup('env', 'SYMFONY__ENV__MAILER_USER')|default('~', true) }}" @@ -68,7 +69,8 @@ login_user=root login_password="{{ database_root_password_mariadb }}" notify: run install - when: database_driver == 'pdo_mysql' + when: (database_driver == 'pdo_mysql') and + (populate_database == True) - name: add mariadb user mysql_user: @@ -82,7 +84,8 @@ login_password="{{ database_root_password_mariadb }}" state=present when: (database_driver == 'pdo_mysql') and - (database_user != 'root') + (database_user != 'root') and + (populate_database == True) - name: postgresql db postgresql_db: @@ -93,7 +96,8 @@ login_user="{{ database_root_user_postgres }}" login_password="{{ database_root_password_postgres }}" notify: run install - when: database_driver == 'pdo_pgsql' + when: (database_driver == 'pdo_pgsql') and + (populate_database == True) - name: add postgresql user postgresql_user: @@ -107,7 +111,8 @@ login_password="{{ database_root_password_postgres }}" state=present when: (database_driver == 'pdo_pgsql') and - (database_user != 'postgres') + (database_user != 'postgres') and + (populate_database == True) - name: remove cache file: