Affine Ansible role https://affine.pro/
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-11-23 00:24:12 +00:00
.forgejo/workflows feat: initial release 2026-11-23 01:23:58 +01:00
defaults feat: initial release 2026-11-23 01:23:58 +01:00
meta feat: initial release 2026-11-23 01:23:58 +01:00
tasks feat: initial release 2026-11-23 01:23:58 +01:00
templates feat: initial release 2026-11-23 01:23:58 +01:00
.gitignore feat: initial release 2026-11-23 01:23:58 +01:00
CHANGELOG.md feat: initial release 2026-11-23 01:23:58 +01:00
LICENSE feat: initial release 2026-11-23 01:23:58 +01:00
README.md Prettified Code! 2026-11-23 00:24:12 +00:00

affine

Deploys a self-hosted AFFiNE server (docs, whiteboards, databases) via Docker Compose, following upstream's self-host compose file (.docker/selfhost/compose.yml of the release): server, one-shot migration job, Redis and PostgreSQL with pgvector, routed through Traefik.

Requirements

  • Docker
  • Traefik on the traefik_web network with a websecure entrypoint (when affine_traefik is true)
  • community.docker Ansible collection

Variables

Variable Default Description
affine_instance affine Compose project name and container name prefix.
affine_data_path /data/affine Host path for storage/ (uploads), config/ (config.json, private key) and db/ (PostgreSQL).
affine_docker_path /docker/affine Host path for the compose.yml file.
affine_version 0.27.4 ghcr.io/toeverything/affine tag. Never go below the version that last migrated the database.
affine_pg_version pg16 pgvector/pgvector tag.
affine_redis_version 8 Redis tag.
affine_domain ~ Public domain (no protocol prefix). Traefik rule and AFFiNE's external URL. Required with affine_traefik.
affine_port ~ When set, exposes AFFiNE on this host port, bound to 127.0.0.1. Either this or affine_domain must be set.
affine_traefik true Attaches the server to traefik_web and adds routing labels.
affine_traefik_certresolver default Traefik certificate resolver.
affine_db_password ~ PostgreSQL password. Required.
affine_mail_conf ~ SMTP settings. See Mail.
affine_config {} Contents of config.json. See config.json.
affine_env {} Extra environment variables for server and migration job, overriding the role's own.
affine_uninstall false Stops and removes the containers and the compose directory.
affine_purge false Also removes the data directory. Requires affine_uninstall: true. Irreversible.

The indexer (full-text search via Manticore/Elasticsearch) is off, like in upstream's compose (AFFINE_INDEXER_ENABLED=false).

Mail

Needed for invites, magic sign-in links and password resets.

affine_mail_conf:
  host: smtp.example.com
  username: affine@example.com
  password: secret
  # Optional:
  port: 587 # default 465
  sender: "AFFiNE <affine@example.com>" # default "AFFiNE <username>"
  ignore_tls: false # true only for self-signed certificates

config.json

Everything without an environment variable lives in config.json (OIDC login, signup policy, copilot, ...), see the schema. With affine_config empty, the role leaves the file alone (settings saved in the admin panel at /admin stay). With it set, the role writes the file on every run and restarts the server when it changes.

affine_config:
  auth:
    allowSignup: false
  oauth:
    providers:
      oidc:
        clientId: affine
        clientSecret: secret
        issuer: https://auth.example.com/realms/example

The OIDC redirect URI to register at the provider is https://<affine_domain>/oauth/callback.

Usage

- hosts: web01
  become: true
  roles:
    - role: affine
      vars:
        affine_domain: notes.example.com
        affine_db_password: "{{ vault_affine_db_password }}"

The first visitor sets up the admin account at /admin - open it right after the first deploy. Upgrades: bump affine_version; the migration job migrates the database before the server starts.