- Jinja 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .forgejo/workflows | ||
| defaults | ||
| files | ||
| meta | ||
| tasks | ||
| templates | ||
| .gitignore | ||
| CHANGELOG.md | ||
| LICENSE | ||
| README.md | ||
Plausible
Deploys a Plausible Community Edition instance via Docker Compose with PostgreSQL and ClickHouse, routed through Traefik as a reverse proxy.
Requirements
- Docker
community.dockerAnsible collection
Variables
| Variable | Default | Description |
|---|---|---|
plausible_instance |
plausible |
Unique instance name. Used as Compose project name and container name prefix. Change when running multiple instances on the same host. |
plausible_version |
v3.2.1 |
Plausible CE image tag. Pin to a specific version in production. |
plausible_pg_version |
18-alpine |
PostgreSQL image tag. |
plausible_clickhouse_version |
25.11-alpine |
ClickHouse image tag. |
plausible_data_path |
/data/plausible |
Host path for persistent data (database, event data, uploads). |
plausible_docker_path |
/docker/plausible |
Host path for the compose.yml file and ClickHouse config files. |
plausible_domain |
~ |
Public domain Plausible runs on (no protocol prefix). Required. |
plausible_port |
~ |
When set, exposes Plausible on this host port. Omit when using a reverse proxy. |
plausible_traefik |
true |
When true, attaches to the traefik_web network and adds Traefik routing labels. |
plausible_secret_key |
~ |
Secret key for cryptographic signing. Required. See Secret Generation. |
plausible_totp_key |
~ |
TOTP vault encryption key. Required. See Secret Generation. |
plausible_db_password |
~ |
PostgreSQL user password. Required. Generate with openssl rand -hex 32. |
plausible_email_verification |
false |
When true, requires email verification for new accounts. |
plausible_disable_registration |
invite_only |
Controls who can register. Accepted values: true (nobody), false (everyone), invite_only. |
plausible_mail_conf |
~ |
SMTP mail configuration dict. See Mail. |
plausible_backup_cron |
~ |
Cron schedule for nightly dumps of both databases into <plausible_data_path>/backup. ~ disables it. See Backup. |
plausible_uninstall |
false |
Stops and removes containers and the compose directory. |
plausible_purge |
false |
Also removes the data directory. Requires plausible_uninstall: true. Irreversible. |
Secret Generation
All three secrets must be generated before the first deploy:
openssl rand -base64 48 # → plausible_secret_key
openssl rand -base64 32 # → plausible_totp_key
openssl rand -hex 32 # → plausible_db_password
Copy the output values into your inventory:
plausible_secret_key: "..."
plausible_totp_key: "..."
plausible_db_password: "..."
Usage
Minimal setup:
plausible_domain: "analytics.example.com"
plausible_db_password: "{{ vault_plausible_db_password }}"
plausible_secret_key: "{{ vault_plausible_secret_key }}"
plausible_totp_key: "{{ vault_plausible_totp_key }}"
With mail and open registration:
plausible_domain: "analytics.example.com"
plausible_db_password: "{{ vault_plausible_db_password }}"
plausible_secret_key: "{{ vault_plausible_secret_key }}"
plausible_totp_key: "{{ vault_plausible_totp_key }}"
plausible_disable_registration: "false"
plausible_email_verification: true
plausible_mail_conf:
host: smtp.example.com
username: plausible@example.com
password: "{{ vault_plausible_smtp_password }}"
Multiple instances on the same host:
# instance 1
plausible_instance: plausible_team_a
plausible_domain: analytics-a.example.com
plausible_data_path: /data/plausible_team_a
plausible_docker_path: /docker/plausible_team_a
plausible_db_password: "secret_a"
# ... other secrets
# instance 2
plausible_instance: plausible_team_b
plausible_domain: analytics-b.example.com
plausible_data_path: /data/plausible_team_b
plausible_docker_path: /docker/plausible_team_b
plausible_db_password: "secret_b"
# ... other secrets
plausible_mail_conf is a dict. When unset, Plausible cannot send emails (invites, reports, password resets).
| Key | Required | Default | Description |
|---|---|---|---|
host |
yes | — | SMTP server hostname. |
username |
yes | — | SMTP username. |
password |
yes | — | SMTP password. |
port |
no | 465 |
SMTP port. |
ssl |
no | true |
true for TLS, false to disable. |
address |
no | username |
From address. Defaults to username. |
Backup
Copying the live database directories does not give a consistent backup. With
plausible_backup_cron set (e.g. "30 2 * * *"), the role installs
/usr/local/bin/<plausible_instance>-backup and a cron job that writes:
backup/postgres/plausible_db.dump:pg_dump -Fcof users, sites and settings;backup/clickhouse/latest/: a native ClickHouseBACKUPofplausible_events_db(events, sessions, imports), schema included.
Each run writes beside the last good copy first, so a failed run never replaces
it. Point a file-level backup (restic etc.) at <plausible_data_path>/backup and
schedule it after the dump.
Restore into a fresh deploy (same secrets, empty plausible_data_path), with
the backup copied back to <plausible_data_path>/backup:
docker stop plausible-app
docker exec -i plausible-db pg_restore -U postgres -d plausible_db --clean --if-exists \
< /data/plausible/backup/postgres/plausible_db.dump
docker exec plausible-events-db clickhouse-client --query "DROP DATABASE plausible_events_db SYNC"
docker exec plausible-events-db clickhouse-client \
--query "RESTORE DATABASE plausible_events_db FROM File('latest')"
docker start plausible-app
Uninstall
To stop and remove all containers and the compose directory:
plausible_uninstall: true
To also wipe all data including the database and event data (irreversible):
plausible_uninstall: true
plausible_purge: true
Notes
plausible_domainis always required — it is used inBASE_URLregardless of theplausible_traefiksetting.plausible_data_path/dbis owned by70:70(PostgreSQL Alpine container user), mode0700.plausible_data_path/datais owned by999:65533(Plausible app container user).- ClickHouse data and log directories are created as root; the ClickHouse container entrypoint chowns them to
101:101at startup. - All secret variables (
plausible_db_password,plausible_secret_key,plausible_totp_key) should be stored in Ansible Vault. - The role ships four static ClickHouse config files that reduce memory and CPU usage, suitable for small self-hosted setups.