From 17178eb842cf5a388ece96eeef8716ac9a465480 Mon Sep 17 00:00:00 2001 From: Erik Stambaugh Date: Tue, 23 Jan 2024 15:58:04 -0800 Subject: [PATCH] Fixes to make it start properly from clean --- ansible/roles/mastodon/tasks/main.yaml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ansible/roles/mastodon/tasks/main.yaml b/ansible/roles/mastodon/tasks/main.yaml index f73d60b..d7bbb72 100644 --- a/ansible/roles/mastodon/tasks/main.yaml +++ b/ansible/roles/mastodon/tasks/main.yaml @@ -127,6 +127,11 @@ # -- it's in lib/tasks/mastodon.rake under User.new # or https://docs.joinmastodon.org/admin/tootctl/#accounts-create +- name: wait for the db to come up + command: timeout --foreground 300 bash -c -- 'until docker compose exec -t mastodon_db psql -U postgres mastodon_production -P pager=off -c "\\dt"; do sleep 1; done' + args: + chdir: /srv/mastodon + - name: check for any tables at all command: docker compose exec -t mastodon_db psql -U postgres mastodon_production -P pager=off -c '\dt' args: @@ -137,7 +142,7 @@ command: docker compose run -t --rm mastodon_web bundle exec rails db:setup args: chdir: /srv/mastodon - when: hazschema.stdout is match("Did not find any relations") + when: hazschema.stderr is match("Did not find any relations") register: newschema - name: check whether our admin account has been created yet @@ -145,7 +150,9 @@ register: accountcount - name: create admin account - command: "docker exec -it mastodon_web bash -c 'RAILS_ENV=production tootctl accounts create meat --email {{ admin_email }} --confirmed --role Owner'" + command: "docker compose exec -it mastodon_web bash -c 'RAILS_ENV=production tootctl accounts create meat --email {{ admin_email }} --confirmed --role Owner'" + args: + chdir: /srv/mastodon when: accountcount.stdout == "1"