From 4119ff977b80db0990e4d5848a1be2bca0bd0616 Mon Sep 17 00:00:00 2001 From: Deimos Date: Sun, 26 May 2019 14:55:41 -0600 Subject: [PATCH] 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. --- salt/salt/final-setup.sls | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/salt/salt/final-setup.sls b/salt/salt/final-setup.sls index aa3ec61..21795c1 100644 --- a/salt/salt/final-setup.sls +++ b/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: