personal_infra/tofu/nodito
counterweight d208783fbf
navidrome: a music server on its own box, with beets in front of it
Navidrome 0.64.0 on music-box (nodito VM 8200, 1 core / 1 GB / 50 GB), public
at music.contrapeso.xyz. A single Go binary with a SQLite database; the only
external dependency is ffmpeg for transcoding. Plus beets, the CLI that fixes
tags before Navidrome ever indexes them.

── Exposed without basic auth, on purpose ─────────────────────────────────
Navidrome speaks two protocols on one port: its web UI, and the Subsonic API
(/rest/*) that every mobile client actually uses. A Subsonic client
authenticates with ?u=&t=md5(password+salt)&s= in the query string and has
nowhere to carry a second credential, so Basic Auth in front of the site is
invisible to most of them. The choice is a proxy credential or a working phone.

Same call this estate already made for monerod's restricted RPC, for the same
reason: proxied bare so Feather can reach it, with the service's own auth doing
the authenticating.

The cost is stated rather than glossed: the login page and the whole /rest/*
surface are reachable by anyone who finds the hostname, and Navidrome has no
rate limiting and no 2FA.

A fail2ban jail on vipy reads a per-vhost Caddy access log and catches WEB UI
brute force, where a bad login returns 401. It very likely does NOT catch
Subsonic brute force, because that protocol answers a bad password with HTTP
200 and puts the failure in the body - which Caddy never sees. Nor can it be
fixed on the music box: the request arrives from vipy over the tailnet, so the
only address fail2ban could ban there is vipy's, which would take down every
service behind the edge. Banning has to happen at the edge; the edge cannot see
the failure. So /rest/* is protected by password strength alone, and the README
carries a one-line curl to re-check that after every upgrade.

── Passwords are stored reversibly, and cannot not be ─────────────────────
The Subsonic API requires the server to compute md5(password+salt) per request,
so Navidrome cannot hash passwords one-way. It encrypts them at rest with
PasswordEncryptionKey instead. Two real consequences, both in the README: root
on that box means every Navidrome password in plaintext, so the password must
be unique to this service; and changing the key invalidates every stored
password, so it is set before the first account and left alone.

── beets is not a service, deliberately ───────────────────────────────────
`beet import` is interactive and it MOVES AND RENAMES FILES. A timer that
reorganises a music library unattended is a way to lose one. Installed and
configured, run by hand.

/srv/music is counterweight:navidrome mode 2750 and the setgid bit is
load-bearing: without it beets' files land in the curator's own group,
Navidrome cannot read them, and the symptom is an EMPTY LIBRARY rather than a
permission error. ReplayGain and lyrics are auto: no - on one core they turn a
two-minute import into a twenty-minute one.

── Monitoring ─────────────────────────────────────────────────────────────
Host liveness and disk (400), the systemd unit (401), a probe that fetches
/app/ and greps it (403), and public reachability plus cert expiry (402).

/app/ was chosen by testing all three candidates against 0.64.0: /ping returns
a bare "." and proves only that something listens; /rest/ping.view identifies
the server but logs two warnings per call, ~576 a day; /app/ returns
<title>Navidrome</title> and logs nothing. 402 asserts 200 on /app/ and not on
"/", because "/" answers 302 - checked live rather than assumed.

── Also ───────────────────────────────────────────────────────────────────
The headscale ACL grants tag:prd-vipy exactly tag:music-box:4533. Without a
rule the node is invisible rather than unreachable, which surfaces as a Caddy
502 "no such host".

inventory lan_ip was read off nodito's ARP table for the VM's own MAC, not
guessed - and .149 had belonged to another machine, whose stale host key made
SSH refuse the connection. That is the designed behaviour, not a fault.

50 GB is the LIBRARY ceiling, not just the OS: /srv/music is on the root disk,
so roughly 300-450 albums in FLAC. 1 GB is fine for serving and tight for the
initial scan, which is the memory peak.

No backups, deliberately. The music files would swamp the age-encrypted nightly
path, and navidrome.db is a rebuildable index. What is NOT rebuildable is
playlists, play counts, ratings and accounts - there are none today, which is
what makes the trade fair, and the README names this as the decision to revisit
if that changes.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-27 11:09:40 +02:00
..
.terraform.lock.hcl tofu: stop gitignoring the lock file and the VM inventory 2026-09-12 18:43:14 +02:00
main.tf mempool working 2025-12-14 22:15:29 +01:00
provider.tf tf defined vms 2025-10-31 08:54:18 +01:00
README.md tofu: stop gitignoring the lock file and the VM inventory 2026-09-12 18:43:14 +02:00
terraform.tfvars.example tofu: stop gitignoring the lock file and the VM inventory 2026-09-12 18:43:14 +02:00
variables.tf stuff 2025-12-08 10:34:04 +01:00
versions.tf tf defined vms 2025-10-31 08:54:18 +01:00
vms.auto.tfvars navidrome: a music server on its own box, with beets in front of it 2026-09-27 11:09:40 +02:00

Nodito VMs with OpenTofu (Proxmox)

This directory lets you declare VMs on the nodito Proxmox node and apply with OpenTofu. It clones the Ansible-built template debian-13-cloud-init and places disks on the ZFS pool proxmox-tank-1.

Prereqs

  • Proxmox API token with VM privileges. Example: user root@pam, token name tofu.
  • OpenTofu installed.
    sudo apt-get update
    sudo apt-get install -y apt-transport-https ca-certificates curl gnupg
    
    sudo install -m 0755 -d /etc/apt/keyrings
    curl -fsSL https://get.opentofu.org/opentofu.gpg | sudo tee /etc/apt/keyrings/opentofu.gpg >/dev/null
    curl -fsSL https://packages.opentofu.org/opentofu/tofu/gpgkey | sudo gpg --no-tty --batch --dearmor -o /etc/apt/keyrings/opentofu-repo.gpg >/dev/null
    sudo chmod a+r /etc/apt/keyrings/opentofu.gpg /etc/apt/keyrings/opentofu-repo.gpg
    
    echo \
      "deb [signed-by=/etc/apt/keyrings/opentofu.gpg,/etc/apt/keyrings/opentofu-repo.gpg] https://packages.opentofu.org/opentofu/tofu/any/ any main
    deb-src [signed-by=/etc/apt/keyrings/opentofu.gpg,/etc/apt/keyrings/opentofu-repo.gpg] https://packages.opentofu.org/opentofu/tofu/any/ any main" | \
      sudo tee /etc/apt/sources.list.d/opentofu.list > /dev/null
    sudo chmod a+r /etc/apt/sources.list.d/opentofu.list
    
    sudo apt-get update
    sudo apt-get install -y tofu
    tofu version
    
  • The Ansible template exists: debian-13-cloud-init (VMID 9001 by default).

Provider Auth

Credentials are the only thing not in git. Copy terraform.tfvars.example to terraform.tfvars (gitignored) and set:

  • proxmox_api_url (e.g. https://nodito:8006/api2/json)
  • proxmox_api_token_id (e.g. root@pam!tofu)
  • proxmox_api_token_secret

Alternatively, export them as TF_VAR_proxmox_api_token_secret etc.

Declare VMs

VMs are declared in vms.auto.tfvars, which is committed. *.auto.tfvars is loaded automatically, so it needs no -var-file. Example entry:

vms = {
  web1 = {
    name         = "web1"
    cores        = 2
    memory_mb    = 2048
    disk_size_gb = 20
    ipconfig0    = "ip=dhcp" # or "ip=192.168.1.50/24,gw=192.168.1.1"
  }
}

All VM disks are created on zfs_storage_name (defaults to proxmox-tank-1). Network attaches to vmbr0. VLAN can be set per-VM with vlan_tag.

Usage

tofu init
tofu plan
tofu apply

terraform.tfvars and vms.auto.tfvars are both auto-loaded.

VMs are created once and then protected: the module sets lifecycle.prevent_destroy = true and ignores subsequent config changes. After the initial apply, manage day‑2 changes directly in Proxmox (or remove the lifecycle block if you need OpenTofu to own ongoing updates).

Notes

  • Clones are full clones by default (full_clone = true).
  • Cloud-init injects cloud_init_user and ssh_authorized_keys.
  • .terraform.lock.hcl is committed: it pins the provider hashes, which matters because versions.tf tracks a release candidate (3.0.2-rc05).
  • State is local (terraform.tfstate, gitignored) and has no remote backend, so it exists only on the machine that last ran tofu apply.
  • The map is not a complete inventory of nodito: state also manages bastion-box (1100) and nonkeiwaisi-box (3300), which are not declared in vms.auto.tfvars. tofu plan is clean today, but relaxing the lifecycle block without first declaring them would put them up for destruction.
  • Disks use scsi0 on ZFS with discard enabled.