UniFi Deploy Role¶
Installs the UniFi Network Application on the macmini controller (or any Debian/Ubuntu host) using the shared ops-library conventions. The role absorbs the bespoke infrastructure/services/unifi playbook: MongoDB provisioning, Java runtime install, UniFi package download, Traefik wiring, Home Assistant read-only user, and firewall management all live behind a single reusable interface.
Features¶
Installs MongoDB 8.0 from the upstream repo, enables authentication, configures quiet logging, logrotate, and an optional cron-based log monitor.
Creates the
unifiunix user, directory layout, cache path, and version-pinned UniFi.debdownload/install logic.Ships a hardened custom systemd service that injects Mongo URI + JVM tuning via environment variables to avoid
system.propertiescorruption.Emits a Traefik dynamic configuration file (and optional static entrypoint tweak) that matches the production router/service layout.
Opens the canonical UniFi ports with
ufwand optionally reconciles a read-only Home Assistant account inside Mongo/UniFi.
Key Variables¶
All tunables live in defaults/main.yml. The highlights:
Variable |
Default |
Description |
|---|---|---|
|
(required) |
MongoDB SCRAM password used for the admin + UniFi databases (store with SOPS/Vault). |
|
|
URL for the UniFi package. Keep in sync with |
|
|
Optional checksum (sha256:xxxx). Set to enforce artifact integrity. |
|
|
Heap sizes used in the systemd service. |
|
|
External domain used in the Traefik router + debug output. |
|
|
Toggle Traefik dynamic file management. |
|
|
When true, open the standard UniFi TCP/UDP ports via |
|
|
Generate or reconcile a read-only UniFi admin for Home Assistant integration. |
|
|
Optional pre-defined HA password. Leave empty to auto-generate and store under |
|
|
Force the MongoDB apt codename (defaults to detected release, fallback |
Review the defaults file for Traefik entrypoints, MongoDB repo release, logrotate script paths, and controller URLs.
Example Usage¶
- hosts: macmini
become: true
roles:
- role: local.ops_library.unifi_deploy
vars:
unifi_mongodb_password: "{{ sops_unifi_mongodb_password }}"
unifi_external_domain: "home.wersdoerfer.de"
unifi_traefik_entrypoints: ["web-secure"]
unifi_create_homeassistant_user: true
unifi_homeassistant_password: "{{ sops_homeassistant_unifi_password }}"
Notes¶
The role assumes Debian/Ubuntu + systemd. It performs a hard fail on other platforms to avoid half-configured hosts.
MongoDB authentication is mandatory: define
unifi_mongodb_passwordvia SOPS/Ansible Vault before running the role.If you already manage Traefik entrypoints elsewhere, keep
unifi_traefik_manage_api_entrypoint: falseto avoid editingtraefik.toml.For production cutovers, run
unifi_backupprior tounifi_deployand keepunifi_removeready for clean rollbacks.