From c7963acb815606ac9a73557c8e7cebfa4d2e285e Mon Sep 17 00:00:00 2001 From: Giancarlo Razzolini <grazzolini@archlinux.org> Date: Wed, 22 Jul 2020 11:31:16 -0300 Subject: [PATCH] roles/aurweb: Change tasks to work with the new DB method Added python-alembic to the package list and also running initdb.py for creating the tables when the database is created and alembic update when there's changes to the code. --- roles/aurweb/tasks/main.yml | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/roles/aurweb/tasks/main.yml b/roles/aurweb/tasks/main.yml index 11ebe22d9..69aa39b45 100644 --- a/roles/aurweb/tasks/main.yml +++ b/roles/aurweb/tasks/main.yml @@ -8,6 +8,7 @@ - make - php-memcached - pyalpm + - python-alembic - python-bleach - python-markdown - python-mysql-connector @@ -73,21 +74,21 @@ priv="{{ aurweb_db }}.*:ALL" no_log: true -- name: check if db exists - mysql_db: - name: "{{ aurweb_db }}" - state: present - register: db_imported - -- name: import aur sql db - mysql_db: - state: import - name: "{{ aurweb_db }}" - login_host: "{{ aurweb_db_host }}" - login_password: "{{ vault_mariadb_users.root }}" - target: "{{ aurweb_dir }}/schema/aur-schema.sql" - when: db_imported.changed - no_log: true +- name: initialize the database + command: python aurweb/initdb.py + args: + chdir: "{{ aurweb_dir }}" + become: true + become_user: "{{ aurweb_user }}" + when: db_created.changed + +- name: run migrations + command: alembic upgrade head + args: + chdir: "{{ aurweb_dir }}" + become: true + become_user: "{{ aurweb_user }}" + when: release.changed or db_created.changed - name: create aurweb conf dir file: path={{ aurweb_conf_dir }} state=directory -- GitLab