fix: auto-bootstrap Outline team on fresh install
All checks were successful
CI/CD / deploy (push) Successful in 15m8s
CI/CD / syntax-check (push) Successful in 1m4s

On a fresh DB Outline shows a blank login page because there is no team
and emailSigninEnabled = false. Add idempotent Ansible tasks that:
1. Create the 'Visual' team if none exists
2. Set guestSignin=true so email magic-link login works
Triggered by: server rebuild lost Outline DB (no backup existed).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jack 2026-03-27 09:14:14 +07:00
parent aa8d5082d3
commit f0c3fbbe1b
2 changed files with 37 additions and 0 deletions

View file

@ -31,5 +31,6 @@ uptime_kuma_image: "louislam/uptime-kuma:1" # https://hub
outline_image: "outlinewiki/outline:0.80.2" # https://hub.docker.com/r/outlinewiki/outline/tags
outline_db_image: "postgres:15-alpine"
outline_redis_image: "redis:7-alpine"
outline_team_name: "Visual"
n8n_image: "n8nio/n8n:1.89.2" # https://hub.docker.com/r/n8nio/n8n/tags
outline_mcp_image: "git.{{ domain_base }}/jack/outline-mcp:latest"

View file

@ -139,3 +139,39 @@
loop: "{{ forgejo_hooks.results }}"
loop_control:
label: "{{ item.item }}"
# ── Outline: bootstrap team on fresh install ─────────────────────────────────
# On a fresh DB there is no team → login page shows nothing.
# emailSigninEnabled = guestSignin AND SMTP_HOST is set.
# We idempotently create the team + enable guestSignin so email login works.
- name: Wait for Outline to be healthy
ansible.builtin.command: docker exec outline wget -qO- http://127.0.0.1:3000/_health
register: outline_health
changed_when: false
retries: 15
delay: 10
until: outline_health.rc == 0
- name: Bootstrap Outline team (idempotent)
ansible.builtin.shell: |
docker exec outline-db psql -U outline outline -c "
INSERT INTO teams (id, name, \"createdAt\", \"updatedAt\",
sharing, \"documentEmbeds\", \"guestSignin\",
\"defaultUserRole\", \"memberCollectionCreate\",
\"inviteRequired\", \"memberTeamCreate\")
SELECT gen_random_uuid(), '{{ outline_team_name }}', NOW(), NOW(),
true, true, true,
'member', true, false, true
WHERE NOT EXISTS (SELECT 1 FROM teams);
"
register: outline_team
changed_when: "'INSERT 0 1' in outline_team.stdout"
- name: Enable email signin on Outline team
ansible.builtin.shell: |
docker exec outline-db psql -U outline outline -c "
UPDATE teams SET \"guestSignin\" = true
WHERE \"guestSignin\" = false;
"
register: outline_guest_signin
changed_when: "'UPDATE 1' in outline_guest_signin.stdout"