Files
claudeandClaude Opus 5.5 99687ea231 Own LDAP account and mail, Harmony Users gate, Dex-only sign-in UI
- tasks/ldap.yml keeps cn=Harmony (harmony@eom.dev): password from Vault,
  in Harmony Users, Postfix Users and Dovecot Users. GoTrue sends as it,
  and it is an instance admin alongside eric@eom.dev.
- theme.js hides the e-mail/password form; Register and /register (also in
  Caddy) go to https://www.eom.dev/members/.
- The Dex button uses the square eom.dev icon.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 17:44:29 -05:00

202 lines
8.7 KiB
YAML

# SPDX-License-Identifier: MIT-0
---
- name: Validate required secrets
ansible.builtin.assert:
that:
- harmony_oidc_client_secret | length > 0
- harmony_smtp_password | length > 0
fail_msg: Set harmony_oidc_client_secret and harmony_smtp_password (Vault).
quiet: true
# They are spliced into SQL (tasks/configure.yml).
- name: Validate the admin e-mail addresses
ansible.builtin.assert:
that: harmony_admin_emails | reject('match', '^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+$') | list | length == 0
fail_msg: harmony_admin_emails must be plain e-mail addresses.
quiet: true
- name: Keep the service's LDAP account
ansible.builtin.include_tasks: ldap.yml
when: harmony_ldap_manage | bool
- name: Read the existing credentials
kubernetes.core.k8s_info:
kubeconfig: "{{ harmony_kubeconfig | default(omit, true) }}"
context: "{{ harmony_kube_context | default(omit, true) }}"
kind: Secret
namespace: "{{ harmony_namespace }}"
name: "{{ harmony_name }}"
register: _harmony_secret
no_log: true
# Vault values win. Otherwise keep what the cluster already has, so the
# database passwords and keys never change behind Harmony's back; on the
# first run, generate them (hex/alphanumeric, so they are safe in URLs).
- name: Use, reuse or generate the instance secrets
ansible.builtin.set_fact:
_harmony_existing: "{{ _existing }}"
_harmony_base:
JWT_SECRET: "{{ harmony_jwt_secret or _existing.JWT_SECRET or _gen64 }}"
POSTGRES_PASSWORD: "{{ harmony_postgres_password or _existing.POSTGRES_PASSWORD or _gen48 }}"
SECRET_KEY_BASE: "{{ _existing.SECRET_KEY_BASE or _gen64 }}"
REDIS_PASSWORD: "{{ _existing.REDIS_PASSWORD or _gen48 }}"
LISTENER_PASSWORD: "{{ _existing.LISTENER_PASSWORD or _gen48 }}"
INTERNAL_API_SECRET: "{{ _existing.INTERNAL_API_SECRET or _gen64 }}"
LIVEKIT_API_KEY: "{{ _existing.LIVEKIT_API_KEY or ('API' ~ lookup('ansible.builtin.password', '/dev/null', chars=['hexdigits'], length=12) | lower) }}"
LIVEKIT_API_SECRET: "{{ _existing.LIVEKIT_API_SECRET or _gen48 }}"
SMTP_PASS: "{{ harmony_smtp_password }}"
OIDC_CLIENT_SECRET: "{{ harmony_oidc_client_secret }}"
vars:
_raw: "{{ (_harmony_secret.resources | first).data if _harmony_secret.resources else {} }}"
_blank: {JWT_SECRET: "", POSTGRES_PASSWORD: "", SECRET_KEY_BASE: "", REDIS_PASSWORD: "", LISTENER_PASSWORD: "", INTERNAL_API_SECRET: "", LIVEKIT_API_KEY: "", LIVEKIT_API_SECRET: "", ANON_KEY: "", SERVICE_ROLE_KEY: "", VAPID_PUBLIC_KEY: "", VAPID_PRIVATE_KEY: ""}
_existing: "{{ _blank | combine(dict(_raw.keys() | zip(_raw.values() | map('b64decode')))) }}"
_gen64: "{{ lookup('ansible.builtin.password', '/dev/null', chars=['ascii_letters', 'digits'], length=64) }}"
_gen48: "{{ lookup('ansible.builtin.password', '/dev/null', chars=['ascii_letters', 'digits'], length=48) }}"
no_log: true
- name: Check secret lengths
ansible.builtin.assert:
that:
# PostgREST 13+ refuses a JWT secret under 32 characters.
- _harmony_base.JWT_SECRET | length >= 32
- _harmony_base.POSTGRES_PASSWORD | length >= 16
- _harmony_base.POSTGRES_PASSWORD is match('^[A-Za-z0-9]+$')
fail_msg: harmony_jwt_secret needs 32+ characters; harmony_postgres_password 16+ letters and digits.
quiet: true
no_log: true
# The anon and service-role keys are JWTs signed with JWT_SECRET; they are
# made again only when the secret changed. The VAPID pair never rotates: push
# subscriptions are bound to it.
- name: Derive the API keys and the VAPID pair
ansible.builtin.script:
cmd: genkeys.py
executable: python3
environment:
JWT_SECRET: "{{ _harmony_base.JWT_SECRET }}"
register: _harmony_genkeys
changed_when: false
when: >-
_harmony_existing.JWT_SECRET != _harmony_base.JWT_SECRET
or not _harmony_existing.ANON_KEY or not _harmony_existing.SERVICE_ROLE_KEY
or not _harmony_existing.VAPID_PUBLIC_KEY or not _harmony_existing.VAPID_PRIVATE_KEY
no_log: true
- name: Assemble the instance secrets
ansible.builtin.set_fact:
_harmony_secrets: >-
{{ _harmony_base | combine({
'ANON_KEY': _new.anon_key if _rekey else _harmony_existing.ANON_KEY,
'SERVICE_ROLE_KEY': _new.service_role_key if _rekey else _harmony_existing.SERVICE_ROLE_KEY,
'VAPID_PUBLIC_KEY': _harmony_existing.VAPID_PUBLIC_KEY or _new.vapid_public_key,
'VAPID_PRIVATE_KEY': _harmony_existing.VAPID_PRIVATE_KEY or _new.vapid_private_key,
}) }}
vars:
_new: "{{ (_harmony_genkeys.stdout | from_json) if _harmony_genkeys is not skipped else {} }}"
_rekey: "{{ _harmony_genkeys is not skipped and (_harmony_existing.JWT_SECRET != _harmony_base.JWT_SECRET or not _harmony_existing.ANON_KEY or not _harmony_existing.SERVICE_ROLE_KEY) }}"
no_log: true
- name: Create namespace
kubernetes.core.k8s:
kubeconfig: "{{ harmony_kubeconfig | default(omit, true) }}"
context: "{{ harmony_kube_context | default(omit, true) }}"
state: present
definition:
apiVersion: v1
kind: Namespace
metadata:
name: "{{ harmony_namespace }}"
when: harmony_create_namespace | bool
- name: Store credentials
kubernetes.core.k8s:
kubeconfig: "{{ harmony_kubeconfig | default(omit, true) }}"
context: "{{ harmony_kube_context | default(omit, true) }}"
state: present
apply: true
definition: "{{ lookup('ansible.builtin.template', 'secret.yml.j2') | from_yaml }}"
no_log: true
- name: Store configuration
kubernetes.core.k8s:
kubeconfig: "{{ harmony_kubeconfig | default(omit, true) }}"
context: "{{ harmony_kube_context | default(omit, true) }}"
state: present
apply: true
definition: "{{ lookup('ansible.builtin.template', 'config.yml.j2') | from_yaml_all | list }}"
register: _harmony_config
- name: Deploy the database
kubernetes.core.k8s:
kubeconfig: "{{ harmony_kubeconfig | default(omit, true) }}"
context: "{{ harmony_kube_context | default(omit, true) }}"
state: present
apply: true
definition: "{{ lookup('ansible.builtin.template', 'db.yml.j2') | from_yaml_all | list }}"
wait: true
wait_timeout: "{{ harmony_wait_timeout }}"
- name: Deploy Supabase (auth, rest, realtime, storage, imgproxy, kong)
kubernetes.core.k8s:
kubeconfig: "{{ harmony_kubeconfig | default(omit, true) }}"
context: "{{ harmony_kube_context | default(omit, true) }}"
state: present
apply: true
definition: "{{ lookup('ansible.builtin.template', 'supabase.yml.j2') | from_yaml_all | list }}"
wait: true
wait_timeout: "{{ harmony_wait_timeout }}"
# Harmony's bootstrap.sh, unchanged, from the release's source: migrations
# (each once, in supabase_migrations.schema_migrations), the harmony_listener
# role, the instance name and domain on a new database, the upload ceiling and
# storage origin. A Job is immutable, so each run replaces the last one.
- name: Remove the previous bootstrap Job
kubernetes.core.k8s:
kubeconfig: "{{ harmony_kubeconfig | default(omit, true) }}"
context: "{{ harmony_kube_context | default(omit, true) }}"
state: absent
api_version: batch/v1
kind: Job
namespace: "{{ harmony_namespace }}"
name: "{{ harmony_name }}-bootstrap"
delete_options:
# Foreground: its pod is gone before the next one starts; two
# bootstrap.sh runs at once deadlock on the migrations.
propagationPolicy: Foreground
wait: true
- name: Bootstrap the database
kubernetes.core.k8s:
kubeconfig: "{{ harmony_kubeconfig | default(omit, true) }}"
context: "{{ harmony_kube_context | default(omit, true) }}"
state: present
definition: "{{ lookup('ansible.builtin.template', 'bootstrap-job.yml.j2') | from_yaml }}"
wait: true
wait_condition:
type: Complete
status: "True"
wait_timeout: "{{ harmony_wait_timeout }}"
- name: Deploy Harmony (redis, web, federation, media cache, caddy, ingress)
kubernetes.core.k8s:
kubeconfig: "{{ harmony_kubeconfig | default(omit, true) }}"
context: "{{ harmony_kube_context | default(omit, true) }}"
state: present
apply: true
definition: "{{ lookup('ansible.builtin.template', 'harmony.yml.j2') | from_yaml_all | list }}"
wait: true
wait_timeout: "{{ harmony_wait_timeout }}"
- name: Deploy LiveKit
kubernetes.core.k8s:
kubeconfig: "{{ harmony_kubeconfig | default(omit, true) }}"
context: "{{ harmony_kube_context | default(omit, true) }}"
state: "{{ 'present' if harmony_voice_enabled | bool else 'absent' }}"
apply: true
definition: "{{ lookup('ansible.builtin.template', 'livekit.yml.j2') | from_yaml_all | list }}"
wait: "{{ harmony_voice_enabled | bool }}"
wait_timeout: "{{ harmony_wait_timeout }}"
- name: Configure the instance
ansible.builtin.include_tasks: configure.yml