From 5124a8035fd976cd9f712248496ec0238c7eaa95 Mon Sep 17 00:00:00 2001 From: Erik Stambaugh Date: Sun, 21 Jan 2024 12:27:46 -0800 Subject: [PATCH] Create admin account automatically --- ansible/roles/mastodon/tasks/main.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ansible/roles/mastodon/tasks/main.yaml b/ansible/roles/mastodon/tasks/main.yaml index 6def033..6f01175 100644 --- a/ansible/roles/mastodon/tasks/main.yaml +++ b/ansible/roles/mastodon/tasks/main.yaml @@ -137,6 +137,16 @@ chdir: /srv/mastodon when: hazschema.stdout is match("Did not find any relations") + +- name: check whether our admin account has been created yet + shell: "docker exec -t mastodon_db psql -U postgres mastodon_production -t -c 'select count(*) from accounts;' | awk '{ print $1 }' | head -1" + register: accountcount + +- name: create admin account + command: "docker exec -it mastodon_web bash -c 'RAILS_ENV=production tootctl accounts create meat --email meat@{{ domain_name }} --confirmed --role Owner'" + when: accountcount.stdout == "1" + + - name: restart mastodon command: docker compose restart args: