Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create the code-submitter database if missing #76

Merged
merged 4 commits into from
Sep 25, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions roles/code-submitter/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,22 @@
notify:
Reload nginx

- name: Check if database exists
shell: test -f "{{ install_dir }}/sqlite.db" || echo "Missing"
PeterJCLaw marked this conversation as resolved.
Show resolved Hide resolved
register: detect_database
changed_when: detect_database.stdout.startswith("Missing")

- 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 detect_database.changed # noqa: no-handler - Use a handler to ensure execution order

- name: Enable service
service:
Expand Down
Loading