Viseron Ansible role https://viseron.netlify.app/
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-11-26 23:38:27 +00:00
.forgejo/workflows fix: moved to forgejo pipeline 2026-10-13 12:17:41 +07:00
defaults feat: add viseron_env for extra container environment 2026-11-27 00:38:03 +01:00
handlers feat: initial version 2026-09-01 02:47:15 +02:00
meta feat: initial version 2026-09-01 02:47:15 +02:00
tasks feat: initial version 2026-09-01 02:47:15 +02:00
templates feat: add viseron_env for extra container environment 2026-11-27 00:38:03 +01:00
.gitignore feat: initial version 2026-09-01 02:47:15 +02:00
CHANGELOG.md feat: add viseron_env for extra container environment 2026-11-27 00:38:03 +01:00
LICENSE feat: initial version 2026-09-01 02:47:15 +02:00
README.md Prettified Code! 2026-11-26 23:38:27 +00:00

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.docker Ansible 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/dri is present automatically.
  • On a Proxmox LXC, the host must pass /dev/dri (and, for unprivileged containers, the matching render/video group 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_port or viseron_domain must 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/PGID default). Data directories are created 0:0 to match.
  • viseron_docker_path (holding only compose.yml) is mode 0700; viseron_data_path and its subdirectories are mode 0755.