diff --git a/roles/code-submitter/tasks/main.yml b/roles/code-submitter/tasks/main.yml index 0c8f7ef..ae0070e 100644 --- a/roles/code-submitter/tasks/main.yml +++ b/roles/code-submitter/tasks/main.yml @@ -76,17 +76,25 @@ notify: Reload nginx +- name: Check if database exists + stat: + path: "{{ install_dir }}/sqlite.db" + register: database_file + - name: Install database # noqa: no-changed-when - We want to always run this (it handles its own idempotency) shell: # noqa: command-instead-of-shell - We need this to use `environment` argv: - "{{ venv_dir }}/bin/alembic" - upgrade - head - chdir: /srv/code-submitter + chdir: "{{ install_dir }}" environment: - PYTHONPATH: /srv/code-submitter + PYTHONPATH: "{{ install_dir }}" become_user: www-data - when: code_submitter_repo.changed # noqa: no-handler - Use a handler to ensure execution order + when: | + code_submitter_repo.changed or + database_file.stat.isreg is not defined or + not database_file.stat.isreg - name: Enable service service: