From 5eb228c2799964083615b1777c05f3fac31364eb Mon Sep 17 00:00:00 2001 From: Erik Stambaugh Date: Fri, 26 Jan 2024 19:27:41 -0800 Subject: [PATCH] Save admin password in credentials --- ansible/roles/mastodon/tasks/main.yaml | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/ansible/roles/mastodon/tasks/main.yaml b/ansible/roles/mastodon/tasks/main.yaml index 2fdd249..93a53a1 100644 --- a/ansible/roles/mastodon/tasks/main.yaml +++ b/ansible/roles/mastodon/tasks/main.yaml @@ -149,12 +149,23 @@ 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 compose exec -it mastodon_web bash -c 'RAILS_ENV=production tootctl accounts create {{ admin_name }} --email {{ admin_email }} --confirmed --role Owner'" - args: - chdir: /srv/mastodon - when: accountcount.stdout == "1" +- name: register a mastodon admin account + block: + - name: create admin account + shell: "docker compose exec -it mastodon_web bash -c 'RAILS_ENV=production tootctl accounts create {{ admin_name }} --email {{ admin_email }} --confirmed --role Owner' 2>&1 | grep \"New password: \" | sed -e 's/.*password: //'" + args: + chdir: /srv/mastodon + register: passwdout + + - name: save masto admin password + delegate_to: localhost + become: false + copy: + dest: credentials/mastodon/masto_admin_pw + content: "{{passwdout.stdout}}" + + when: accountcount.stdout == "1" - name: restart mastodon command: docker compose restart