Skip to content

Commit

Permalink
Create the code-submitter database if missing
Browse files Browse the repository at this point in the history
This ensures that the database can be re-created if it's been
removed (as we do between SR years), even if the code hasn't changed.

Fixes #58.
  • Loading branch information
PeterJCLaw committed Sep 23, 2024
1 parent c06715e commit da80c4b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion roles/code-submitter/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@
notify:
Reload nginx

- name: Check if database exists

Check failure on line 79 in roles/code-submitter/tasks/main.yml

View workflow job for this annotation

GitHub Actions / ansible

no-changed-when

Commands should not change things if nothing needs doing.
shell: test -f "{{ install_dir }}/sqlite.db" && echo "Exists" || echo "Missing"
register: database_exists

- 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:
Expand All @@ -86,7 +90,7 @@
environment:
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_exists.stdout.startswith("Missing") # noqa: no-handler - Use a handler to ensure execution order

- name: Enable service
service:
Expand Down

0 comments on commit da80c4b

Please sign in to comment.