EnsureNextcloudUsers

Idempotently creates a Nextcloud account for every "regular employee" user in DirectoryService. Runs every netsetup update cycle from EnsureCustomerVms right after the Nextcloud VM is up. Best-effort: any failure (no Nextcloud VM, SSH down, occ fault) is logged + swallowed so the rest of the cycle continues.

"Regular employee" filter: a real Email is set AND no infra role (MailRelay/DomainProvider). Same rule as NixTemplateFactory.BuildMailboxes. NOT role-based: CommonRoles.Default is assigned in-memory by EmployeeTranslator but drops on JSON serialization (employees end up with empty Roles in the config the live host reads), so the old Default-role filter returned zero users on Proxmox. Service accounts (root, osisaadmin, dnsadmin, mailadmin, nextadmin, pmgadmin, wifi) carry no Email and are skipped.

Transport: SSH from the Proxmox host to the Nextcloud VM via the netsetup master key, calling the NixOS-provided nextcloud-occ wrapper (which drops to the nextcloud user and invokes php occ). Each user gets user:info <name> as an existence probe; on absence, user:add creates with the AD password via OC_PASS + --password-from-env.

public static class EnsureNextcloudUsers

1. Methods

1.1. Run(ISystemHost, NETSetupConfig, Host)

Production entry point. Resolves the Nextcloud VM, gates on the qemu-guest-agent reporting hostname=="Nextcloud" (proves install + first boot are done — same gate UpdateNixosVm uses), discovers the live IP via the guest agent (NOT the pinned config IP — in Phase 1 that’s an OPNsense-LAN address that doesn’t exist yet; in Phase 2 the live agent IP equals the pinned IP anyway), then provisions each Default-role user. Outer try/catch makes the whole call best-effort: any failure is logged + swallowed so the rest of the cycle continues.

public static void Run(ISystemHost host, NETSetupConfig config, Host proxmoxHost)
Table 1. Parameters
Name Type Description

host

ISystemHost

config

NETSetupConfig

proxmoxHost

Host