Browse Source

Salt: try to detect and re-run db init if needed

Sometimes the database initialization fails, generally due to some
earlier step in the setup having an issue. Even if a re-provision
resolves that issue, the database init wouldn't be re-run since it was
set up to only happen after the database was created.

This changes it so that it will try to select from the users table, and
if that fails it will re-run the initialization.
merge-requests/70/head
Deimos 6 years ago
parent
commit
4119ff977b
  1. 3
      salt/salt/final-setup.sls

3
salt/salt/final-setup.sls

@ -4,8 +4,9 @@ initialize-db:
cmd.run:
- name: {{ bin_dir }}/python -c "from scripts.initialize_db import initialize_db; initialize_db('{{ app_dir }}/{{ pillar['ini_file'] }}')"
- cwd: {{ app_dir }}
- onchanges:
- require:
- postgres_database: tildes
- unless: psql -U tildes tildes -c "SELECT user_id FROM users;"
{% if grains['id'] == 'dev' %}
insert-dev-data:

Loading…
Cancel
Save