- Jinja 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .forgejo/workflows | ||
| defaults | ||
| handlers | ||
| meta | ||
| tasks | ||
| templates | ||
| .gitignore | ||
| CHANGELOG.md | ||
| LICENSE | ||
| README.md | ||
Viseron
Deploys Viseron, a self-hosted NVR with AI-based object/motion detection, as a single Docker container, optionally routed through Traefik as a reverse proxy.
Requirements
- Docker
community.dockerAnsible collection
Variables
| Variable | Default | Description |
|---|---|---|
viseron_instance |
viseron |
Unique instance name. Used as Compose project name and container name prefix. Change when running multiple instances on the same host. |
viseron_version |
latest |
Viseron image tag. Pin to a specific version in production. |
viseron_data_path |
/data/viseron |
Host path for persistent data (config, database, recordings, snapshots, thumbnails, clips, timelapse). |
viseron_docker_path |
/docker/viseron |
Host path for the compose.yml file. |
viseron_domain |
~ |
Public domain Viseron runs on (no protocol prefix). Enables Traefik routing when set. |
viseron_traefik_certresolver |
default |
Name of the Traefik certificate resolver to use for viseron_domain. Must already be defined in Traefik's static config. |
viseron_port |
~ |
Host port to expose Viseron on (maps to container port 8888). Omit when using Traefik via viseron_domain. |
viseron_vaapi_enabled |
false |
Maps /dev/dri into the container for Intel/AMD VAAPI hardware acceleration. See Hardware acceleration. |
viseron_env |
{} |
Extra container environment variables (dict), e.g. POSTGRES_DATABASE_URL. See Database. |
viseron_config |
~ |
Full content of config.yaml, written verbatim. See Configuration. |
viseron_secrets |
~ |
Full content of secrets.yaml, written verbatim. See Configuration. |
viseron_uninstall |
false |
Stops and removes containers and the compose directory. |
viseron_purge |
false |
Also removes the data directory. Requires viseron_uninstall: true. Irreversible. |
Usage
Minimal setup with Traefik:
viseron_domain: "cameras.example.com"
With a direct host port instead of Traefik:
viseron_port: 8888
Multiple instances on the same host:
# instance 1
viseron_instance: viseron_home
viseron_domain: cameras-home.example.com
viseron_data_path: /data/viseron_home
viseron_docker_path: /docker/viseron_home
# instance 2
viseron_instance: viseron_office
viseron_domain: cameras-office.example.com
viseron_data_path: /data/viseron_office
viseron_docker_path: /docker/viseron_office
Configuration
Viseron's config.yaml is component-based — cameras, detectors, motion detection, MQTT, and everything else are declared per-component, and there is no such thing as a sensible universal default beyond an empty file. Because of that, this role doesn't attempt to generate or template config.yaml: by default it leaves Viseron alone to manage it, and optionally accepts the complete file content as a variable instead of trying to model Viseron's config schema in Ansible.
Unmanaged (default): leave viseron_config unset. Viseron creates an empty config.yaml on first boot and everything from then on is configured through its own built-in web UI.
Ansible-managed: set viseron_config to the full file content. It is written to viseron_data_path/config/config.yaml on every run, which makes the variable the single source of truth — any changes made through the web UI's config editor will be overwritten on the next deploy. Since config.yaml/secrets.yaml are bind-mounted files, Docker Compose has no way to tell they changed on its own (only the compose file's own service definition triggers a recreate) — this role restarts the container itself via a handler whenever either file's content changes, so a config change always takes effect on that same run.
viseron_config: |
ffmpeg:
camera:
front_door:
name: Front Door
host: !secret front_door_host
path: /Streaming/Channels/101/
username: !secret front_door_username
password: !secret front_door_password
darknet: {}
mqtt:
broker: mqtt.example.com
webserver: {}
logger: {}
Viseron supports keeping credentials out of config.yaml via its own !secret key_name syntax, resolved from secrets.yaml in the same directory. Set viseron_secrets to manage that file (mode 0600, independent of viseron_config — it can be set on its own to seed secrets for a web-UI-managed config too):
viseron_secrets: |
front_door_host: 192.168.1.50
front_door_username: admin
front_door_password: "{{ vault_front_door_camera_password }}"
The container bundles its own PostgreSQL server, persisted under viseron_data_path/config. On first start this database initializes before the web UI becomes reachable, which can take a little while — let the play's wait: true step run to completion rather than assuming a hang.
Database
To use an external PostgreSQL instead of the bundled one, set Viseron's own
POSTGRES_DATABASE_URL (SQLAlchemy URL). Viseron then skips waiting for the bundled
server and creates its tables itself (the user needs to own the database). The bundled
server still starts, unused. Move existing data with pg_dump from the container first.
viseron_env:
POSTGRES_DATABASE_URL: "postgresql://viseron:{{ vault_viseron_db_password }}@db.example.com:5432/viseron"
Hardware acceleration
Viseron supports several acceleration backends (VAAPI, NVIDIA CUDA, Coral EdgeTPU, Jetson Nano, Raspberry Pi camera stack), each needing a different image variant and/or device passthrough. This role currently only wires up VAAPI, since it's the one that applies without a dedicated GPU and doesn't require privileged: true — just a device mapping:
viseron_vaapi_enabled: true
This works for Intel and AMD CPUs with an integrated GPU (VAAPI support is built into every amd64 Viseron image). It requires /dev/dri to already exist and be usable inside the container's host:
- On bare metal or a VM with the iGPU passed through,
/dev/driis present automatically. - On a Proxmox LXC, the host must pass
/dev/dri(and, for unprivileged containers, the matchingrender/videogroup IDs) through to the container first — that's a Proxmox-level prerequisite, out of scope for this role. - Without an integrated GPU (e.g. a plain Proxmox VM/LXC on hardware with no iGPU, or a dedicated NIC/storage-only host), leave
viseron_vaapi_enabled: false— Viseron runs fine CPU-only, just without hardware-accelerated decode/encode.
CUDA (NVIDIA), Coral EdgeTPU, Jetson Nano, and Raspberry Pi acceleration are not currently supported by this role — they each need a different upstream image repository (e.g. roflcoopter/amd64-cuda-viseron instead of roflcoopter/viseron) and, for Coral/Jetson/RPi, privileged: true. Add them if/when the target hardware calls for it.
Uninstall
To stop and remove all containers and the compose directory:
viseron_uninstall: true
To also wipe all data including recordings and the database (irreversible):
viseron_uninstall: true
viseron_purge: true
Notes
- At least one of
viseron_portorviseron_domainmust be set for Viseron to be reachable — leaving both unset deploys a container with no exposed access. - The container always runs as root inside itself (Viseron's own
PUID/PGIDdefault). Data directories are created0:0to match. viseron_docker_path(holding onlycompose.yml) is mode0700;viseron_data_pathand its subdirectories are mode0755.