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 1 commit
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
Prev Previous commit
Next Next commit
Use stat helper to detect the database file
This is cleaner than using a custom shell script.
  • Loading branch information
PeterJCLaw committed Sep 24, 2024
commit 18afcdb8dd86fced1d56d255a6c49a6fa0551112
11 changes: 7 additions & 4 deletions roles/code-submitter/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -77,9 +77,9 @@
Reload nginx

- name: Check if database exists
shell: test -f "{{ install_dir }}/sqlite.db" || echo "Missing"
register: detect_database
changed_when: detect_database.stdout.startswith("Missing")
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`
@@ -91,7 +91,10 @@
environment:
PYTHONPATH: "{{ install_dir }}"
become_user: www-data
when: code_submitter_repo.changed or detect_database.changed # noqa: no-handler - Use a handler to ensure execution order
when: | # noqa: no-handler - Use a handler to ensure execution order
code_submitter_repo.changed or
database_file.stat.isreg is not defined or
RealOrangeOne marked this conversation as resolved.
Show resolved Hide resolved
not database_file.stat.isreg

- name: Enable service
service:
Loading