From 2798286ee8c7daf490bc2a1853103a6db2618596 Mon Sep 17 00:00:00 2001 From: Peter Law Date: Mon, 23 Sep 2024 22:49:34 +0100 Subject: [PATCH] Create the code-submitter database if missing 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 https://github.com/srobo/ansible/issues/58. --- roles/code-submitter/tasks/main.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/roles/code-submitter/tasks/main.yml b/roles/code-submitter/tasks/main.yml index 9b6c8fb..f033e38 100644 --- a/roles/code-submitter/tasks/main.yml +++ b/roles/code-submitter/tasks/main.yml @@ -76,6 +76,11 @@ notify: 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") + - 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: @@ -86,7 +91,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 detect_database.changed # noqa: no-handler - Use a handler to ensure execution order - name: Enable service service: