mirror of
https://github.com/fscotto/infra.git
synced 2026-11-25 21:29:51 +00:00
Compare commits
8 Commits
main
...
2ab5ba6818
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2ab5ba6818 | ||
|
|
a347880d4c | ||
|
|
b05a2b4e74 | ||
|
|
75d9081a11 | ||
|
|
b4b3bd10b8 | ||
|
|
db10d1296e | ||
|
|
8c35ef63c9 | ||
|
|
64aebe8c34 |
532
AGENTS.md
532
AGENTS.md
@@ -6,10 +6,9 @@ Ansible-driven personal infrastructure repo for Fedora and Void desktops, Fedora
|
||||
- Main orchestration: `ansible/site.yml`
|
||||
- Inventory and layering inputs: `ansible/inventory/hosts.yml`, `ansible/inventory/group_vars/*.yml`, `ansible/inventory/host_vars/*.yml`
|
||||
- Dotfiles live under `dotfiles/`
|
||||
- AI agent instructions (bootstrap, dispatcher, knowledge, rules, patterns) are centralized in `dotfiles/common/.config/ai/` and shared between OpenCode, Codex, Gemini CLI, and Cline.
|
||||
- OpenCode loads its entrypoint configuration from `dotfiles/common/.config/opencode/opencode.json`; Codex global instructions deploy from `dotfiles/common/.codex/AGENTS.md`; Cline deploys both the cross-tool `dotfiles/common/.agents/AGENTS.md` pointer (to `~/.agents/AGENTS.md`) and the always-on global rule `dotfiles/common/.cline/rules/ai-context.md` (to `~/.cline/rules/`), which auto-binds the deployed `bootstrap.md`, dispatcher, safety directives, and distilled ChatGPT knowledge.
|
||||
- AI agent instructions (bootstrap, rules, knowledge) are centralized in `dotfiles/common/.config/ai/` and shared between OpenCode, Codex, and Gemini CLI.
|
||||
- OpenCode loads its entrypoint configuration from `dotfiles/common/.config/opencode/opencode.json`.
|
||||
- Codex config is rendered from `dotfiles/common/.codex/config.toml.j2` so `model_instructions_file` points to the deployed `~/.config/ai/bootstrap.md`.
|
||||
- ChatGPT conversation memory is stored in `dotfiles/common/.config/ai/memory/chatgpt/` and regenerated incrementally by `scripts/chatgpt_export_to_memory.py` from an official ChatGPT data export.
|
||||
|
||||
## Topology
|
||||
- Current personal desktop: `ikaros = platform_fedora + role_personal_workstation + graphical_desktop + desktop_gnome`
|
||||
@@ -26,13 +25,9 @@ Ansible-driven personal infrastructure repo for Fedora and Void desktops, Fedora
|
||||
- Preserve layering `all -> platform -> role -> desktop -> host`.
|
||||
- Keep `ansible/site.yml` small; orchestration belongs there, implementation belongs in roles.
|
||||
- Prefer minimal, targeted edits. Preserve idempotency and existing ordering.
|
||||
- Keep completed one-time cleanup operations out of the playbook. Execute them directly
|
||||
with explicit authorization; retain only the ongoing desired-state configuration and
|
||||
historical documentation, not permanent cleanup flags or tasks.
|
||||
- Use trunk-based development: `main` is the single long-lived branch. Land small,
|
||||
validated changes quickly, either as direct commits or via short-lived branches merged
|
||||
as soon as validation passes. Do not maintain `release/`, `support/`, or other
|
||||
long-lived branch lines: tag releases from the trunk and fix production issues on it.
|
||||
- Use Git Flow branch prefixes: `feature/` for new functionality, `bugfix/` for non-urgent fixes,
|
||||
`hotfix/` for urgent production fixes, `release/` for release preparation, and `support/` for
|
||||
maintained release lines. Do not use abbreviated prefixes such as `feat/`.
|
||||
- Desktop and WSL hosts use `ansible_connection: local`; remote infrastructure hosts use SSH.
|
||||
- Treat `secrets/` as sensitive. Never print secret values.
|
||||
- Tmux plugins are bootstrapped by TPM on the host; the repo only keeps tmux config and custom helper scripts.
|
||||
@@ -53,60 +48,26 @@ Ansible-driven personal infrastructure repo for Fedora and Void desktops, Fedora
|
||||
- Rocky server after activation: `ansible-playbook ansible/site.yml --limit <host> --check --diff`
|
||||
- Atlas NAS: `ansible-playbook ansible/site.yml --limit atlas --check --diff`
|
||||
- Aegis IoT: `ansible-playbook ansible/site.yml --limit aegis --check --diff`
|
||||
- Aegis NFS client layer: `ansible-playbook ansible/site.yml --limit aegis --tags nfs --list-tasks`
|
||||
- Aegis host DNS: `ansible-playbook ansible/site.yml --limit aegis --tags dns --check --diff`
|
||||
- Focused checks:
|
||||
- Emacs is disabled by default; temporary Emacs check: `ansible-playbook ansible/site.yml --limit <host> --tags emacs --check --diff -e emacs_enabled=true`
|
||||
- AI coding agents: `ansible-playbook ansible/site.yml --limit <host> --tags ai_agents --check --diff`
|
||||
- AI desktop apps lifecycle: `ansible-playbook ansible/site.yml --limit ikaros --tags chatgpt,opencode_desktop,cline_desktop --check --diff`
|
||||
- Mail bootstrap: `sh -n scripts/bootstrap_mail.sh` and `shellcheck scripts/bootstrap_mail.sh`
|
||||
- Thunderbird iCloud profile: `ansible-playbook ansible/site.yml --limit ikaros --tags thunderbird --check --diff`
|
||||
- Server NPM Quadlet: `systemctl status prometheus-npm.service`; the Compose fallback is retired.
|
||||
- Explicit Prometheus legacy cleanup (destructive only without check mode):
|
||||
`ansible-playbook ansible/site.yml --limit prometheus --tags server_legacy_cleanup --check --diff -e server_legacy_cleanup=true`
|
||||
- Server compose render: `podman-compose -f /opt/docker/server/docker-compose.yml config` and `systemctl status podman-compose-server`
|
||||
- Atlas media stack:
|
||||
`ansible-playbook ansible/site.yml --limit atlas --tags storage,sharing,containers --check --diff`
|
||||
- Atlas rootless Gitea staging (does not start Gitea):
|
||||
`ansible-playbook ansible/site.yml --limit atlas --tags gitea --check --diff`
|
||||
- Atlas canonical Gitea domain (restarts only Gitea on a real configuration change):
|
||||
`ansible-playbook ansible/site.yml --limit atlas --tags gitea_public_domain --check --diff`
|
||||
- Atlas Nextcloud/ONLYOFFICE steady state:
|
||||
`ansible-playbook ansible/site.yml --limit atlas --tags nextcloud --check --diff`
|
||||
- Atlas recurring consistent Nextcloud backup preparation:
|
||||
`ansible-playbook ansible/site.yml --limit atlas --tags nextcloud_backup,monitoring --check --diff`
|
||||
- Atlas iCloudPD storage and boot-started Quadlet:
|
||||
`ansible-playbook ansible/site.yml --limit atlas --tags icloudpd --check --diff`
|
||||
- Ongoing Gitea proxy configuration:
|
||||
`ansible-playbook ansible/site.yml --limit prometheus --tags gitea_cutover,prometheus_backup --check --diff -e server_gitea_on_atlas=true`
|
||||
and `ansible-playbook ansible/site.yml --limit atlas --tags gitea --check --diff`
|
||||
- Atlas daily Navidrome music copy:
|
||||
`ansible-playbook ansible/site.yml --limit atlas --tags music_sync --check --diff`
|
||||
- Atlas network/share hardening:
|
||||
`ansible-playbook ansible/site.yml --limit atlas --tags hardening,sharing --check --diff`
|
||||
- Atlas ZFS snapshot retention and scrub timers:
|
||||
`ansible-playbook ansible/site.yml --limit atlas --tags snapshots,scrub --check --diff`
|
||||
- Atlas encrypted Borg backup:
|
||||
`ansible-playbook ansible/site.yml --limit atlas --tags packages,borg --check --diff`
|
||||
- Atlas Borg progress logging only:
|
||||
`ansible-playbook ansible/site.yml --limit atlas --tags borg_logging --check --diff`
|
||||
- Atlas manual offline USB backup and 45Drives Alerts reminder:
|
||||
`ansible-playbook ansible/site.yml --limit atlas --tags usb_backup,usb_reminder --check --diff`
|
||||
- Atlas pool, disk, capacity, temperature, and job monitoring:
|
||||
`ansible-playbook ansible/site.yml --limit atlas --tags monitoring --check --diff`
|
||||
- Atlas explicit post-restore SELinux relabeling:
|
||||
`ansible-playbook ansible/site.yml --limit atlas --tags restorecon --check -e '{"atlas_restorecon_paths":["/zpool/archive"]}'`
|
||||
- Prometheus/Aegis WireGuard gateway:
|
||||
`ansible-playbook ansible/site.yml --limit prometheus,aegis --tags wireguard --check --diff`
|
||||
- Prometheus NPM Quadlet steady state (does not perform a cutover):
|
||||
`ansible-playbook ansible/site.yml --limit prometheus --tags npm_quadlet --check --diff`
|
||||
- Atlas phase-one rootless services:
|
||||
`ansible-playbook ansible/site.yml --limit atlas --tags backend_phase1 --check --diff`
|
||||
- Prometheus/Atlas WireGuard overlay:
|
||||
`ansible-playbook ansible/site.yml --limit prometheus,atlas --tags wireguard --check --diff`
|
||||
- DuckDNS config only: `ansible-playbook ansible/site.yml --limit prometheus --tags duckdns --check --diff`
|
||||
|
||||
## Conventions
|
||||
- Use FQCN Ansible modules.
|
||||
- Prefer declarative modules over `command`/`shell`; when `shell` is required, make idempotency and failure behavior explicit.
|
||||
- Start YAML files with `---`, use 2-space indentation, and keep file modes quoted like `"0644"`.
|
||||
- Keep booleans as booleans and structured vars as YAML lists/maps.
|
||||
- Group similar tasks into list variables (typically in `group_vars`) and apply them
|
||||
with a single task looping over the list, rather than one near-identical task per item.
|
||||
- Put host-specific overrides in `host_vars`, not shared `group_vars`.
|
||||
- Use `no_log: true` for secret-bearing task inputs or outputs.
|
||||
|
||||
@@ -122,7 +83,6 @@ Ansible-driven personal infrastructure repo for Fedora and Void desktops, Fedora
|
||||
- `dotfiles/desktop/.config/niri/config.kdl` and `session-env` deployed via `desktop_niri_dotfiles` (Niri / Wayland)
|
||||
- Void Niri lives in `profile_desktop_niri`, gated on `'niri' in desktop_sessions_enabled`; it installs the `emptty` `niri.desktop` session, the `/usr/local/bin/start-niri` launcher, and the xdg-desktop-portal config, mirroring `profile_desktop_sway`.
|
||||
- Fedora GNOME (`desktop_gnome`) assumes GNOME comes from the Fedora Workstation base install; Ansible deploys shared desktop dotfiles and git/GPG config for `ikaros` and `nymph`, not GNOME settings.
|
||||
- `profile_desktop_gnome` first discovers configured Thunderbird accounts in both `~/.thunderbird` and `~/.config/thunderbird` and selects an existing profile without changing its account settings. Only if no account exists does it seed a new iCloud IMAP/SMTP profile with CalDAV and CardDAV through a non-overwriting `user.js`. Registry changes preserve other profiles and create backups; Thunderbird must be closed. The bootstrap address comes from `vault_icloud_email` and the app-specific password is never stored by Ansible.
|
||||
- Do not switch or restart the display manager during a playbook run from an active graphical session.
|
||||
- `nymph` is the Fedora/GNOME laptop target; keep GNOME settings unmanaged for now and add host-specific tuning only after real use.
|
||||
|
||||
@@ -141,32 +101,25 @@ The dotfile vars follow the same split: `desktop_common_dotfiles` carries mode-i
|
||||
## Workstation Notes
|
||||
- `deadalus` is modeled as Windows + Fedora WSL and is the sole workstation target.
|
||||
- Fedora WSL belongs to `platform_fedora`, `workstation_dev_fedora`, and the shared WSL layer. It must not receive Flatpak or Snap runtimes.
|
||||
- Fedora WSL installs Mise from the official `jdxcode/mise` COPR and uses its pinned Temurin Java 11 JDK; update the declared Mise version deliberately.
|
||||
- Windows applications are installed manually and are not managed from the WSL profile.
|
||||
|
||||
## Rocky Server Notes
|
||||
- DuckDNS support is removed from the server profile, not feature-gated. No updater tasks,
|
||||
templates or enablement variables remain. Prometheus uses its static IP and `fscotto.co`;
|
||||
the local updater, log and cron job were already retired. External DuckDNS account/name
|
||||
and existing encrypted token are outside this removal and remain untouched.
|
||||
- DuckDNS is rendered by `profile_server` from host-local `server_duckdns_domain` and
|
||||
`vault_duckdns_token`. Keep the rotated token in encrypted Vault or untracked local vars, never in
|
||||
dotfiles. The private `~/duckdns/duck.sh` keeps the existing entrypoint; rendering uses `no_log`
|
||||
and disables diffs. Provisioning does not execute the updater or change its external schedule.
|
||||
- `rocky_server` is a child of both `platform_rocky` and `server`; `prometheus` is its active target.
|
||||
- The target must already provide `server_username` with local sudo access before the profile runs.
|
||||
- The Rocky profile installs Podman and podman-compose. Prometheus explicitly retires the legacy
|
||||
Compose unit, files and final-export helper with `server_legacy_stack_retired: true`.
|
||||
Its approved opt-in cleanup removed old application data on 2026-10-03; normal runs do not
|
||||
delete data or recreate the retired files. On Prometheus, Nginx Proxy Manager is now the rootful
|
||||
`prometheus-npm.service` Quadlet with a pinned image digest and the existing `/opt/npm/data` and
|
||||
`/opt/npm/letsencrypt` bind mounts. The rootful `server_web` bridge remains `10.89.0.0/24`.
|
||||
Gitea runs on Atlas; PostgreSQL and Navidrome are absent from the desired Prometheus stack.
|
||||
Normal runs do not delete legacy data, update DNS, or perform an implicit cutover;
|
||||
destructive cleanup requires its explicit tag and opt-in extra-var.
|
||||
- The Rocky profile installs Podman and podman-compose, uses firewalld, preserves SELinux enforcement, and renders the
|
||||
existing Nginx Proxy Manager/Gitea Compose stack with a `podman-compose-server` systemd unit. PostgreSQL and
|
||||
Navidrome are no longer part of the desired Prometheus configuration. The role does not stop or remove legacy
|
||||
containers, delete `/opt/postgres/data`, start the Compose stack, update DNS, or cut over traffic.
|
||||
- Firewalld enables SSH, Cockpit (`9090/tcp`), HTTP and HTTPS. Nginx Proxy Manager publishes `80/tcp` and
|
||||
`443/tcp`; bind its administration interface only to `127.0.0.1:81` and use `npm-tunnel` from Ikaros or Nymph.
|
||||
Nextcloud remains disabled; do not provision `/srv/nextcloud` directories.
|
||||
- The completed Ubuntu-to-Rocky data migration script and its operational instructions
|
||||
have been removed; current provisioning does not provide that one-time migration path.
|
||||
- Completed Gitea owner-migration, migration-restore and final-export tasks, helpers and flags
|
||||
are removed. Current Gitea marker/ownership checks, recurring backups and proxy configuration
|
||||
remain intact. `server_gitea_proxy_enabled` controls ongoing proxy management only.
|
||||
- `scripts/migrate_prometheus_data.sh` is the separate, source-host-run NPM/Gitea migration path. It dry-runs by
|
||||
default and requires explicit source-stack quiescing before copying persistent Docker data with rsync.
|
||||
- Atlas-only OpenZFS, NFS, Samba, and Syncthing stay selected through Atlas host variables and must not
|
||||
leak into `rocky_server`. Cockpit plus its Navigator and Podman extensions are selected explicitly for
|
||||
Prometheus through its host variables.
|
||||
@@ -184,10 +137,10 @@ The dotfile vars follow the same split: `desktop_common_dotfiles` carries mode-i
|
||||
- Atlas requires `vault_atlas_admin_password_hash` for Cockpit and, while sharing is enabled,
|
||||
`vault_atlas_samba_password`. The future rootful media stack also requires
|
||||
`vault_atlas_immich_db_password`. Never print these values.
|
||||
- Atlas creates the complete declared hierarchy only under the verified existing or explicitly bootstrapped pool: `archive`,
|
||||
`services`, `services/data`, `services/data/navidrome`, `services/data/syncthing`, `media`, `media/music`,
|
||||
`media/photobook`, `backup`, `backup/hosts`, and `backup/hosts/prometheus`. `backup` has a `500G`
|
||||
reservation covering its descendants. `archive` is the SMB-shared raw-data namespace; container state is never beneath it.
|
||||
- Atlas creates the complete declared hierarchy only under the verified existing or explicitly bootstrapped pool: `work`, `archive`,
|
||||
`archive/app_data`, `archive/app_data/navidrome`, `archive/app_data/syncthing`, `media`, `media/music`,
|
||||
`media/photobook`, `backups`, `backups/services`, and `backup_prometheus`. `backups/services` has a `500G`
|
||||
refreservation. There is no separate legacy `zpool/syncthing` dataset.
|
||||
- The `immich` system account is fixed to UID/GID `1100`, has no login shell or `wheel` membership, and receives only
|
||||
the `video` and `render` supplementary groups. Immich's rootful Quadlets run as `1100:1100`; Server and ML receive
|
||||
`/dev/dri`, while the Photobook external library is read-only at `/external/photobook`.
|
||||
@@ -196,381 +149,58 @@ The dotfile vars follow the same split: `desktop_common_dotfiles` carries mode-i
|
||||
`1100`. Targeted SELinux is enforced persistently; a required reboot is reported but never initiated automatically. The primary LAN interface is assigned explicitly to the managed firewalld zone, and firewall rules are applied before NFS or SMB are started; their service state and TCP listeners are then verified. SMB3 exposes `Archive` to Vault-backed authorized accounts on mandatory encrypted, signed SMB3 over TCP/445 only and admits the configured LAN without host-specific exclusions.
|
||||
- Atlas NPM and Immich share a rootful Podman network. NPM publishes HTTP/HTTPS, but its administration port remains
|
||||
bound to `127.0.0.1:81`; do not expose it directly to the LAN or Internet.
|
||||
- `profile_backend_phase1` temporarily runs rootless Navidrome and Syncthing on Atlas until Uranus replaces
|
||||
them. It binds only to Atlas' LAN IP, never `wg0`; Navidrome and the Syncthing GUI admit only Aegis as
|
||||
the source-NAT gateway, while native Syncthing ports admit the configured LAN. It initializes fresh
|
||||
state only and never migrates or deletes source application data. The enabled rootless
|
||||
`atlas-music-sync.timer` copies `/zpool/archive/Music` to `/zpool/media/music` daily at 00:45
|
||||
Europe/Rome without deleting destination files; it requires both datasets to be mounted.
|
||||
- `wireguard_overlay` manages `wg0` between Prometheus (`10.0.0.1`) and Aegis (`10.0.0.2`). It persists private
|
||||
keys only on their respective hosts, exchanges only derived public keys through Ansible, and verifies a real peer
|
||||
handshake. Prometheus opens `51820/udp`; Aegis is the LAN gateway. Its persistent IPv4 forwarding, narrowly scoped
|
||||
WireGuard-to-LAN firewalld policy, and source masquerading permit Prometheus to reach LAN services without a static
|
||||
route on the router. Prometheus includes `192.168.178.0/24` in Aegis' peer `AllowedIPs`; add the Uranus VIP there
|
||||
when it is assigned. After a firewalld reload, restore Prometheus' rootful Podman networking with
|
||||
`podman network reload --all` so the existing proxy stack retains container DNS.
|
||||
|
||||
- Atlas qBittorrent is selected by `atlas_manage_qbittorrent` and managed with the
|
||||
`qbittorrent` tag as the admin-owned rootless `atlas-qbittorrent.service` Quadlet.
|
||||
Its Web UI is `http://192.168.178.55:8090` on the LAN and prepared for the manual
|
||||
NPM HTTPS domain `torrent.fscotto.co`, trusting only Aegis for forwarded client
|
||||
addresses. DNS and NPM configuration stay manual. Configuration lives in
|
||||
`services/data/qbittorrent`, and only `Archive/Downloads` is writable as payload
|
||||
storage. It uses the home Internet connection, not WireGuard or a VPN; no router
|
||||
forwarding or published torrent peer port is configured. See `docs/atlas-qbittorrent.md`.
|
||||
|
||||
- Atlas HTTP downloads use the admin-owned rootless `atlas-aria2.service` and
|
||||
`atlas-ariang.service` Quadlets, gated by `atlas_manage_aria2` and the `aria2` tag.
|
||||
AriaNg binds the LAN at `http://192.168.178.55:8091`; direct RPC is LAN-only on TCP/6800
|
||||
and requires a private target-generated token. State lives in `services/data/aria2`,
|
||||
with payloads in `Archive/Downloads`; do not expose RPC through the existing
|
||||
qBittorrent `torrent.fscotto.co` endpoint. Public `downloads.fscotto.co` uses
|
||||
a manual NPM Access List for both UI and `/jsonrpc`. The `aria2_gateway` tag
|
||||
manages an admin user service on TCP/8092, accessible only through Aegis,
|
||||
injecting the private token for JSON-RPC POST clients; keep this route
|
||||
authenticated and never expose the gateway directly. See `docs/atlas-aria2.md`.
|
||||
|
||||
- Atlas Nextcloud backup preparation (`atlas-nextcloud-backup.service`) is an ordered
|
||||
requirement of the nightly `atlas-borg-backup.service` and the operator-started
|
||||
`atlas-usb-backup.service`. A structurally complete bundle younger than
|
||||
`atlas_nextcloud_backup_reuse_max_seconds` (20 h, asserted below 24 h so the nightly
|
||||
Borg cycle always refreshes it) is reused without pausing the applications: a manual
|
||||
USB run therefore reaches its LUKS prompt within seconds, while preparation failure
|
||||
still blocks the dependent job. Force one fresh preparation with
|
||||
`systemctl set-environment ATLAS_NEXTCLOUD_BACKUP_FORCE=1` before the start and unset
|
||||
the variable afterwards. Deployed and validated on 2026-11-15: a dependency start reused
|
||||
a verified bundle 14 h old and skipped preparation in 14 ms, and an operator-started
|
||||
USB run reached its LUKS prompt in under a second; the FORCE path has not been exercised
|
||||
in production yet. See `docs/atlas-nextcloud.md`.
|
||||
- `profile_backend_phase1` is limited to rootless Navidrome and Syncthing user Quadlets on Atlas. Official Navidrome
|
||||
`0.63.2` uses SQLite below `/data` and does not support `ND_DATABASE_URL` or an external PostgreSQL backend; do not
|
||||
recreate the obsolete Prometheus `navidromedb` service. The role requires the storage role's `zpool/media/music`,
|
||||
`zpool/archive/app_data`, `zpool/archive/app_data/navidrome`, and `zpool/archive/app_data/syncthing` datasets at
|
||||
their exact paths. It never creates the pool.
|
||||
- Keep `backend_phase1_start_services` false until the stopped Prometheus Navidrome data directory has been copied to
|
||||
Atlas and its SQLite database verified. The playbook renders the target but never migrates or deletes application
|
||||
data; after cutover, set the flag true to enable and start Navidrome and Syncthing.
|
||||
- Phase 1 must not change Prometheus' existing NPM deployment. NPM continues to be managed exactly by `profile_server`;
|
||||
use `10.0.0.2:4533` for Navidrome and `10.0.0.2:8384` for the Syncthing GUI. Syncthing does not use host networking:
|
||||
its GUI, transfer, QUIC and discovery ports are explicitly published only on `10.0.0.2`; native transfer/discovery does not use the HTTP proxy.
|
||||
- `wireguard_overlay` manages the required `wg0` path between Prometheus and Atlas, persists private keys only on their
|
||||
respective hosts, and exchanges only derived public keys. The initial run must include both hosts. Prometheus
|
||||
opens `51820/udp`; the Atlas backend role admits service ports only in the WireGuard firewalld zone.
|
||||
|
||||
## Atlas NAS TODO
|
||||
Completed validation: the existing RAIDZ2 pool and datasets, SELinux, LAN firewall, SSH, Cockpit with
|
||||
the selected 45Drives plugins, encrypted SMB3 `Archive`, the Aegis-only NFSv4 `photobook` export, and the
|
||||
Prometheus--Aegis WireGuard gateway are operational. The gateway handshake, forwarding, source masquerading,
|
||||
and TCP reachability to Atlas were verified. Temporary Navidrome and Syncthing are available through their
|
||||
manual NPM Proxy Hosts; Syncthing uses `/data/Org` backed by the SMB-shared Archive dataset. Aegis has also
|
||||
validated NFSv4.2 read, write, delete, and `all_squash` mapping to UID/GID `1100` end-to-end. The ZFS
|
||||
snapshot timers are active; a recursive hourly snapshot and scheduled retention prune completed
|
||||
successfully. The first monthly scrub completed successfully on 2026-10-04;
|
||||
the actual service result and pool scan were independently verified.
|
||||
|
||||
### Priority 1 - Data protection
|
||||
- [x] Deploy Ansible-managed recursive ZFS snapshots with 24 hourly, 30 daily, 8 weekly, and 12 monthly
|
||||
generations, plus a monthly scrub on the first Sunday at 03:00. The timers and first hourly snapshot were
|
||||
verified on Atlas. Cockpit Scheduler is for visibility or manual operations only, and snapshot
|
||||
rollback is never automated.
|
||||
- [x] Verify the first monthly ZFS scrub from its actual service result. On 2026-10-04
|
||||
it completed at 05:02 CEST after 2:02:04, repairing 0 B with zero errors;
|
||||
the service exited successfully and the pool reported no known data errors.
|
||||
- [x] Activate and validate the encrypted offsite Borg backup to the Hetzner Storage Box. Atlas uses the
|
||||
dedicated SSH identity, pinned ED25519 host key, Vault-backed `repokey` encryption, and a locked
|
||||
non-login `borg` account with no sudo or supplementary groups. The initial snapshot-consistent backup,
|
||||
Borg repository check, and temporary-directory restore completed successfully; the restored `Archive`
|
||||
tree matched the live data, and temporary snapshots and mounts were removed. The exported recovery key
|
||||
was copied offline. Daily backup retries and logging, 30 daily, 8 weekly and 12 monthly archives,
|
||||
compaction, and monthly repository checks are enabled. Runs report a ZFS-based estimated percentage.
|
||||
On 2026-09-30 a successful incremental run also removed the stale 2026-09-29 snapshot and its own
|
||||
temporary snapshot after exit; the earlier `RuntimeDirectory` cleanup failure is resolved.
|
||||
- [x] Populate `/zpool/archive` with the currently available data so offsite and offline backup tests run
|
||||
against a representative load.
|
||||
- [x] Evaluate Borg against the populated pool. The 2026-09-29 archive took 1 h 32 min for 2.18 TB
|
||||
original / 2.04 TB compressed data, with 13.49 GB deduplicated size; retention and compaction
|
||||
succeeded. On 2026-09-30 a subsequent incremental archive completed in about 22 seconds with
|
||||
successful cleanup. The monitor reported 37% Storage Box quota used. These are observed runs, not
|
||||
a guarantee of future duration or compression ratio.
|
||||
- [x] Add the UUID-bound offline USB backup with versioned rsync, locking, capacity checks, verification,
|
||||
safe unmounting and a tested restore procedure; never trigger it for an arbitrary USB disk. The
|
||||
LUKS/ext4 identities were read-only verified; the manual service and 45Drives Alerts reminder timer were
|
||||
deployed on Atlas. Interactive LUKS unlock is part of the manual service; only the reminder is
|
||||
scheduled for the first Saturday of each month at 10:00 Europe/Rome via the existing 45Drives
|
||||
notifier. A manual test produced an Alerts notification, not an email. The first USB attempt failed
|
||||
on a `security.selinux` xattr and was interrupted; the xattr filter is deployed and the temporary
|
||||
recursive snapshot and open LUKS mapper were cleaned up. A later run reported checksum verification
|
||||
and published the USB version, but failed while removing host-namespace ZFS snapshot mounts. Those
|
||||
exact mounts and snapshots were cleaned up. An `ExecStopPost` helper now removes only the named
|
||||
temporary snapshot after the backup process exits. A new full run checksum-verified and published a
|
||||
USB version; the service ended successfully, the mapper closed, no temporary USB snapshot remained,
|
||||
and the pool was healthy. On 2026-09-25 an independent, read-only USB restore test copied one file from
|
||||
the published `atlas/latest` version into `/var/tmp` and matched contents, owner, mode, size, mtime and
|
||||
POSIX ACL. The temporary copy and mount were removed, the mapper closed, and the pool remained healthy.
|
||||
- [x] Test restores independently from a ZFS snapshot, Borg, and the offline USB backup before relying on
|
||||
any backup path. The earlier Borg temporary-directory restore passed. On 2026-09-25 a separate,
|
||||
read-only ZFS snapshot test restored one file to `/var/tmp`, confirmed matching contents, ownership,
|
||||
mode, mtime and ACL, then removed its temporary copy and on-demand mount. This is a file-level smoke
|
||||
test, not full dataset recovery. An independent USB file restore passed on 2026-09-25 with matching
|
||||
content and metadata; the later scaled OS-rebuild rehearsal is documented under Priority 2.
|
||||
- [x] Add monitoring and alerting for pool health, scrub/resilver, SMART data, temperatures, free space,
|
||||
snapshot/local-backup growth, Hetzner Storage Box quota, and failed maintenance or backup timers.
|
||||
The half-hourly Atlas health monitor and systemd final-failure hooks are deployed. A live probe
|
||||
found no issues; the service and timer succeeded, and a labelled 45Drives Alerts test notification
|
||||
was submitted. Alerts are deduplicated; email delivery is not claimed. The Storage Box quota probe
|
||||
runs `df -m` over the dedicated pinned-key SSH identity and does not open the Borg repository.
|
||||
The failed-job hook was corrected to pass the literal systemd unit name; its expansion was verified
|
||||
on Atlas, but a new real failure notification has not been deliberately triggered.
|
||||
|
||||
### Priority 2 - NAS operability and recovery
|
||||
- [x] Document and test disaster recovery in `docs/atlas-recovery.md`: the operator confirmed Vault
|
||||
and Borg recovery material is available offline; provisional targets are RPO 24h/RTO 72h. On
|
||||
2026-09-30 an isolated small Rocky VM was rebuilt with the Atlas Ansible roles, imported its
|
||||
preserved RAIDZ2 pool without force/rewind, and restored a file from the preserved snapshot;
|
||||
the second Ansible run was idempotent. Earlier independent production ZFS, USB, and Borg file
|
||||
restore tests remain separate evidence. A production-size full restore, unclean import, and
|
||||
measured 24h/72h compliance are not claimed.
|
||||
- [x] Define a controlled Rocky kernel/OpenZFS update and reboot procedure in
|
||||
`docs/atlas-updates.md`. The first real change-window execution is not yet
|
||||
validated; the procedure never reboots automatically or upgrades pool features.
|
||||
- [x] Add the Atlas-initiated least-privilege Prometheus backup pull: Prometheus exposes only prepared
|
||||
- Provide the required Vault variables and validate the first remote bootstrap on the real Rocky Linux 9 host.
|
||||
Before the first apply, confirm the pool, mountpoints, LAN subnet and firewalld zone. Keep
|
||||
`atlas_manage_media_stack` disabled until `/dev/dri`, the container paths and the Immich database secret are validated.
|
||||
- Validate the complete baseline on the target: OpenZFS kmod loading, existing pool import, dataset
|
||||
mounts, SSH reconnect, Cockpit and all selected 45Drives plugins, NFSv4, SMB and Syncthing.
|
||||
- Finalize dataset properties and the shared UID/GID, group and POSIX ACL model; test the same files
|
||||
through both NFS and SMB before considering multiprotocol access complete.
|
||||
- Add Ansible-managed ZFS snapshot retention and scrub timers. Use Cockpit Scheduler for visibility
|
||||
or manual operations, not as the only source of configuration, and never automate snapshot rollback.
|
||||
- Manage the Syncthing star topology, device IDs, folders, folder modes, ignore rules and protected GUI
|
||||
or API access for the selected clients.
|
||||
- Validate the managed WireGuard path and its LAN/VPN-only firewalld rules before enabling remote services;
|
||||
never expose SSH, Cockpit, NFS, SMB or Syncthing through public port forwarding.
|
||||
- Add the Atlas-initiated least-privilege Prometheus backup pull: Prometheus exposes only prepared
|
||||
read-only dumps through a dedicated account and Atlas retains the private SSH key, pinned host key,
|
||||
atomic pull, verification, retention and systemd service/timer. The dedicated key/account and unit
|
||||
files are deployed; live read-only SSH, shell denial, and write denial were verified. On 2026-09-30
|
||||
a manual export, Atlas pull, checksum verification, and temporary restore passed; both SQLite
|
||||
databases passed integrity checks and a restored Git repository passed `git fsck`. Both daily
|
||||
timers are enabled for 02:00/03:00 Europe/Rome. On 2026-10-01 their first scheduled export and
|
||||
pull succeeded: Atlas verified the payload checksum and published `20261001T000001Z` as `latest`.
|
||||
- [x] Decide whether a common SMB/NFS namespace is required: no. `Archive` (SMB) and `photobook` (NFS)
|
||||
remain intentionally distinct; `docs/atlas-sharing-decision.md` records the decision. No ACL or export
|
||||
change is authorized by this decision.
|
||||
|
||||
### Priority 3 - Service expansion
|
||||
- [x] Populate `/zpool/media/music` and validate Navidrome. On 2026-09-30, 21,158 files
|
||||
(93,937,810,350 regular-file bytes) were copied from `/zpool/archive/Music` using a temporary
|
||||
ZFS snapshot; a checksum-based rsync dry run found no differences or extra files. Navidrome saw
|
||||
all files through its read-only mount, completed a scan, indexed 18,168 tracks, and responded
|
||||
over HTTP. Some imported playlists still reference obsolete Windows paths. The source was left
|
||||
intact and the temporary snapshot was removed.
|
||||
- [x] Schedule a daily, non-deleting copy from `Archive/Music` to the separate Navidrome music
|
||||
dataset. The rootless `atlas-music-sync.timer` is enabled for 00:45 Europe/Rome; a manual
|
||||
idempotent service run succeeded on 2026-10-01. The first scheduled run triggered at
|
||||
00:45 CEST on 2026-10-02 and exited successfully (`Result=success`, status 0); the next
|
||||
run is scheduled for 2026-10-03 00:45 CEST.
|
||||
- [x] Design the staged Prometheus-to-Atlas Gitea migration in `docs/atlas-gitea-migration.md`.
|
||||
The approved topology keeps NPM on Prometheus and moves HTTPS and public SSH (TCP/2222) together;
|
||||
Gitea runs as an `admin`-owned rootless user Quadlet on Atlas with an internal `gitea` user.
|
||||
The rootful-to-rootless data-layout
|
||||
conversion passed an isolated restore rehearsal. The later partial cutover is tracked below.
|
||||
- [x] Prepare the dedicated Atlas Gitea dataset, non-login UID/GID 1101 with a separate rootless Podman
|
||||
sub-ID range, and disabled user Quadlet. On 2026-10-01 the targeted Ansible run and a second idempotent
|
||||
run passed; the generated unit was inactive, with no staging HTTP/SSH listener. POSIX ACLs on only the
|
||||
service-namespace parents grant this account traversal without access to sibling datasets.
|
||||
- [x] Perform an isolated rootless restore rehearsal from the verified Prometheus backup. On 2026-10-01
|
||||
the SHA-256-checked selective extraction and path/SSH conversion succeeded; SQLite `quick_check`
|
||||
passed, all 33 repositories passed `git fsck`, and source/target public SSH host-key fingerprints
|
||||
matched. The pinned rootless image answered HTTP and listened on internal SSH/2222 with
|
||||
`--network none`; the temporary container was removed and the Quadlet stayed inactive. A second
|
||||
restore run made no changes. This is a rehearsal copy, not the final consistent cutover copy.
|
||||
- [x] Verify ZFS and Borg coverage of the staged Gitea dataset. On 2026-10-01 the managed recursive
|
||||
hourly snapshot `atlas-auto-hourly-20261001T193401Z` included it, and the managed incremental
|
||||
Borg archive `atlas-20261001T193420Z` included its database. A private one-file restore from
|
||||
each independently matched the staged database and passed SQLite `quick_check`; temporary files
|
||||
and snapshot mounts were removed, the Borg service ended successfully, and the pool was healthy.
|
||||
- [x] Include the new Gitea dataset in a UUID-bound offline USB version and test a file restore
|
||||
before accepting production writes. The operator's 2026-10-01 manual run published version
|
||||
`20261001T201220Z-254397` successfully on 2026-10-02. Its Gitea database was restored to a
|
||||
temporary directory from a read-only mount: contents, owner, group, mode, size, mtime and POSIX
|
||||
ACL matched, and SQLite `quick_check` passed. Temporary files and mounts were removed, LUKS
|
||||
was closed, and the pool remained healthy. A redundant run was stopped during verification;
|
||||
its temporary snapshot was cleaned up and the service's resulting failed state was reset.
|
||||
- [x] Install a separate opt-in final Gitea export helper on Prometheus. Its 2026-10-01 targeted
|
||||
deployment and `bash -n` passed while Gitea and NPM stayed running. It refuses an active export
|
||||
timer, stops only Gitea, verifies SQLite, publishes a checksum-verified Gitea-only version for
|
||||
Atlas' existing pull, and leaves the source stopped on success. It was invoked on 2026-10-02
|
||||
after the export timer was stopped; version `20261002T071525Z` was pulled and verified on Atlas.
|
||||
- [x] Prepare the Atlas final-restore gate without replacing the rehearsal: it accepts only a
|
||||
checksum-verified `gitea-cutover` export, refuses a running target, stages and validates the new
|
||||
layout before replacing the marked rehearsal, and rolls back a failed swap. Synthetic success
|
||||
and rollback tests passed on 2026-10-01. On 2026-10-02 the final gate replaced the rehearsal;
|
||||
SQLite `quick_check`, all 33 repository `git fsck` checks, checksum and SSH host-key comparison passed.
|
||||
- [x] Start the rootless Atlas Gitea Quadlet and move the primary HTTPS route. On 2026-10-02 Atlas
|
||||
answered HTTP 200 through the Aegis gateway. NPM stayed on Prometheus; its variable upstream
|
||||
required a managed Nginx `server_proxy.conf` override because runtime DNS ignores Compose
|
||||
`extra_hosts`. The primary public HTTPS page and API returned 200, and `git ls-remote` succeeded
|
||||
for a representative repository after NPM restart; the Navidrome and Syncthing Proxy Hosts also
|
||||
responded. The source
|
||||
Gitea container was removed from the desired Compose stack without deleting its data; the
|
||||
Prometheus backup export timer resumed for NPM only. A post-cutover recursive ZFS snapshot and
|
||||
encrypted Borg archive `atlas-20261002T073044Z` completed successfully.
|
||||
- [x] Move the live Gitea Quadlet and dataset from the legacy host `gitea` account to `admin`
|
||||
after a disposable snapshot-copy test of the pinned derived image. On 2026-10-02 the explicit
|
||||
outage run stopped only legacy Gitea, made safety snapshot
|
||||
`zpool/services/data/gitea@gitea-owner-migration-20261002T100104`, changed dataset ownership,
|
||||
and validated loopback staging (HTTP 200, internal `gitea` UID/GID 1000, SQLite `quick_check`)
|
||||
before promoting the `admin` Quadlet. Production LAN and public HTTPS returned 200; Navidrome
|
||||
and Syncthing remained active, the pool was healthy, and the normal Gitea run changed nothing.
|
||||
The old host account and data on Prometheus remain preserved; the old Atlas Quadlet and its
|
||||
parent-dataset traverse ACL were removed. A subsequent normal run changed nothing.
|
||||
- [x] Validate public Gitea SSH/2222 and an authenticated read from Ikaros. After the VPS
|
||||
firewall was opened on 2026-10-02, TCP/2222 connected, the public ED25519 host-key
|
||||
fingerprint matched Atlas, Gitea authenticated `fscotto` using the `ikaros` key, and
|
||||
`git ls-remote` returned HEAD for `fscotto/infra.git` over public SSH.
|
||||
- [x] Validate authenticated SSH pull and push. On 2026-10-02 the operator reported both
|
||||
operations working through the public SSH endpoint; the earlier agent-run `git ls-remote`
|
||||
remains the independent read-only check. The agent did not perform a test push.
|
||||
- [x] Validate Gitea login and write via HTTPS. On 2026-10-03 the operator confirmed
|
||||
authenticated web login and Git clone/pull/push through the public HTTPS endpoint. Do not
|
||||
restart the stale source Gitea after Atlas has accepted writes.
|
||||
- [x] Design and deploy the empty temporary Atlas Nextcloud/ONLYOFFICE stack on 2026-10-03.
|
||||
The operator explicitly authorized empty internal service startup before the first scrub;
|
||||
this does not close the scrub or protection checks. Four rootless Quadlets, separate
|
||||
component datasets, pinned images/apps, Vault secrets, standard fabio/chiara users, a
|
||||
separate application admin and the Famiglia folder are deployed. Cron and internal Office
|
||||
connection checks succeeded; repeat deployment changed nothing. See `docs/atlas-nextcloud.md`.
|
||||
- [x] Complete the authorized empty-stack public cutover on 2026-10-03 after operator
|
||||
DNS/NPM configuration. Both hostnames passed TLS and HTTPS redirects; authenticated
|
||||
web login, WebDAV, private-file isolation, Famiglia cross-user create/read/update/delete and
|
||||
CalDAV/CardDAV discovery passed. The Office connector and public health/API asset passed.
|
||||
Temporary test files were removed; no iCloud data was imported.
|
||||
- [x] Test a manual consistent Nextcloud backup and isolated restore on 2026-10-04.
|
||||
Paused application writers and cron, copied app/config/custom apps/themes and files,
|
||||
dumped PostgreSQL, restored database roles and verified authenticated DAV contents,
|
||||
account recovery and Famiglia permissions. Test containers had no external network,
|
||||
published ports or live data mounts; they and the temporary restore copy were removed.
|
||||
See `docs/atlas-nextcloud-recovery-test.md`; this is not recurring Borg/USB recovery evidence.
|
||||
- [x] Integrate consistent Nextcloud bundles with recurring Borg and operator-started USB
|
||||
backups, two-version local retention, interruption recovery and failure monitoring.
|
||||
On 2026-10-04 Borg archive `atlas-20261004T095255Z` succeeded; its new bundle was
|
||||
extracted from Hetzner and restored in isolation with checksums, accounts, Famiglia
|
||||
permissions and authenticated DAV verified. No production database was replaced.
|
||||
- [x] Validate a new USB version and restore its consistent Nextcloud bundle. On
|
||||
2026-10-04 USB version `20261004T101101Z-3420114` completed successfully; bundle
|
||||
`20261004T100959Z-3415600` was read-only extracted, checksum-verified and restored
|
||||
in isolation. Accounts, Famiglia permissions and authenticated DAV passed. The
|
||||
test copy/containers were removed, LUKS closed and the pool remained healthy.
|
||||
- [ ] Complete Nextcloud desktop/mobile editing and synchronization acceptance before family import.
|
||||
iCloud migration and future Uranus transfer remain separate operations, not playbook flags.
|
||||
- [x] Move Gitea canonical HTTPS and SSH hostname to `git.fscotto.co` on
|
||||
2026-10-03 through Ansible. Only Gitea restarted; second run changed nothing.
|
||||
HTTPS and authenticated SSH reads returned the same repository HEAD.
|
||||
The new NPM hostnames passed TLS/HTTP checks; old DuckDNS Proxy Hosts were
|
||||
observed disabled. Details are in `docs/domain-fscotto-co.md`.
|
||||
- [x] Confirm login on the new Gitea hostname and update remaining client remotes/integrations.
|
||||
The operator confirmed completion on 2026-10-03; the agent did not perform a test push.
|
||||
- [x] Remove obsolete DuckDNS NPM Proxy Hosts, unused certificates and the old upstream override.
|
||||
The operator confirmed completion on 2026-10-03; no new agent runtime check was performed.
|
||||
- [x] Review and remove completed one-time procedures from the playbook.
|
||||
The operator confirmed completion on 2026-10-03.
|
||||
- [x] Retire Prometheus' local DuckDNS updater on 2026-10-03 through Ansible:
|
||||
the five-minute cron entry and private updater/log directory were removed.
|
||||
Provisioning support was subsequently removed entirely; repeat cleanup changed nothing. HTTPS services, private NPM
|
||||
administration and the export timer stayed healthy. The external name and Vault token
|
||||
remain untouched for possible future use on a local host.
|
||||
- [ ] Keep `atlas_manage_media_stack` disabled until the future Immich deployment has validated `/dev/dri`,
|
||||
container paths, and the required Vault database secret.
|
||||
|
||||
### Priority 4 - Optional workflows
|
||||
- [x] Deploy the declared Atlas iCloudPD state dataset and inactive rootless `admin` Quadlet.
|
||||
Photos belong under `/zpool/archive/Pictures/iCloudPD`; private config/MFA state belongs in
|
||||
`zpool/services/data/icloudpd`. Photobook remains reserved for Immich. Ansible now renders
|
||||
`icloudpd.conf` with the Apple ID from the existing Vault key, but does not store the password
|
||||
or manage MFA. Automatic startup was approved on 2026-10-03; the Quadlet now
|
||||
uses `WantedBy=default.target` and Ansible keeps the service running.
|
||||
The isolated no-network layout test is documented in
|
||||
`docs/atlas-icloudpd-migration.md`. On 2026-10-02 Atlas deployment and a second idempotent run
|
||||
passed; no app config existed at deployment. A manual first start on 2026-10-02 generated
|
||||
`icloudpd.conf`; an Ansible run then replaced it with a private mode-0600 Vault-backed template
|
||||
and an idempotent second run. The image later expanded the config, so Ansible now seeds it
|
||||
only when absent and maintains the declared fields. Its launcher requires `traceroute`; the
|
||||
rootless Quadlet grants only `NET_RAW`, tested in isolation and after restart. The service
|
||||
was subsequently initialized interactively; initial ingestion is tracked below.
|
||||
- [x] Retire Aegis iCloudPD completely. The operator authorized deleting its Quadlet,
|
||||
`/var/lib/icloudpd` data, and MFA state despite an unaudited container overlay. After two
|
||||
interactive-sudo runs on 2026-10-02, the unit is `not-found`/`inactive`, the Quadlet and state
|
||||
directory are absent, and AdGuard remains active. The temporary retirement tasks have since
|
||||
been removed from the Aegis role; it no longer manages iCloudPD.
|
||||
- [x] Validate Atlas iCloudPD authentication and initial ingestion. On 2026-10-03 the active
|
||||
rootless service logged `All photos and videos have been downloaded` at 02:16 and reported
|
||||
completion for the user. The destination held 11,658 files (86,020,430,015 bytes); the preceding 24h
|
||||
logs showed download activity without authentication failures or errors. A later read-only check
|
||||
found the service still active. This confirms the initial download, not the next daily cycle.
|
||||
- [x] Declare HEIC decoding for Fedora graphical desktops without converting the originals on Atlas.
|
||||
The Fedora role installs RPM Fusion Free with a pinned signing-key fingerprint and
|
||||
`libheif-freeworld` on Ikaros and Nymph. The package was confirmed installed on Ikaros on
|
||||
2026-10-03; Nymph deployment and an actual image-opening test were not observed.
|
||||
- [ ] Validate Atlas iCloudPD filesystem/SELinux/SMB access, the next daily sync, ZFS/Borg/USB
|
||||
backup inclusion, and isolated restore of photos and private state. A recursive hourly snapshot
|
||||
of `zpool/archive` exists after ingestion, but no iCloudPD-specific backup version or restore
|
||||
has been verified. The first monthly scrub remains a separate open data-protection check.
|
||||
|
||||
## Prometheus NPM Quadlet cutover
|
||||
- [x] Stage a rootful NPM Quadlet using the exact running image and the existing data/certificate
|
||||
mounts, bridge subnet, public HTTP/HTTPS ports, and loopback-only administration port.
|
||||
The generated service depends on `server-web-network.service` and is wanted by `multi-user.target`.
|
||||
- [x] Take and verify the stopped-source export before switching owners. Version
|
||||
`20261003T091009Z` was pulled to Atlas and its NPM SQLite database checked in isolation.
|
||||
- [x] Cut over NPM to `prometheus-npm.service` on 2026-10-03. The legacy Compose unit is inactive
|
||||
and disabled; the Quadlet is active with zero recorded restarts. Public Gitea and Syncthing
|
||||
HTTPS returned 200 with valid TLS, while public TCP/81 remained unreachable.
|
||||
- [x] Validate the post-cutover backup path. The export and Atlas pull published
|
||||
`20261003T091633Z`; checksum, SQLite `quick_check`, ten proxy hosts, six certificate records,
|
||||
both Quadlet files were present, and the complete Let's Encrypt tree (70 regular files plus
|
||||
12 symlinks) matched the live data. A targeted normal Ansible run changed nothing. Details and rollback
|
||||
boundaries are in `docs/prometheus-npm-quadlet.md`.
|
||||
- [x] Remove only unused Gitea, Navidrome and PostgreSQL images with opt-in
|
||||
Ansible tasks on 2026-10-03. Second run changed nothing; NPM stayed active
|
||||
with zero restarts, HTTP/HTTPS passed, backup timer and SSH proxy stayed active.
|
||||
This image-only step preserved data and fallback; the later approved deletion is tracked below. Validation:
|
||||
`ansible-playbook ansible/site.yml --limit prometheus --tags server_image_cleanup --check --diff -e server_legacy_image_cleanup=true`
|
||||
- [x] Complete explicitly approved old-data and Compose fallback removal on 2026-10-03.
|
||||
Backup paths and mount dependencies were reconciled before deletion; repeat cleanup changed
|
||||
nothing. The normal Compose/template/helper check did not recreate retired files.
|
||||
A separately approved manual export/pull published `20261003T112906Z`; checksum and isolated
|
||||
SQLite restore passed with ten proxy hosts and both Quadlet definitions. NPM, primary HTTPS,
|
||||
WireGuard, SSH proxy and backup timer remained healthy; existing backup archives were preserved.
|
||||
- [x] Retire the unused secondary Gitea hostname `git.ov-ad3410.infomaniak.ch`
|
||||
on 2026-10-03. Its NPM Proxy Host was already soft-deleted and had no
|
||||
associated certificate. Its Ansible domain and runtime override were removed;
|
||||
nginx -t and reload passed without restarting NPM. Primary HTTPS returned 200
|
||||
with valid TLS. At that step only `git.fscotto.duckdns.org` remained declared;
|
||||
the subsequent domain transition and operator-confirmed cleanup are tracked above.
|
||||
- [ ] Observe the first scheduled export and Atlas pull after the cutover; the manual end-to-end
|
||||
cycle passed, but the next unattended cycle has not yet occurred.
|
||||
|
||||
## Cerberus Management Node (Deferred)
|
||||
`cerberus` is postponed until the office in the new house is physically set up. It is not an inventory
|
||||
host and this section is a design and implementation backlog, not authorization to provision it early.
|
||||
|
||||
The planned node is a Lenovo ThinkCentre M700 Tiny with an Intel Core i3-6100T, 8 GB RAM, a 256 GB SSD,
|
||||
and native 1 Gbps Ethernet. It will connect to a multi-input KVM switch using a passive DisplayPort-to-HDMI
|
||||
cable, sharing the monitor and peripherals with Ikaros. Fedora Sericea (immutable Fedora with the Sway
|
||||
Wayland compositor) is the intended OS. Cerberus is an isolated management plane: a dedicated Toolbox
|
||||
environment will run Ansible for future `uranus` cluster provisioning. Rootless Podman will host Grafana,
|
||||
Prometheus, and Loki. The 256 GB local SSD is the hot tier retaining metrics and logs for 30 days; scheduled,
|
||||
validated exports of older historical data will use a dedicated Atlas NFS dataset as cold storage.
|
||||
|
||||
### Implementation plan
|
||||
- [ ] Confirm the office, KVM switch, passive DisplayPort-to-HDMI path, shared monitor/peripherals, and native
|
||||
1 Gbps Ethernet are physically operational before adding Cerberus to inventory.
|
||||
- [ ] Install and update Fedora Sericea with Sway; document the immutable-host lifecycle and keep host changes
|
||||
declarative rather than treating the base OS as a mutable workstation.
|
||||
- [ ] Model Cerberus as its own host with independent platform, role, desktop, network, and storage inputs;
|
||||
do not repurpose Ikaros variables or make it a Uranus cluster member.
|
||||
- [ ] Provision an isolated Toolbox-based Ansible controller with the required collections and a reproducible
|
||||
project checkout; define its least-privilege SSH access, known-host handling, and Vault workflow without
|
||||
storing secrets in the image or repository.
|
||||
- [ ] Define the explicit Uranus provisioning workflow from Cerberus, including inventory boundaries,
|
||||
validation-only runs, and separate approval for any destructive cluster operation.
|
||||
- [ ] Design rootless Podman/Quadlet services for Grafana, Prometheus, and Loki, including persistent local
|
||||
state, service ownership, LAN exposure/authentication, resource limits, updates, and backups.
|
||||
- [ ] Size and enforce a 30-day local hot-retention policy for metrics and logs on the 256 GB SSD; validate
|
||||
actual disk growth and alert before capacity exhaustion.
|
||||
- [ ] Create and validate a dedicated Atlas NFS cold-storage dataset and least-privilege export for Cerberus;
|
||||
do not use a broad existing share or couple it to unrelated Atlas application state.
|
||||
- [ ] Implement scheduled, idempotent exports of data older than 30 days to the Atlas NFS cold tier, with
|
||||
locking, capacity checks, integrity verification, retention rules, failure monitoring, and a tested restore.
|
||||
- [ ] Validate management-plane recovery: rebuild Cerberus, restore observability history from Atlas, and
|
||||
confirm that Uranus provisioning can resume without depending on unreproducible local state.
|
||||
atomic pull, verification, retention and systemd service/timer.
|
||||
- Add the encrypted offsite backup with Borg to a Hetzner Storage Box: use a dedicated SSH identity,
|
||||
pin the host key, keep Borg repository credentials and encryption material in Vault, use
|
||||
snapshot-consistent sources, and manage retries, logging, pruning, repository checks and restores.
|
||||
- Add the UUID-bound offline USB backup with versioned rsync, locking, capacity checks, verification,
|
||||
safe unmounting and a tested restore procedure; never trigger it for an arbitrary USB disk.
|
||||
- Add monitoring and alerting for pool health, scrub/resilver, SMART data, temperatures, free space and
|
||||
failed backup timers, plus a controlled Rocky kernel/OpenZFS update and reboot procedure.
|
||||
- Document and test disaster recovery: rebuild Atlas with Ansible, import the existing pool, restore
|
||||
from snapshot/USB/Hetzner, preserve Vault and Borg recovery material offline, and define RPO/RTO.
|
||||
- Optionally design iCloud photo ingestion as a separate workflow after the storage and backup layers
|
||||
are validated; do not make it a dependency of the Atlas baseline.
|
||||
|
||||
## Coding Agent Notes
|
||||
- Shared agent definitions and lifecycle flags live in `ai_agents` in `ansible/inventory/group_vars/all.yml`.
|
||||
- Shared agent dotfiles live in `ai_agents_dotfiles`; rendered configs live in `ai_agents_templates`.
|
||||
- Every `ai_agents.<agent>` entry has independent `install_enabled`, `deploy_enabled`, and `uninstall_enabled` flags. Installation and removal must not both be true for the same agent; the common pre-task fails before changes when they conflict.
|
||||
- Fedora, Void desktop, and WSL workstation profiles consume the shared agent definitions; do not duplicate package entries in profile-specific vars. IBM Bob on the workstation follows its own flags.
|
||||
- WSL (`deadalus`) installs Claude Code, Codex and the Cline CLI; every other managed agent (including IBM Bob) is disabled and selected for removal through host overrides. `cline_deploy_enabled: true` also keeps Cline's cross-tool AGENTS pointer, global rules, and shared `~/.config/ai` context deployed on the host for the ecaas/cdp devcontainer bind mounts. Existing user state remains untouched.
|
||||
- `dotfiles_common` deploys `ai_agents_dotfiles` and renders `ai_agents_templates` only when deployment is enabled.
|
||||
- Removal is limited to the managed npm packages and `/usr/local/bin/bob`; never remove agent dotfiles, instructions, credentials, or user data.
|
||||
- Keep `.config/ai/` as the common instruction source; update agent-specific entrypoints to reference it rather than duplicating instruction text.
|
||||
- Fedora desktop AI apps (`chatgpt_desktop`, `opencode_desktop`, `cline_desktop`) follow the same lifecycle pattern through `ai_desktop_apps` in `ansible/inventory/group_vars/fedora.yml`; `install_enabled` and `uninstall_enabled` are independent per app and mutually exclusive (enforced by the common pre-task).
|
||||
- ChatGPT opts in per host (`ikaros`, `nymph`); Cline opts in through `desktop_gnome` group vars; OpenCode Desktop keeps removal selected by default because Cline replaced it.
|
||||
- Desktop-app removal deletes only managed artifacts: the RPM package (`chatgpt`, `opencode`, `cline`), ChatGPT's managed repository and signing key, and every cached download; it never removes user data, GNOME favorites, or the npm-managed CLI counterparts.
|
||||
|
||||
## Tooling Notes
|
||||
- Install local tooling with:
|
||||
@@ -588,32 +218,14 @@ validated exports of older historical data will use a dedicated Atlas NFS datase
|
||||
- `aegis` is a remote Fedora IoT Raspberry Pi 4 node. Bootstrap it once with
|
||||
`ansible/bootstrap/aegis.bu`; the remaining configuration is applied by `profile_aegis` over SSH.
|
||||
- Fedora IoT is immutable. Do not add it to mutable Fedora package or shared dotfile roles.
|
||||
- `profile_aegis` owns the `nfs-utils` and `wireguard-tools` rpm-ostree layers and reports the required reboot
|
||||
without initiating it. `wireguard_overlay` then configures Aegis as the WireGuard LAN gateway with persistent IPv4
|
||||
forwarding, a scoped inter-zone policy, and source masquerading. It also owns rootful Podman Quadlets, persistent container
|
||||
state under `/var/lib`, the Podman auto-update timer, LAN-restricted firewalld rules, and SSH hardening. Keep
|
||||
`aegis_lan_subnet`, `aegis_adguard_web_port`, and `aegis_network_connection_uuid` host-specific;
|
||||
SSH permits only the declared
|
||||
- `profile_aegis` owns rootful Podman Quadlets, persistent container state under `/var/lib`, the
|
||||
Podman auto-update timer, LAN-restricted firewalld rules, and SSH hardening. Keep
|
||||
`aegis_lan_subnet` and `aegis_adguard_web_port` host-specific; SSH permits only the declared
|
||||
key-authenticated users, never root or password authentication. Keep Apple IDs and other
|
||||
credentials in Vault and use `no_log` for their rendering.
|
||||
- `aegis_adguard_web_port` defaults to `80`. The initial AdGuard Home wizard port `3000` is intentionally unmanaged: open and close it manually only while
|
||||
completing initial setup. Disable the local systemd-resolved stub through `profile_aegis` before
|
||||
AdGuard binds port 53; keep
|
||||
`/etc/resolv.conf` linked to `/run/systemd/resolve/resolv.conf`. LAN clients may use AdGuard, but
|
||||
Aegis must use the independent upstream DNS declared by `aegis_host_dns_servers` so Greenboot does
|
||||
not depend on the AdGuard container during startup.
|
||||
- Aegis iCloudPD has been retired and is no longer managed by this role. Its service, Quadlet,
|
||||
data, and MFA state were removed with the operator's explicit authorization.
|
||||
|
||||
## Project Devcontainer Generator
|
||||
- `cmd/devcontainer/` generates standalone per-project language configurations;
|
||||
it does not replace existing deadalus ecaas/cdp provisioning or remove host tools.
|
||||
- Keep shared Git/agent behavior documented in `docs/project-devcontainers.md`.
|
||||
- Focused validation: `go -C cmd/devcontainer test ./...`.
|
||||
- Real engine builds, host credential forwarding and Fedora SELinux/Podman checks
|
||||
require target-host validation; do not report generator tests as runtime evidence.
|
||||
|
||||
- `devcontainer_generator` builds the CLI natively on Fedora graphical desktops
|
||||
and development workstations and installs it in `~/.local/bin/devcontainer`.
|
||||
Validate with `ansible-playbook ansible/site.yml --limit ikaros --tags devcontainer_generator --check --diff`;
|
||||
check mode skips compilation and binary installation explicitly.
|
||||
`/etc/resolv.conf` linked to `/run/systemd/resolve/resolv.conf` so Aegis retains router-provided DNS.
|
||||
- iCloudPD requires post-deployment interactive MFA initialization; its cookie/configuration state is
|
||||
persisted in `/var/lib/icloudpd/config`.
|
||||
|
||||
402
README.it.md
402
README.it.md
@@ -95,27 +95,6 @@ Nota sullo stato attuale del playbook principale:
|
||||
- `ansible/site.yml` applica il profilo server Rocky a `prometheus` con DNF, systemd, dotfiles server e firewalld
|
||||
- `ansible/site.yml` applica il profilo NAS Rocky su `atlas` tramite SSH remoto
|
||||
|
||||
## Nodo pianificato e posticipato: Cerberus
|
||||
|
||||
`cerberus` e un nodo di management **posticipato**, in attesa dell'allestimento
|
||||
fisico dell'ufficio nella nuova casa. Non e ancora presente nell'inventory e non
|
||||
esistono ruoli o playbook che lo prendano come target.
|
||||
|
||||
L'hardware previsto e un Lenovo ThinkCentre M700 Tiny (Intel Core i3-6100T,
|
||||
8 GB di RAM e SSD da 256 GB) con Ethernet nativa a 1 Gbps. Condividera monitor
|
||||
e periferiche di Ikaros tramite uno switch KVM a ingressi multipli, usando un
|
||||
cavo passivo DisplayPort-HDMI per il collegamento video. Il sistema operativo
|
||||
previsto e Fedora Sericea, la variante Fedora immutabile con compositor Wayland
|
||||
Sway.
|
||||
|
||||
Cerberus sara un management plane isolato: Ansible verra eseguito in un ambiente
|
||||
Toolbox dedicato per il provisioning del futuro cluster `uranus`, anziche da
|
||||
Ikaros o da un host non gestito. Lo stack di osservabilita rootless Podman
|
||||
eseguira Grafana, Prometheus e Loki. L'SSD locale sara l'hot storage, con
|
||||
metriche e log conservati per 30 giorni; esportazioni programmate trasferiranno
|
||||
i dati storici piu vecchi su un dataset Atlas montato via NFS come cold storage.
|
||||
Il piano di implementazione, con prerequisiti espliciti, e in `AGENTS.md`.
|
||||
|
||||
## Desktop
|
||||
|
||||
Target operativi:
|
||||
@@ -164,6 +143,7 @@ Lo stato attuale del profilo workstation include:
|
||||
|
||||
- installazione pacchetti base Fedora via dnf
|
||||
- installazione e configurazione di Docker dal repository ufficiale
|
||||
- installazione di Mise dal COPR ufficiale con JDK Eclipse Temurin Java 11 fissato
|
||||
- gestione dei dotfiles workstation e rendering dei template dev condivisi
|
||||
- preparazione di Fedora WSL con `systemd` per il toolchain di sviluppo
|
||||
- attivazione del firewall `firewalld` sui target Fedora che dichiarano regole host-specifiche
|
||||
@@ -181,10 +161,6 @@ Le applicazioni Windows sono installate e gestite manualmente; il profilo WSL no
|
||||
|
||||
## Server
|
||||
|
||||
La migrazione dei servizi pubblici a `fscotto.co`, la gestione Ansible
|
||||
degli URL Gitea e i passaggi ancora aperti per ritirare DuckDNS sono in
|
||||
[`docs/domain-fscotto-co.md`](docs/domain-fscotto-co.md).
|
||||
|
||||
Sistema operativo:
|
||||
|
||||
- Rocky Linux 9
|
||||
@@ -204,36 +180,51 @@ Lo stato attuale del profilo server include:
|
||||
- installazione pacchetti Rocky via DNF, EPEL e CRB
|
||||
- installazione di Podman e podman-compose
|
||||
- abilitazione dei servizi systemd dichiarati in inventory/group vars
|
||||
- copia dei dotfiles server e rendering del Quadlet rootful `prometheus-npm.service` per Nginx Proxy
|
||||
Manager; il vecchio fallback Compose è stato rimosso con autorizzazione esplicita
|
||||
- copia dei dotfiles server e rendering del `docker-compose.yml` per Nginx Proxy Manager e Gitea,
|
||||
piu l'unita `podman-compose-server` (attivazione manuale)
|
||||
- attivazione di firewalld con SSH, Cockpit (`9090/tcp`), HTTP e HTTPS abilitati
|
||||
- Syncthing escluso dal profilo server Rocky
|
||||
|
||||
Il 2026-10-03 la pulizia opt-in autorizzata ha rimosso dati e immagini precedenti di Gitea,
|
||||
Navidrome e PostgreSQL, directory obsolete vuote, helper finale Gitea e fallback Compose NPM.
|
||||
I servizi migrati restano su Atlas. `server_legacy_stack_retired: true` evita che i normali task
|
||||
ricreino i residui; la cancellazione richiede `--tags server_legacy_cleanup` e
|
||||
`-e server_legacy_cleanup=true`. NPM attivo e archivi di backup restano intatti.
|
||||
Export, pull Atlas e restore SQLite isolato post-pulizia sono riusciti; il primo ciclo automatico
|
||||
resta da osservare. Evidenze e confini del recovery:
|
||||
[`docs/prometheus-npm-quadlet.md`](docs/prometheus-npm-quadlet.md).
|
||||
Il Compose desiderato su Prometheus non include piu Navidrome ne il database PostgreSQL obsoleto.
|
||||
Navidrome e Syncthing appartengono ad Atlas; Navidrome ufficiale usa invece SQLite. Il profilo non
|
||||
arresta o rimuove automaticamente eventuali container legacy e non elimina `/opt/postgres/data`.
|
||||
|
||||
Nginx Proxy Manager pubblica solo `80/tcp` e `443/tcp`; la sua interfaccia di amministrazione e
|
||||
associata a `127.0.0.1:81` ed e raggiungibile da Ikaros o Nymph con l'alias Bash `npm-tunnel`.
|
||||
Nextcloud resta disabilitato e il profilo non crea directory `/srv/nextcloud`.
|
||||
|
||||
La fase 1 su Atlas non modifica i dati persistenti NPM. I proxy host NPM usano gli upstream LAN
|
||||
`http://192.168.178.55:4533` per Navidrome e `http://192.168.178.55:8384` per la GUI Syncthing;
|
||||
Prometheus li raggiunge attraverso Aegis come gateway WireGuard. Solo la GUI web di Syncthing usa
|
||||
NPM; il traffico di sincronizzazione resta sulle porte native esposte sulla LAN dichiarata.
|
||||
Mantenere l'autenticazione Syncthing e una policy di accesso NPM adeguata.
|
||||
La fase 1 su Atlas non modifica questo deployment NPM ne i suoi dati persistenti. Dopo aver attivato
|
||||
WireGuard e i servizi Atlas, configurare i proxy host NPM correnti con upstream Navidrome
|
||||
`http://10.0.0.2:4533` e upstream per la GUI Syncthing `http://10.0.0.2:8384`. Solo la GUI web di
|
||||
Syncthing usa NPM; il traffico di sincronizzazione resta sulle porte native pubblicate esplicitamente solo
|
||||
sull'indirizzo WireGuard di Atlas. Configurare l'autenticazione Syncthing e una policy di accesso NPM adeguata prima di pubblicare la GUI.
|
||||
|
||||
### Rimozione DuckDNS
|
||||
### DuckDNS
|
||||
|
||||
Il supporto DuckDNS è stato rimosso dal profilo server: non restano task, template,
|
||||
variabili o flag di abilitazione. Prometheus usa IP statico e `fscotto.co`.
|
||||
Updater locale, log e cron erano già stati rimossi. Nome/account DuckDNS esterni
|
||||
ed eventuale token cifrato esistente restano invariati per un possibile uso futuro.
|
||||
`profile_server` genera `~/duckdns/duck.sh` con permessi `0700`, mantenendo il percorso dello
|
||||
script e `duck.log`. Definire `server_duckdns_domain` negli host vars del server e salvare il
|
||||
**nuovo token rigenerato** in `vault_duckdns_token`, nel Vault cifrato `secrets/vault.yml`
|
||||
(`ansible-vault edit secrets/vault.yml`) oppure negli override non versionati `secrets/vault.local.yml`.
|
||||
Non committare lo script generato e non passare il token sulla riga di comando. Il rendering
|
||||
nasconde output e diff sensibili; lo script verifica TLS e passa il token a curl tramite stdin.
|
||||
Il playbook non esegue lo script e non modifica la sua schedulazione esterna.
|
||||
|
||||
```bash
|
||||
ansible-playbook ansible/site.yml --limit prometheus --tags duckdns --check --diff
|
||||
ansible-playbook ansible/site.yml --limit prometheus --tags duckdns
|
||||
```
|
||||
|
||||
La cancellazione dalla cronologia non revoca il token: rigenerarlo sul pannello DuckDNS.
|
||||
Dopo la bonifica, riclonare gli altri checkout senza unire nuovamente la vecchia storia;
|
||||
salvare separatamente eventuali modifiche non committate senza copiare segreti.
|
||||
|
||||
### Migrazione dati
|
||||
|
||||
Dopo il provisioning Rocky, eseguire `scripts/migrate_prometheus_data.sh` **sul server Ubuntu
|
||||
sorgente**. Lo script usa rsync, e in dry-run di default; richiede `--quiesce-source --execute` per
|
||||
fermare lo stack sorgente e copiare in modo consistente soltanto i dati di Nginx Proxy Manager e
|
||||
Gitea. Non sposta Navidrome o Syncthing, non avvia container, non cancella dati e non esegue il
|
||||
cutover.
|
||||
|
||||
Utente del profilo server:
|
||||
|
||||
@@ -255,282 +246,90 @@ ansible-playbook ansible/site.yml --limit prometheus -e server_username=myuser -
|
||||
|
||||
## NAS
|
||||
|
||||
`atlas` è un NAS Rocky Linux 9 raggiunto via SSH. Normalmente il pool esiste già e il profilo gestisce
|
||||
solo i dataset figli. La creazione iniziale del RAIDZ2 richiede esplicitamente `atlas_create_pool=true`
|
||||
e quattro percorsi `/dev/disk/by-id/...` verificati in `atlas_zpool_disks`. Il ruolo non partiziona,
|
||||
forza, distrugge, ripristina né modifica il layout vdev di un pool esistente. I client Linux usano NFSv4,
|
||||
quelli Windows/WSL SMB; l'accesso è limitato alla LAN configurata.
|
||||
`atlas` e un NAS Rocky Linux 9 raggiunto tramite SSH. Normalmente il pool ZFS esiste gia e il profilo
|
||||
gestisce solo i dataset figli. Un bootstrap RAIDZ2 una tantum e disponibile solo con conferma esplicita
|
||||
(`atlas_create_pool=true`) e quattro percorsi reali e verificati `/dev/disk/by-id/...` in
|
||||
`atlas_zpool_disks`. Non partiziona, forza, distrugge, esegue rollback o modifica il layout vdev di un
|
||||
pool esistente. I client Linux usano NFSv4, quelli Windows/WSL SMB; entrambi restano limitati alla LAN
|
||||
configurata.
|
||||
|
||||
Per il primo avvio servono `vault_atlas_admin_password_hash`, `vault_atlas_samba_password` e
|
||||
`vault_atlas_immich_db_password`; il primo è un hash compatibile con `/etc/shadow`, non una password
|
||||
Cockpit in chiaro. Il bootstrap usa l'amministratore preesistente:
|
||||
Per il primo avvio fornire `vault_atlas_authorized_ssh_keys`, `vault_atlas_admin_password_hash`,
|
||||
`vault_atlas_samba_password` e `vault_atlas_immich_db_password`. Eseguire il bootstrap tramite
|
||||
l'amministratore esistente:
|
||||
|
||||
```bash
|
||||
ansible-playbook ansible/site.yml --limit atlas \
|
||||
-e atlas_connection_username=<existing-admin>
|
||||
```
|
||||
|
||||
Le esecuzioni successive usano `atlas_admin_username`. Storage, condivisioni e firewall LAN sono
|
||||
abilitati; prima dell'applicazione verificare pool, mountpoint, subnet e zona firewalld. La creazione
|
||||
del pool è protetta da un gate esplicito e avviene solo se è assente. Atlas non fa più parte della VPN
|
||||
WireGuard: la vecchia interfaccia è stata ritirata manualmente dopo la verifica del collegamento tra
|
||||
Prometheus e Aegis. Le chiavi SSH autorizzate sono in file separati sotto
|
||||
`~/.ssh/authorized_keys.d/`. `atlas_manage_media_stack` resta disabilitato finché `/dev/dri`, percorsi
|
||||
dei container e segreto del database Immich non sono validati.
|
||||
`vault_atlas_admin_password_hash` deve essere un hash compatibile con `/etc/shadow`, non una
|
||||
password Cockpit in chiaro. Le esecuzioni successive usano `atlas_admin_username`. Atlas dichiara
|
||||
abilitati storage, condivisioni e regole firewall LAN. Prima della prima applicazione verificare pool e
|
||||
mountpoint esistenti, subnet LAN e zona firewalld attiva. `atlas_manage_media_stack` resta disabilitato
|
||||
finche non saranno validati `/dev/dri`, i percorsi dei container e il segreto del database Immich.
|
||||
|
||||
Sotto `zpool` Atlas crea `archive` (SMB), `services/data` con i dataset applicativi
|
||||
`services/data/navidrome` e `services/data/syncthing`, `media`, `media/music`, `media/photobook` e
|
||||
`backup/hosts/prometheus`. Archivio e applicazioni usano `zstd`; media, Syncthing e backup host usano
|
||||
`lz4`. `backup` ha una riserva di `500G` che copre i discendenti. SELinux targeted è persistente;
|
||||
l'eventuale riavvio necessario viene segnalato, non eseguito. Atlas assegna l'interfaccia primaria
|
||||
alla zona firewalld gestita, rifiuta redirect e source route, registra i martian, mantiene il reverse-path
|
||||
filter loose e disabilita il forwarding IPv4. SSH consente soltanto l'amministratore dichiarato con
|
||||
chiave pubblica: root, password, agent forwarding e remote forwarding sono disabilitati, mentre il
|
||||
forwarding locale resta disponibile per i tunnel amministrativi. SMB3 espone `Archive` agli account
|
||||
autorizzati da Vault sulla LAN, solo su TCP/445 con cifratura e firma obbligatorie. NFSv4 espone
|
||||
soltanto `media/photobook` all'IP di Aegis su TCP/2049, con `all_squash` verso UID/GID `1100`.
|
||||
Con la gestione storage attiva, Atlas crea l'intera gerarchia sotto il pool `zpool` esistente o creato esplicitamente:
|
||||
`work`, `archive`, `archive/app_data`, i dataset applicativi separati
|
||||
`archive/app_data/navidrome` e `archive/app_data/syncthing`, `media`, `media/music`,
|
||||
`media/photobook`, `backups`, `backups/services` e `backup_prometheus`. I dataset applicativi e
|
||||
di archivio usano `zstd`; media, Syncthing e backup dei servizi usano `lz4`;
|
||||
`backups/services` mantiene inoltre una `refreservation` di `500G`.
|
||||
Atlas impone SELinux targeted in modo persistente e segnala, senza avviarlo, l’eventuale reboot necessario per attivarlo. Assegna esplicitamente l’interfaccia LAN primaria alla zona firewalld gestita e applica hardening persistente del kernel di rete: rifiuta redirect e source-route, registra i martian, usa reverse-path filtering loose per WireGuard e disabilita il forwarding IPv4. SSH consente solo l’amministratore dichiarato tramite chiave pubblica; root, password, agent e forwarding
|
||||
remoto sono disabilitati, mentre il forwarding locale resta disponibile per tunnel amministrativi privati. SMB3 pubblica `Archive` solo agli account Samba configurati con password in Vault e
|
||||
ammette la LAN configurata su SMB3 cifrato e firmato, esclusivamente su TCP/445. NFSv4 esporta soltanto
|
||||
`media/photobook` all'IP configurato di Aegis su TCP/2049, con `all_squash` verso UID/GID anonimi `1100`.
|
||||
|
||||
L'account di sistema `immich` usa UID/GID `1100`, non ha shell di login né gruppo `wheel` e riceve i
|
||||
gruppi `video` e `render`. Lo stack Immich futuro prevede Quadlet rootful per Server, ML, cache,
|
||||
PostgreSQL e NPM su una rete Podman comune. Immich gira come `1100:1100`, Server e ML ricevono
|
||||
`/dev/dri` e Photobook è montato in sola lettura su `/external/photobook`. NPM pubblica `80` e `443`;
|
||||
l'interfaccia amministrativa resta su `127.0.0.1:81`, raggiungibile via tunnel SSH.
|
||||
L'account di sistema `immich` usa UID/GID `1100`, shell senza login, nessuna appartenenza a `wheel` e
|
||||
i gruppi supplementari `video` e `render`. I Quadlet rootful di Immich Server, ML, cache compatibile
|
||||
Redis, PostgreSQL e NPM condividono una rete Podman. Immich viene eseguito come `1100:1100`; Server e
|
||||
ML ricevono `/dev/dri` e Photobook e montato in sola lettura su `/external/photobook`. NPM pubblica `80` e
|
||||
`443`, mentre l'amministrazione resta vincolata a `127.0.0.1:81` per l'accesso tramite tunnel SSH.
|
||||
|
||||
Atlas ospita temporaneamente Navidrome e Syncthing rootless fino alla sostituzione con Uranus. I
|
||||
servizi sono inizializzati **ex novo**, senza migrare lo stato precedente, rispettivamente sotto
|
||||
`/zpool/services/data/navidrome` e `/zpool/services/data/syncthing`; la musica in
|
||||
`/zpool/media/music` è stata popolata separatamente da `/zpool/archive/Music` il 2026-09-30;
|
||||
Navidrome ha completato la scansione. Il timer rootless `atlas-music-sync.timer` copia i file nuovi
|
||||
o modificati ogni giorno alle 00:45 Europe/Rome, senza eliminare quelli presenti solo nella
|
||||
destinazione; entrambi i dataset ZFS devono essere montati. La prima esecuzione schedulata è
|
||||
riuscita il 2026-10-02. Alcune playlist originali contengono
|
||||
ancora vecchi percorsi Windows. I servizi sono vincolati all'indirizzo LAN di Atlas
|
||||
(`192.168.178.55`), mai a WireGuard. `wireguard_overlay` collega invece Prometheus (`10.0.0.1`)
|
||||
e Aegis (`10.0.0.2`): le chiavi private restano sui rispettivi host e Ansible scambia solo le pubbliche.
|
||||
Prometheus apre `51820/udp`; Aegis inoltra soltanto il traffico overlay→LAN dichiarato e applica
|
||||
source NAT, evitando interfacce VPN su Atlas/Uranus e route statiche sul router. Navidrome (`4533/tcp`)
|
||||
e la GUI Syncthing (`8384/tcp`) ammettono solo Aegis, mentre le porte native Syncthing sono limitate
|
||||
alla LAN. Dopo la verifica dei servizi, configurare manualmente i Proxy Host NPM verso
|
||||
`http://192.168.178.55:4533` e `http://192.168.178.55:8384`. Il peer Prometheus include la LAN
|
||||
negli `AllowedIPs`; aggiungere la VIP Uranus quando esisterà. Dopo il reload di firewalld, Ansible
|
||||
ricarica le reti Podman rootful di Prometheus per conservare DNS e connettività del proxy.
|
||||
La fase 1 e limitata ai Quadlet utente rootless di Navidrome e Syncthing su Atlas. E abilitata nella
|
||||
configurazione host di Atlas e puo essere impostata a `false` solo per una sospensione intenzionale. Navidrome ufficiale `0.63.2` usa il database SQLite sotto `/data` e
|
||||
non supporta `ND_DATABASE_URL` ne un backend PostgreSQL esterno. Il servizio obsoleto `navidromedb`
|
||||
e quindi rimosso da Prometheus invece di essere replicato su Atlas. Il ruolo deriva i percorsi dal
|
||||
pool `zpool`, montato in `/zpool`: musica in sola lettura da `/zpool/media/music`, stato
|
||||
applicativo Navidrome e `navidrome.db` in `/zpool/archive/app_data/navidrome` e dati Syncthing in
|
||||
`/zpool/archive/app_data/syncthing`. `profile_atlas` crea questi dataset quando
|
||||
`atlas_manage_storage` e attivo; il ruolo backend verifica i mountpoint esatti prima di avviare i
|
||||
container. Il ruolo backend non crea mai il pool. Il ruolo separato `wireguard_overlay`
|
||||
gestisce `wg0` tra Prometheus (`10.0.0.1`) e Atlas (`10.0.0.2`), genera una sola volta le chiavi
|
||||
private sui rispettivi host e scambia tramite Ansible soltanto quelle pubbliche. Solo Prometheus apre
|
||||
pubblicamente `51820/udp`. Le porte backend sono ammesse esclusivamente nella zona firewalld WireGuard.
|
||||
|
||||
La migrazione Gitea da Prometheus ad Atlas è descritta in
|
||||
[`docs/atlas-gitea-migration.md`](docs/atlas-gitea-migration.md). Gitea usa un Quadlet rootless
|
||||
di `admin` su un dataset dedicato; l'immagine derivata mantiene UID/GID 1000 ma chiama l'utente
|
||||
interno `gitea`. NPM resta su Prometheus e l'HTTPS pubblico primario serve Atlas. L'SSH pubblico
|
||||
su TCP/2222 autentica la chiave `ikaros` e un `git ls-remote` è riuscito; l'operatore ha
|
||||
confermato pull e push SSH. Login e scrittura Git via HTTPS sono stati confermati il 2026-10-03. I dati sorgente restano
|
||||
conservati su Prometheus senza avviarne il vecchio container.
|
||||
`backend_phase1_start_services` resta falso durante il trasferimento dello stato applicativo, quindi
|
||||
la prima esecuzione reale del backend genera i Quadlet senza creare un database Atlas vuoto. Dopo aver
|
||||
arrestato Navidrome su Prometheus, copiare l'intera directory `/opt/navidrome/data/` in
|
||||
`/zpool/archive/app_data/navidrome/`, preservando `navidrome.db` e gli eventuali file SQLite laterali.
|
||||
Impostare quindi questa variabile a vero e rieseguire il ruolo per abilitare e avviare Navidrome e
|
||||
Syncthing. Il playbook non copia e non elimina mai i dati applicativi.
|
||||
|
||||
Validare il gateway con:
|
||||
Validare e generare i servizi Atlas con:
|
||||
|
||||
```bash
|
||||
ANSIBLE_LOCAL_TEMP=/tmp/ansible-local \
|
||||
ansible-playbook ansible/site.yml --limit prometheus,aegis --tags wireguard --check --diff
|
||||
```
|
||||
ansible-playbook ansible/site.yml --limit atlas --tags storage
|
||||
|
||||
La prima esecuzione reale WireGuard deve includere entrambi i peer. Se Aegis ha appena installato il
|
||||
layer `wireguard-tools`, riavviarlo manualmente e rieseguire senza `--check`: il ruolo attende un
|
||||
handshake effettivo.
|
||||
|
||||
Gli snapshot ZFS ricorsivi coprono l'intero pool: 24 orari al minuto 05, 30 giornalieri alle 00:15,
|
||||
8 settimanali la domenica alle 01:00 e 12 mensili il primo giorno alle 02:00. La retention elimina
|
||||
solo gli snapshot con prefisso gestito `atlas-auto` e non esegue rollback. Lo scrub OpenZFS mensile è
|
||||
previsto la prima domenica alle 03:00; il timer settimanale incompatibile è disabilitato. Il primo
|
||||
snapshot orario ricorsivo è riuscito e la pulizia pianificata della retention è stata osservata il
|
||||
2026-09-30. Il primo scrub mensile richiede ancora una verifica a runtime.
|
||||
|
||||
```bash
|
||||
ANSIBLE_LOCAL_TEMP=/tmp/ansible-local \
|
||||
ansible-playbook ansible/site.yml --limit atlas --tags snapshots,scrub --check --diff
|
||||
```
|
||||
ansible-playbook ansible/site.yml --limit prometheus,atlas --tags wireguard
|
||||
|
||||
Il backup Borg cifrato usa il sub-account Hetzner `u660064-sub1`, il repository relativo `./borg-data`
|
||||
e Borg remoto 1.4 su SSH porta 23. La chiave ED25519 del server è fissata; una chiave client dedicata
|
||||
appartiene all'account `borg`, bloccato e senza login, sudo o gruppi supplementari. La chiave privata
|
||||
resta in `/etc/atlas-borg`; la passphrase proviene da `vault_atlas_borg_passphrase` ed è resa in un
|
||||
file `0600`. Solo il wrapper root crea snapshot e mount; avvia il client come `borg` con il minimo
|
||||
accesso temporaneo in lettura, senza concedergli gestione ZFS o sudo.
|
||||
|
||||
Il backup giornaliero parte alle 04:30 con un ritardo casuale fino a 30 minuti. Crea uno snapshot ZFS
|
||||
ricorsivo temporaneo e ricostruisce tutti i dataset sotto `/zpool` in un albero di bind mount in sola
|
||||
lettura, per inserirli in un unico archivio coerente. Il wrapper smonta ricorsivamente l'albero privato;
|
||||
un helper `ExecStopPost` mirato rimuove eventuali mount dello snapshot nel namespace host e lo snapshot
|
||||
temporaneo dopo l'uscita del processo. Borg conserva 30 archivi giornalieri, 8 settimanali e 12
|
||||
mensili, poi compatta il repository. Il controllo completo di metadati e repository si svolge il 15
|
||||
di ogni mese alle 06:00. Le operazioni usano un lock comune, journal e retry systemd limitati. Le
|
||||
nuove esecuzioni riportano al massimo una riga di avanzamento al minuto: percentuale **stimata**,
|
||||
dataset, file elaborati e byte originali/compressi/deduplicati. Il denominatore è la somma dei
|
||||
`logicalreferenced` ZFS dello snapshot, non un totale Borg: può superare il 100% e non comprende
|
||||
retention, compattazione o controlli. Le righe di progresso non riportano i nomi dei file; eventuali
|
||||
warning possono farlo. Seguire il job con `sudo journalctl -fu atlas-borg-backup.service`; modifiche
|
||||
all'helper non cambiano un'esecuzione già avviata.
|
||||
|
||||
Attivazione iniziale esplicita:
|
||||
|
||||
1. Inserire una passphrase unica in `secrets/vault.yml` con `ansible-vault edit`.
|
||||
2. Generare e mostrare solo la chiave pubblica con
|
||||
`ansible-playbook ansible/site.yml --limit atlas --tags borg_key`.
|
||||
3. Installarla nel sub-account Hetzner, poi applicare con
|
||||
`ansible-playbook ansible/site.yml --limit atlas --tags packages,borg`.
|
||||
4. Copiare `secrets/recovery/atlas-borg-repokey.export` su un supporto davvero offline: la copia
|
||||
locale ignorata da Git non è di per sé un backup offline.
|
||||
|
||||
Il ruolo inizializza solo un repository `repokey` assente, non accetta password SSH né host key non
|
||||
fissate e non avvia manualmente il primo backup. Validazione:
|
||||
|
||||
```bash
|
||||
ANSIBLE_LOCAL_TEMP=/tmp/ansible-local \
|
||||
ansible-playbook ansible/site.yml --limit atlas --tags packages,borg --check --diff
|
||||
```
|
||||
ansible-playbook ansible/site.yml --limit atlas --tags backend_phase1 --check --diff
|
||||
|
||||
L'attivazione iniziale è riuscita: backup e controllo del repository, restore completo in una
|
||||
directory temporanea confrontato con l'albero `Archive`, esportazione offline della chiave di recupero
|
||||
e pulizia di snapshot/mount temporanei. Il 2026-09-25 un test separato da snapshot ZFS giornaliero ha
|
||||
copiato un file di `/zpool/archive` in `/var/tmp`, verificando contenuto, proprietario, modalità,
|
||||
mtime e ACL POSIX; copia e mount temporanei sono stati rimossi senza interrompere Borg. Non è un test
|
||||
di ripristino dell'intero dataset.
|
||||
|
||||
L'archivio del pool popolato del 2026-09-29 ha richiesto 1 h 32 min per 2,18 TB originali / 2,04 TB
|
||||
compressi, con 13,49 GB di dimensione deduplicata. Retention e compattazione sono riuscite, ma un
|
||||
errore di permessi su `RuntimeDirectory` ha impedito la pulizia dello snapshot dopo il job. Dopo la
|
||||
correzione, l'archivio incrementale del 2026-09-30 è terminato in circa 22 secondi, ha rimosso lo
|
||||
snapshot residuo e quello corrente ed è terminato con stato 0. Il monitor ha rilevato il 37% della
|
||||
quota Storage Box utilizzata. Questi risultati non predicono durata o compressione dei prossimi run.
|
||||
|
||||
Il backup USB offline è distribuito come **servizio solo manuale** (`atlas_manage_usb_backup: true`):
|
||||
Ansible non formatta, sblocca, monta né avvia automaticamente il disco. Il disco esistente è stato
|
||||
verificato in sola lettura il 2026-09-23: UUID LUKS `577b3c43-ea37-4611-81a9-39d555cdfbd4`,
|
||||
UUID ext4 interno `758e2d2e-a427-4797-aad9-39c3a9f17c7e`, mapper `zpool-backup`. All'ispezione
|
||||
era montato in `/mnt/zpool-backup`; il servizio richiede invece che il mapper **non sia montato** prima
|
||||
dell'avvio. Se serve, `systemd-ask-password` chiede interattivamente la passphrase LUKS tramite
|
||||
l'agente di `systemctl start` e la passa direttamente a `cryptsetup`, senza salvarla, esporla negli
|
||||
argomenti o memorizzarla nella cache. Lo script monta il disco privatamente, crea uno snapshot ZFS
|
||||
ricorsivo, copia tutti i dataset in `atlas/snapshots/<timestamp>/` con `rsync --link-dest`, verifica
|
||||
con un dry-run basato sui checksum, aggiorna atomicamente `atlas/latest`, smonta e chiude LUKS. Un
|
||||
errore non sostituisce `latest` né cancella versioni complete precedenti. Borg e USB possono operare
|
||||
contemporaneamente su snapshot distinti, ma la lettura concorrente può ridurre il throughput.
|
||||
|
||||
La copia USB conserva le ACL ma non gli attributi estesi generici, compreso `security.selinux`: la
|
||||
policy della destinazione deve ricreare le etichette dopo un restore. Per un percorso esplicito:
|
||||
|
||||
```bash
|
||||
ansible-playbook ansible/site.yml --limit atlas --tags restorecon \
|
||||
-e '{"atlas_restorecon_paths":["/zpool/archive"]}'
|
||||
```
|
||||
|
||||
Il task accetta solo percorsi sotto la radice del pool Atlas, esegue `restorecon -RFv` solo su quelli
|
||||
indicati ed è altrimenti inattivo; non va lanciato sull'intero pool durante i run ordinari. Le vecchie
|
||||
versioni USB non vengono eliminate automaticamente senza una retention deliberata. Il controllo di
|
||||
capacità include il trasferimento stimato e una riserva libera di 10 GiB. Dopo un backup riuscito,
|
||||
scollegare fisicamente il disco per renderlo davvero offline.
|
||||
|
||||
Validare la configurazione senza avviare il backup e, separatamente, un eventuale relabel pianificato:
|
||||
|
||||
```bash
|
||||
ANSIBLE_LOCAL_TEMP=/tmp/ansible-local \
|
||||
ansible-playbook ansible/site.yml --limit atlas --tags usb_backup,usb_reminder --check --diff
|
||||
ansible-playbook ansible/site.yml --limit atlas --tags restorecon --check \
|
||||
-e '{"atlas_restorecon_paths":["/zpool/archive"]}'
|
||||
ansible-playbook ansible/site.yml --limit atlas --tags backend_phase1
|
||||
```
|
||||
|
||||
Prima dell'avvio manuale smontare in sicurezza `/mnt/zpool-backup`, se ancora montato. Con il mapper
|
||||
chiuso, `sudo systemctl start atlas-usb-backup.service` chiede la passphrase e avvia il backup; né la
|
||||
password LUKS né un keyfile vanno in Ansible. Seguire con
|
||||
`sudo journalctl -fu atlas-usb-backup.service`. **Non esiste un timer di backup USB.** Soltanto
|
||||
`atlas-usb-reminder.timer` è schedulato il primo sabato del mese alle 10:00 `Europe/Rome`: invia un
|
||||
promemoria al notifier 45Drives Houston, senza avviare il backup. Un test manuale ha prodotto una
|
||||
notifica in 45Drives Alerts, **non un'email**; il log conferma l'invio della notifica, non la consegna
|
||||
di posta. Il primo evento pianificato era il 2026-10-03 alle 10:00 CEST. Controllare timer e risultato
|
||||
con `systemctl list-timers atlas-usb-reminder.timer` e in 45Drives Alerts.
|
||||
Per il cutover, arrestare il vecchio Navidrome prima di copiare la sua directory dati, verificare
|
||||
l'ownership dell'account `admin` su Atlas e confermare la presenza del database SQLite copiato prima
|
||||
di impostare `backend_phase1_start_services: true` in `host_vars/atlas.yml`. Conservare i dati sorgente
|
||||
e il container legacy `navidromedb` fermo finche Navidrome su Atlas e una prova di restore non sono
|
||||
stati validati.
|
||||
|
||||
Il primo tentativo USB del 2026-09-23 fallì su `security.selinux` e, dopo l'interruzione, lasciò
|
||||
snapshot e mapper aperti. Applicato il filtro rsync, furono rimossi lo snapshot fallito, il mapper
|
||||
smontato e lo stato failed; non rimase una copia valida di quel tentativo. Un run del 2026-09-24
|
||||
pubblicò una versione verificata ma fallì nella distruzione dello snapshot a causa di mount
|
||||
`.zfs/snapshot` aperti nel namespace host. Dopo la pulizia non forzata, è stato aggiunto un helper
|
||||
`ExecStopPost` mirato e testato con uno snapshot usa-e-getta. Un run successivo del 2026-09-24 ha
|
||||
verificato i checksum, pubblicato la versione ed è terminato con successo: mapper chiuso, nessuno
|
||||
snapshot USB temporaneo e pool sano. Il 2026-09-25 un test di restore indipendente ha aperto il disco
|
||||
in sola lettura, montato ext4 con `ro,noload`, copiato un file di 5.707.945 byte da `atlas/latest` in
|
||||
una directory vuota sotto `/var/tmp` e confrontato contenuto, proprietario, modalità, dimensione,
|
||||
mtime e ACL POSIX. Il test ha rimosso copia e mount temporanei, chiuso LUKS e lasciato il pool sano
|
||||
mentre Borg continuava. È un test su file, non un esercizio completo di disaster recovery.
|
||||
|
||||
Il monitoraggio Atlas è eseguito ogni 30 minuti da `atlas-health-monitor.timer`. Sonde in sola
|
||||
lettura controllano stato/errori del pool e dei vdev, scrub/resilver, SMART dei quattro dischi del
|
||||
pool e dell'NVMe di sistema, temperature dei dischi e CPU, spazio di sistema/pool/snapshot, crescita
|
||||
di `zpool/backup` e quota Hetzner tramite `df -m` via SSH con l'account `borg` e la chiave fissata.
|
||||
La query remota non apre il repository Borg né il suo lock. Gli alert di crescita richiedono una
|
||||
baseline di circa 24 ore. Sono controllati anche attivazione e freschezza dei timer; hook systemd
|
||||
`OnFailure` segnalano errori di snapshot, scrub, Borg, USB, promemoria e monitoraggio. Il monitor non
|
||||
riavvia Borg; avvisa solo se un run supera 14 giorni. Soglie e percorsi stabili dei dischi sono nelle
|
||||
variabili host. Gli avvisi usano 45Drives Houston con deduplicazione; **la consegna email non è stata
|
||||
verificata**. Il controllo live del 2026-09-25 non ha trovato problemi e ha inviato una notifica di
|
||||
prova. Il 2026-09-30 il monitor ha rilevato zero problemi e una quota Storage Box occupata al 37%.
|
||||
L'hook per i job falliti ora passa il nome letterale della unità systemd; l'espansione è stata
|
||||
verificata senza inviare un falso allarme.
|
||||
|
||||
```bash
|
||||
ansible-playbook ansible/site.yml --limit atlas --tags monitoring --check --diff
|
||||
sudo /usr/local/libexec/atlas-health-monitor --dry-run
|
||||
sudo journalctl -u atlas-health-monitor.service -n 100 --no-pager
|
||||
systemctl list-timers atlas-health-monitor.timer
|
||||
```
|
||||
|
||||
`--dry-run` non invia alert e non modifica lo stato del monitor. Un controllo reale si avvia con
|
||||
`sudo systemctl start atlas-health-monitor.service`, senza avviare servizi di backup. Per una prova
|
||||
etichettata di 45Drives Alerts usare
|
||||
`sudo /usr/local/libexec/atlas-health-monitor --test-notification`.
|
||||
|
||||
### Timer systemd di Atlas
|
||||
|
||||
Tutti i dieci timer gestiti sono abilitati. Gli orari sono locali ad Atlas (`Europe/Rome`); Borg e
|
||||
monitoraggio aggiungono il ritardo casuale indicato. Tutti hanno `Persistent=true`: un evento perso
|
||||
viene recuperato quando il timer torna attivo.
|
||||
|
||||
| Timer | Pianificazione (`OnCalendar`) | Azione |
|
||||
| --- | --- | --- |
|
||||
| `atlas-zfs-snapshot-hourly.timer` | `*-*-* *:05:00` — ogni ora al minuto 05 | Snapshot ricorsivo orario e retention |
|
||||
| `atlas-zfs-snapshot-daily.timer` | `*-*-* 00:15:00` — ogni giorno alle 00:15 | Snapshot ricorsivo giornaliero e retention |
|
||||
| `atlas-zfs-snapshot-weekly.timer` | `Sun *-*-* 01:00:00` — domenica alle 01:00 | Snapshot ricorsivo settimanale e retention |
|
||||
| `atlas-zfs-snapshot-monthly.timer` | `*-*-01 02:00:00` — primo giorno del mese alle 02:00 | Snapshot ricorsivo mensile e retention |
|
||||
| `zfs-scrub-monthly@zpool.timer` | `Sun *-*-01..07 03:00:00` — prima domenica alle 03:00 | Scrub ZFS |
|
||||
| `atlas-borg-backup.timer` | `*-*-* 04:30:00` — ogni giorno alle 04:30, più 0–30 min casuali | Backup cifrato offsite |
|
||||
| `atlas-borg-check.timer` | `*-*-15 06:00:00` — giorno 15 alle 06:00, più 0–30 min casuali | Controllo repository Borg |
|
||||
| `atlas-usb-reminder.timer` | `Sat *-*-01..07 10:00:00 Europe/Rome` — primo sabato alle 10:00 | Solo promemoria 45Drives Alerts |
|
||||
| `atlas-health-monitor.timer` | `*:0/30` — ogni mezz'ora, più 0–5 min casuali | Controlli di salute in sola lettura |
|
||||
| `atlas-prometheus-pull.timer` | `*-*-* 03:00:00 Europe/Rome` — ogni giorno alle 03:00 | Pull e verifica del backup preparato su Prometheus |
|
||||
|
||||
`atlas-usb-backup.service` **non ha timer** e va avviato manualmente. Il timer del fornitore
|
||||
`zfs-scrub-weekly@zpool.timer` è disabilitato a favore dello scrub mensile. Il timer di preparazione
|
||||
su Prometheus è attivo alle 02:00 Europe/Rome; il primo ciclo pianificato è riuscito il 2026-10-01.
|
||||
Un export, pull e ripristino temporaneo post-cutover NPM Quadlet sono riusciti il 2026-10-03;
|
||||
il primo ciclo pianificato dopo quel cutover resta da osservare. Durante un backup Borg attivo,
|
||||
`systemctl list-timers` può mostrare `-` per il prossimo evento senza che il timer sia disabilitato.
|
||||
Per vedere la pianificazione corrente: `systemctl list-timers --all` su Atlas.
|
||||
|
||||
Nextcloud è previsto come servizio temporaneo su Atlas prima di Uranus, ma solo dopo la validazione
|
||||
della protezione dei dati: richiede storage applicativo, database e cache separati, segreti Vault,
|
||||
pubblicazione solo tramite NPM e Aegis, procedure di backup, aggiornamento e migrazione. Non
|
||||
distribuirlo prima di completare la checklist di protezione dei dati.
|
||||
|
||||
Atlas è la destinazione dichiarata per iCloudPD. Ansible gestisce dataset, Quadlet rootless e
|
||||
`icloudpd.conf` privato con Apple ID dal Vault: foto in `/zpool/archive/Pictures/iCloudPD`,
|
||||
stato in `zpool/services/data/icloudpd`. Il primo avvio è stato manuale; password e MFA restano
|
||||
gestiti interattivamente, senza avvio automatico al boot. L'inizializzazione è stata completata e
|
||||
il download iniziale di foto e video è terminato il 2026-10-03. Su Aegis
|
||||
il servizio, il Quadlet e `/var/lib/icloudpd` sono stati rimossi e verificati; il playbook Aegis
|
||||
non contiene più task iCloudPD. L'accesso SMB e il ripristino dai backup dei nuovi dati restano
|
||||
da verificare. L'export NFS Photobook resta
|
||||
invariato. Dettagli in [`docs/atlas-icloudpd-migration.md`](docs/atlas-icloudpd-migration.md).
|
||||
|
||||
Il primo ciclo pianificato del backup di Prometheus e una prova di disaster recovery a dimensione reale
|
||||
restano da verificare. Il 2026-09-30 una VM Rocky isolata ha superato ricostruzione OS con Ansible,
|
||||
import del pool RAIDZ2 fittizio e ripristino da snapshot; RPO 24 ore/RTO 72 ore restano obiettivi
|
||||
provvisori, non tempi misurati. Dettagli e limiti sono in `docs/atlas-recovery.md`. Il backlog
|
||||
prioritizzato è in `AGENTS.md`.
|
||||
Restano da completare retention delle snapshot, topologia Syncthing, validazione WireGuard/firewall,
|
||||
pull di backup da Prometheus, backup cifrati con Borg su una Hetzner Storage Box, backup USB,
|
||||
monitoraggio e test di disaster recovery. Il backlog operativo dettagliato e in `AGENTS.md`.
|
||||
|
||||
---
|
||||
|
||||
@@ -627,8 +426,8 @@ Questo significa che, allo stato attuale:
|
||||
- `deadalus` riceve il profilo Fedora WSL tramite play dev dedicati
|
||||
- il server Rocky (`prometheus`) e gestito con pacchetti, servizi, dotfiles server e firewalld
|
||||
- il NAS Rocky (`atlas`) usa un pool ZFS gia esistente, condivisioni NFSv4/SMB limitate alla LAN e Cockpit/45Drives
|
||||
- NPM è un Quadlet rootful su Prometheus, mentre Gitea, Navidrome e Syncthing sono Quadlet
|
||||
rootless su Atlas; il fallback Compose server è stato rimosso
|
||||
- lo stack Compose server include soltanto `gitea` e `nginx-proxy-manager`; Navidrome e Syncthing
|
||||
della fase 1 sono Quadlet rootless su Atlas
|
||||
|
||||
# Dotfiles
|
||||
|
||||
@@ -734,10 +533,9 @@ ansible-playbook ansible/site.yml --limit <host> --tags <tag1>,<tag2> --check --
|
||||
ansible-playbook ansible/site.yml --limit <host> --start-at-task "<task name>" --check --diff
|
||||
ansible-lint ansible/roles/<role>
|
||||
yamllint ansible/path/to/file.yml
|
||||
ansible-playbook ansible/site.yml --limit prometheus --tags server_legacy_cleanup --check --diff -e server_legacy_cleanup=true
|
||||
podman-compose -f /opt/docker/server/docker-compose.yml config
|
||||
ansible-playbook ansible/site.yml --limit atlas --tags storage,sharing,containers --check --diff
|
||||
ansible-playbook ansible/site.yml --limit atlas --tags backend_phase1 --check --diff
|
||||
ansible-playbook ansible/site.yml --limit atlas --tags music_sync --check --diff
|
||||
```
|
||||
|
||||
## Tag supportati dal playbook
|
||||
@@ -753,7 +551,7 @@ Allo stato attuale `ansible/site.yml` espone questi tag:
|
||||
| Tag | Scopo | Ambito principale |
|
||||
| --- | --- | --- |
|
||||
| `always` | pre-task sempre eseguiti, inclusi caricamento vault e validazioni preliminari | common |
|
||||
| `ai_agents` | installazione agenti AI condivisi e distribuzione del contesto condiviso (bootstrap, regole, memoria ChatGPT) | Fedora, WSL |
|
||||
| `ai_agents` | installazione agenti AI condivisi | Fedora, WSL |
|
||||
| `atlas` | account, storage, condivisioni e container Atlas | NAS Atlas |
|
||||
| `backend_phase1` | Quadlet rootless Navidrome e Syncthing | NAS Atlas |
|
||||
| `containers` | Quadlet rootful Atlas | NAS Atlas |
|
||||
|
||||
604
README.md
604
README.md
@@ -63,33 +63,6 @@ nymph is allowed to break
|
||||
|
||||
`ikaros` is the stable personal Fedora/GNOME desktop. `nymph` is the laptop and gets the same shared desktop dotfiles while GNOME itself stays close to the Fedora defaults. The legacy `void` and `desktop` groups are compatibility parents; the main axes are `platform_*`, `role_*`, and `desktop_*`.
|
||||
|
||||
The official ChatGPT desktop RPM is installed only on `ikaros` and `nymph`
|
||||
through their `chatgpt_desktop_install_enabled` host overrides. The playbook
|
||||
configures OpenAI's signed RPM repository and imports its pinned RPM signing
|
||||
key before installation; subsequent updates are handled by DNF. Enabling
|
||||
`chatgpt_desktop_uninstall_enabled` removes the package, repository, and key.
|
||||
|
||||
## Deferred planned node: Cerberus
|
||||
|
||||
`cerberus` is a **postponed** management-plane node, pending the physical setup
|
||||
of the office in the new house. It is not yet an inventory host and no role or
|
||||
playbook targets it.
|
||||
|
||||
The planned hardware is a Lenovo ThinkCentre M700 Tiny (Intel Core i3-6100T,
|
||||
8 GB RAM, and a 256 GB SSD) with native 1 Gbps Ethernet. It will share Ikaros'
|
||||
monitor and peripherals through a multi-input KVM switch, using a passive
|
||||
DisplayPort-to-HDMI cable for its video connection. Fedora Sericea, the
|
||||
immutable Fedora variant with the Sway Wayland compositor, is the intended
|
||||
operating system.
|
||||
|
||||
Cerberus will be an isolated management plane: Ansible will run from a
|
||||
dedicated Toolbox environment to provision the future `uranus` cluster, rather
|
||||
than from Ikaros or an unmanaged host. Its rootless Podman observability stack
|
||||
will run Grafana, Prometheus, and Loki. The local SSD is the hot tier and
|
||||
retains metrics and logs for 30 days; scheduled exports will place older
|
||||
historical data on an NFS-mounted Atlas dataset as the cold tier. The detailed,
|
||||
implementation-gated plan is maintained in `AGENTS.md`.
|
||||
|
||||
## Desktop profiles
|
||||
|
||||
- `ikaros`: stable Fedora Workstation + GNOME desktop.
|
||||
@@ -116,7 +89,7 @@ The workstation receives two layers:
|
||||
- Fedora development setup through `workstation_dev_fedora`.
|
||||
- WSL setup with `systemd` through `workstation_dev_wsl`.
|
||||
|
||||
That gives it Fedora packages through DNF, Docker from the official repository, shared workstation dotfiles and templates, tmux helpers, and WSL systemd configuration. Windows applications are installed manually; the WSL profile does not manage Python remoting components for them.
|
||||
That gives it Fedora packages through DNF, Docker from the official repository, Mise from its official COPR repository with a pinned Eclipse Temurin Java 11 JDK, shared workstation dotfiles and templates, tmux helpers, and WSL systemd configuration. Windows applications are installed manually; the WSL profile does not manage Python remoting components for them.
|
||||
|
||||
### WSL workflow
|
||||
|
||||
@@ -127,36 +100,28 @@ That gives it Fedora packages through DNF, Docker from the official repository,
|
||||
|
||||
## Server
|
||||
|
||||
The public service domain transition to `fscotto.co`, Gitea canonical URL
|
||||
management, and remaining DuckDNS retirement steps are documented in
|
||||
[`docs/domain-fscotto-co.md`](docs/domain-fscotto-co.md).
|
||||
|
||||
`prometheus` is the Rocky Linux 9 server. It has no graphical environment and gets server-specific
|
||||
dotfiles and templates. The profile does not transfer application data, update DNS, or perform an
|
||||
implicit service cutover.
|
||||
dotfiles and templates. The profile provisions configuration only: it does not transfer data, start
|
||||
the Compose stack, update DNS, or perform a cutover.
|
||||
|
||||
The server profile installs platform-specific packages, Podman and podman-compose, declared systemd
|
||||
services, and firewalld. Nginx Proxy Manager runs as the rootful `prometheus-npm.service` Quadlet.
|
||||
On 2026-10-03 the operator-approved opt-in cleanup removed old Gitea, Navidrome and PostgreSQL
|
||||
data/images, empty legacy directories, the Gitea final-export helper and the Compose rollback files.
|
||||
The migrated services stay on Atlas. `server_legacy_stack_retired: true` prevents normal runs from
|
||||
recreating retired files. Data deletion requires `--tags server_legacy_cleanup` and
|
||||
`-e server_legacy_cleanup=true`; image-only cleanup has its own `server_image_cleanup` tag and flag.
|
||||
Active NPM resources and existing backup archives remain preserved.
|
||||
The post-cleanup export/pull and isolated SQLite restore passed; the first unattended cycle remains
|
||||
pending. Evidence and recovery boundaries:
|
||||
[`docs/prometheus-npm-quadlet.md`](docs/prometheus-npm-quadlet.md).
|
||||
|
||||
services, and firewalld. The manually activated `podman-compose-server` unit contains the existing
|
||||
Nginx Proxy Manager and Gitea services. The desired Compose file no longer includes Navidrome,
|
||||
Syncthing, or the obsolete Navidrome PostgreSQL database. Navidrome and Syncthing belong to Atlas;
|
||||
official Navidrome uses SQLite instead. Applying the profile does not stop or remove legacy
|
||||
containers and does not delete `/opt/postgres/data`.
|
||||
|
||||
Firewalld enables SSH, Cockpit (`9090/tcp`), HTTP and HTTPS. Nginx Proxy Manager publishes only
|
||||
`80/tcp` and `443/tcp`; its administration interface is bound to `127.0.0.1:81` and can be reached
|
||||
from Ikaros or Nymph with the `npm-tunnel` Bash alias. Nextcloud remains disabled and the profile
|
||||
does not provision any `/srv/nextcloud` directories.
|
||||
|
||||
NPM remains managed only by `profile_server`. Its WireGuard peer is Aegis (`10.0.0.2`), which forwards
|
||||
selected requests to LAN addresses and source-NATs them so no static route is required on the router.
|
||||
Use an Atlas LAN address for any current NAS-backed upstream; when Uranus receives its VIP, add that VIP
|
||||
to Prometheus' Aegis peer `AllowedIPs` and declare the corresponding proxy target separately.
|
||||
The Atlas phase-one work does not change this NPM deployment or its persistent data. Once WireGuard
|
||||
and the Atlas services are active, configure the current NPM proxy hosts with Navidrome upstream
|
||||
`http://10.0.0.2:4533` and Syncthing GUI upstream `http://10.0.0.2:8384`. Only the Syncthing web GUI
|
||||
uses NPM; synchronization traffic remains on explicitly published native ports bound only to the Atlas
|
||||
WireGuard address. Configure both Syncthing authentication and an appropriate NPM access policy before
|
||||
publishing its GUI.
|
||||
|
||||
Server identity comes from `server_username`, `server_user_group`, and `server_user_home` in `ansible/inventory/group_vars/server.yml`. `server_username` defaults to `username`, but it can be overridden, for example:
|
||||
|
||||
@@ -171,12 +136,45 @@ The target must already provide `server_username` with local sudo access.
|
||||
Prometheus authorizes its declared SSH public keys through separate files below
|
||||
`~/.ssh/authorized_keys.d/`, while `sshd` is configured to read those files directly.
|
||||
|
||||
### DuckDNS retirement
|
||||
### DuckDNS
|
||||
|
||||
DuckDNS support has been removed from the server profile: no tasks, templates,
|
||||
variables or enablement flags remain. Prometheus uses its static IP and `fscotto.co`.
|
||||
The local updater, log and cron job were already removed. The external DuckDNS
|
||||
name/account and existing encrypted token remain untouched for possible future use.
|
||||
`profile_server` renders `~/duckdns/duck.sh` with mode `0700`, keeping the existing updater path
|
||||
and `duck.log`. Set `server_duckdns_domain` in the server's host vars and store the **rotated**
|
||||
`vault_duckdns_token` in encrypted `secrets/vault.yml` (using `ansible-vault edit secrets/vault.yml`)
|
||||
or untracked `secrets/vault.local.yml`. Never commit the rendered script or put the token on a
|
||||
command line. Rendering hides secret output/diffs; the updater verifies TLS and passes the token
|
||||
to curl through stdin. The playbook neither runs the updater nor changes its external schedule.
|
||||
|
||||
```bash
|
||||
ansible-playbook ansible/site.yml --limit prometheus --tags duckdns --check --diff
|
||||
ansible-playbook ansible/site.yml --limit prometheus --tags duckdns
|
||||
```
|
||||
|
||||
An exposed token must be revoked/regenerated on DuckDNS: deleting it from Git history does not
|
||||
revoke it. After a history cleanup, re-clone other checkouts rather than merging the old history
|
||||
back in; preserve any uncommitted work separately without copying secrets.
|
||||
|
||||
### Data migration
|
||||
|
||||
Provision Rocky first, then run the migration script **on the retired Ubuntu source host**. It is
|
||||
dry-run by default and requires an explicit source-stack stop before it can copy application data:
|
||||
|
||||
```bash
|
||||
sudo ./scripts/migrate_prometheus_data.sh \
|
||||
--destination rocky@179.237.102.172 \
|
||||
--identity /root/.ssh/id_ed25519
|
||||
|
||||
sudo ./scripts/migrate_prometheus_data.sh \
|
||||
--destination rocky@179.237.102.172 \
|
||||
--identity /root/.ssh/id_ed25519 \
|
||||
--quiesce-source --execute
|
||||
```
|
||||
|
||||
The script copies only Nginx Proxy Manager and Gitea data. It does not delete data, move
|
||||
Navidrome/Syncthing, copy `/home/git/.ssh`, start containers, update DNS, or perform a cutover. The
|
||||
destination SSH host key must already be trusted and the destination account needs passwordless sudo
|
||||
for `rsync`. It preserves ACLs but not extended attributes, so source SELinux labels are not
|
||||
transferred; the Rocky Compose bind mounts apply their own `:Z` labels when containers start.
|
||||
|
||||
## DNS Filter
|
||||
|
||||
@@ -189,22 +187,16 @@ ansible/bootstrap/generate-aegis-ign.sh --write IMAGE DEVICE
|
||||
```
|
||||
|
||||
The controller manages it remotely as `pi@aegis`; unlike local desktop profiles, Aegis is
|
||||
intentionally an SSH inventory target. `profile_aegis` manages a rootful Podman Quadlet for AdGuard
|
||||
Home, its persistent data under `/var/lib`, the Podman auto-update timer, LAN-restricted
|
||||
firewalld rules, SSH key-only access for `pi`, the `nfs-utils` and `wireguard-tools` rpm-ostree layers,
|
||||
and `wake-ikaros`. `wireguard_overlay` makes Aegis the internal endpoint and LAN gateway for Prometheus:
|
||||
it enables persistent IPv4 forwarding, installs a scoped WireGuard-to-LAN firewalld policy, and source-NATs
|
||||
forwarded tunnel traffic so the router needs no static route. A new layered package deployment requires a manual reboot; the
|
||||
role reports this condition but never reboots Aegis automatically. Set the host-local
|
||||
`aegis_lan_subnet`, `aegis_adguard_web_port`, and `aegis_network_connection_uuid` values before
|
||||
applying it. The playbook permits
|
||||
intentionally an SSH inventory target. `profile_aegis` manages rootful Podman Quadlets for AdGuard
|
||||
Home and iCloudPD, persistent data under `/var/lib`, the Podman auto-update timer, LAN-restricted
|
||||
firewalld rules, SSH key-only access for `pi`, and `wake-ikaros`. Set the host-local
|
||||
`aegis_lan_subnet` and `aegis_adguard_web_port` values before applying it. The playbook permits
|
||||
AdGuard Home HTTP on port `80`; the initial wizard port `3000` is intentionally unmanaged and must be
|
||||
opened and closed manually during initial setup. The profile disables the local systemd-resolved DNS
|
||||
stub and points `/etc/resolv.conf` to its full resolver data, freeing port 53 for AdGuard. LAN clients
|
||||
may use AdGuard on Aegis, while Aegis itself uses the independent upstream DNS declared by
|
||||
`aegis_host_dns_servers`; this prevents Greenboot from depending on the AdGuard container during
|
||||
startup. Reboot Aegis after changing its NetworkManager DNS profile. iCloudPD was retired from Aegis;
|
||||
the Aegis role no longer contains iCloudPD tasks. Atlas iCloudPD config is Vault-backed; MFA is manual.
|
||||
stub and points `/etc/resolv.conf` to its full resolver data, freeing port 53
|
||||
for AdGuard while retaining DNS learned from the router. Define
|
||||
`vault_aegis_icloudpd_apple_id` in Vault before applying it. iCloudPD still requires interactive MFA
|
||||
initialization after its first deployment.
|
||||
|
||||
New Aegis images create the `admin` account in Butane. Before configuring a newly imaged node, run its
|
||||
first playbook execution with `-e ansible_user=admin`; the SSH hardening role then permits that same
|
||||
@@ -217,21 +209,6 @@ ANSIBLE_LOCAL_TEMP=/tmp/ansible-local \
|
||||
ansible-playbook ansible/site.yml --limit aegis --check --diff --ask-become-pass
|
||||
```
|
||||
|
||||
Apply only the independent host DNS configuration, then reboot Aegis manually:
|
||||
|
||||
```bash
|
||||
ANSIBLE_LOCAL_TEMP=/tmp/ansible-local \
|
||||
ansible-playbook ansible/site.yml --limit aegis --tags dns --ask-become-pass
|
||||
```
|
||||
|
||||
Layer the Aegis NFS and WireGuard client tools independently, then reboot Aegis manually when the role reports
|
||||
that the new deployment is ready:
|
||||
|
||||
```bash
|
||||
ANSIBLE_LOCAL_TEMP=/tmp/ansible-local \
|
||||
ansible-playbook ansible/site.yml --limit aegis --tags nfs --ask-become-pass
|
||||
```
|
||||
|
||||
## NAS
|
||||
|
||||
`atlas` is a Rocky Linux 9 NAS reached through SSH. Normally its pool already exists and the profile
|
||||
@@ -242,9 +219,12 @@ clients use NFSv4 and Windows/WSL clients use SMB; both are restricted to the co
|
||||
|
||||
For the first run, provide `vault_atlas_admin_password_hash`, `vault_atlas_samba_password`, and
|
||||
`vault_atlas_immich_db_password`. Bootstrap the host through its
|
||||
existing administrator. The explicit pool gate is safe to repeat: the role creates the RAIDZ2 pool only when
|
||||
it is absent. Atlas no longer participates in the WireGuard overlay; its old interface is retired manually only after
|
||||
Prometheus and Aegis have completed the replacement handshake.
|
||||
existing administrator:
|
||||
|
||||
```bash
|
||||
ansible-playbook ansible/site.yml --limit atlas \
|
||||
-e atlas_connection_username=<existing-admin>
|
||||
```
|
||||
|
||||
`vault_atlas_admin_password_hash` must be an `/etc/shadow`-compatible hash, not a clear-text
|
||||
Cockpit password. Subsequent runs use `atlas_admin_username`. Atlas declares storage, sharing, and its
|
||||
@@ -254,11 +234,11 @@ paths, and the Immich database secret are validated. Atlas reads its declared SS
|
||||
separate files below `~/.ssh/authorized_keys.d/`.
|
||||
|
||||
With storage management enabled, Atlas creates the complete dataset hierarchy below the existing or
|
||||
explicitly bootstrapped `zpool`: SMB-shared `archive`, private `services/data` with separate
|
||||
`services/data/navidrome` and `services/data/syncthing` application datasets, `media`, `media/music`,
|
||||
`media/photobook`, and `backup/hosts/prometheus`. Application/archive datasets use `zstd`, while media,
|
||||
Syncthing, and host-backup datasets use `lz4`; `backup` has a `500G` reservation covering its descendants.
|
||||
Atlas enforces targeted SELinux persistently and reports, without initiating, any reboot required to activate it. It assigns its primary LAN interface explicitly to the managed firewalld zone and applies persistent kernel network hardening: redirects and source routes are rejected, martians logged, reverse-path filtering remains loose for WireGuard, and IPv4 forwarding is disabled. SSH permits only the declared administrator using public-key authentication; root login, passwords,
|
||||
explicitly bootstrapped `zpool`: `work`, `archive`, `archive/app_data`, the separate `archive/app_data/navidrome` and
|
||||
`archive/app_data/syncthing` application datasets, `media`, `media/music`, `media/photobook`,
|
||||
`backups`, `backups/services`, and `backup_prometheus`. Application/archive datasets use `zstd`,
|
||||
while media, Syncthing and service-backup datasets use `lz4`; `backups/services` also has a `500G`
|
||||
refreservation. Atlas enforces targeted SELinux persistently and reports, without initiating, any reboot required to activate it. It assigns its primary LAN interface explicitly to the managed firewalld zone and applies persistent kernel network hardening: redirects and source routes are rejected, martians logged, reverse-path filtering remains loose for WireGuard, and IPv4 forwarding is disabled. SSH permits only the declared administrator using public-key authentication; root login, passwords,
|
||||
agent and remote forwarding are disabled, while local forwarding remains available for private administrative tunnels. SMB3 exposes `Archive` only to the configured Vault-backed
|
||||
Samba accounts on encrypted, signed SMB3 over TCP/445 only and admits the configured LAN without host-specific
|
||||
exclusions. NFSv4 exports only `media/photobook` to the configured Aegis IP over TCP/2049, using
|
||||
@@ -270,281 +250,51 @@ and NPM Quadlets share one Podman network. Immich runs as `1100:1100`; Server an
|
||||
and Photobook is mounted read-only at `/external/photobook`. NPM publishes ports `80` and `443`; its
|
||||
administration interface remains restricted to `127.0.0.1:81` for SSH-tunnel access.
|
||||
|
||||
Atlas temporarily hosts rootless Navidrome and Syncthing until Uranus replaces them. They bind only to
|
||||
Atlas' LAN address (`192.168.178.55`); WireGuard remains exclusively between Prometheus (`10.0.0.1`)
|
||||
and Aegis (`10.0.0.2`). Their state is initialized ex novo in `/zpool/services/data/navidrome` and
|
||||
`/zpool/services/data/syncthing`; no source application state is migrated. The music library at
|
||||
`/zpool/media/music` was populated separately from `/zpool/archive/Music` on 2026-09-30;
|
||||
Navidrome completed its library scan. The rootless `atlas-music-sync.timer` copies new and changed
|
||||
files daily at 00:45 Europe/Rome, without deleting destination-only files. Both ZFS datasets must
|
||||
be mounted. Its first scheduled run succeeded on 2026-10-02. Some source playlists still contain
|
||||
obsolete Windows paths.
|
||||
Phase 1 is limited to rootless Navidrome and Syncthing user Quadlets on Atlas. It is enabled in the
|
||||
Atlas host configuration and can be set to `false` only for a deliberate suspension. Official Navidrome `0.63.2` uses its SQLite database below `/data`; it does
|
||||
not support `ND_DATABASE_URL` or an external PostgreSQL backend. The obsolete `navidromedb` service
|
||||
was therefore removed from Prometheus instead of being reproduced on Atlas. The role derives all
|
||||
storage paths from the `zpool` mounted at `/zpool`: music is read-only at
|
||||
`/zpool/media/music`, Navidrome application state and `navidrome.db` are stored at
|
||||
`/zpool/archive/app_data/navidrome`, and Syncthing persists at
|
||||
`/zpool/archive/app_data/syncthing`. `profile_atlas` creates these datasets when
|
||||
`atlas_manage_storage` is enabled; the backend role verifies their exact mountpoints before starting
|
||||
containers. The backend role never creates the pool. The separate `wireguard_overlay` role manages `wg0`
|
||||
between Prometheus (`10.0.0.1`) and Atlas (`10.0.0.2`), generating private keys once
|
||||
on their respective hosts and exchanging only public keys through Ansible. Prometheus alone opens
|
||||
`51820/udp` publicly. Backend ports are admitted only in the WireGuard firewalld zone.
|
||||
|
||||
The Gitea move from Prometheus to Atlas is tracked in
|
||||
[`docs/atlas-gitea-migration.md`](docs/atlas-gitea-migration.md). The final consistent copy runs in
|
||||
Atlas' dedicated dataset under `admin`'s rootless user Quadlet. Its pinned derived image uses an
|
||||
internal Unix user named `gitea` (UID/GID 1000), while clone URLs keep `git@`. NPM remains on Prometheus and the primary
|
||||
public HTTPS route serves Atlas. Public SSH/2222 authenticates the `ikaros` key and serves
|
||||
`git ls-remote`; the operator also confirmed SSH pull and push. HTTPS login and Git writes were
|
||||
confirmed on 2026-10-03. The old Gitea data remains on Prometheus, but its container
|
||||
is absent from the desired stack.
|
||||
`backend_phase1_start_services` stays false during the application-state transfer, so the first real
|
||||
backend run renders the Quadlets without creating an empty Atlas database. After stopping Navidrome
|
||||
on Prometheus, copy the complete `/opt/navidrome/data/` directory into
|
||||
`/zpool/archive/app_data/navidrome/`, preserving `navidrome.db` and any SQLite sidecar files. Then set
|
||||
this variable to true and rerun the role to enable and start Navidrome and Syncthing. The playbook
|
||||
never copies or deletes application data.
|
||||
|
||||
The separate `wireguard_overlay` role manages `wg0` between Prometheus (`10.0.0.1`) and Aegis
|
||||
(`10.0.0.2`), generating private keys once on their respective hosts and exchanging only public keys
|
||||
through Ansible. Prometheus alone opens `51820/udp`. Aegis forwards only the declared overlay-to-LAN
|
||||
traffic and source-NATs it, so Atlas and future Uranus nodes require neither a VPN interface nor a router
|
||||
static route. Atlas permits Navidrome (`4533/tcp`) and the Syncthing GUI (`8384/tcp`) only from Aegis;
|
||||
Syncthing native ports are limited to the LAN. Configure NPM manually with
|
||||
`http://192.168.178.55:4533` and `http://192.168.178.55:8384` after the services are healthy.
|
||||
Prometheus' peer includes the LAN subnet in `AllowedIPs`; add the Uranus VIP there when it exists.
|
||||
When the WireGuard zone is created, Ansible reloads firewalld and immediately reloads Prometheus'
|
||||
rootful Podman networks so the existing proxy stack retains container DNS and connectivity.
|
||||
|
||||
Validate the gateway with:
|
||||
Validate and render the Atlas services with:
|
||||
|
||||
```bash
|
||||
ANSIBLE_LOCAL_TEMP=/tmp/ansible-local \
|
||||
ansible-playbook ansible/site.yml --limit prometheus,aegis --tags wireguard --check --diff
|
||||
```
|
||||
ansible-playbook ansible/site.yml --limit atlas --tags storage
|
||||
|
||||
The first real WireGuard run must include both peers. If Fedora IoT has just layered `wireguard-tools`,
|
||||
reboot Aegis manually and rerun the command without `--check`; the role then waits for a real peer
|
||||
handshake.
|
||||
|
||||
Atlas declares recursive, systemd-timed ZFS snapshots for the complete pool hierarchy: 24 hourly
|
||||
snapshots at minute 05, 30 daily snapshots at 00:15, 8 weekly snapshots on Sunday at 01:00, and 12
|
||||
monthly snapshots on the first day at 02:00. The retention helper prunes only snapshots carrying its
|
||||
managed `atlas-auto` prefix and never rolls back a dataset. The OpenZFS monthly scrub timer is scheduled
|
||||
for the first Sunday at 03:00; the conflicting weekly scrub timer is disabled explicitly. The first recursive
|
||||
hourly snapshot completed successfully on Atlas, and scheduled retention pruning was observed on
|
||||
2026-09-30. The first monthly scrub still awaits runtime evidence. Validate this layer independently with:
|
||||
|
||||
```bash
|
||||
ANSIBLE_LOCAL_TEMP=/tmp/ansible-local \
|
||||
ansible-playbook ansible/site.yml --limit atlas --tags snapshots,scrub --check --diff
|
||||
```
|
||||
ansible-playbook ansible/site.yml --limit prometheus,atlas --tags wireguard
|
||||
|
||||
Atlas also declares an encrypted Borg backup to the dedicated Hetzner Storage Box sub-account
|
||||
`u660064-sub1`. The repository is the sub-account-relative `./borg-data` path and uses the explicitly
|
||||
selected remote Borg 1.4 binary over SSH port 23. The ED25519 server key is pinned; a dedicated client
|
||||
key is generated for the locked, non-login `borg` system account, and its private half never leaves
|
||||
`/etc/atlas-borg`. The account has no sudo or supplementary groups and owns only its SSH identity,
|
||||
passphrase, cache, and Borg state. Borg receives its passphrase through a mode `0600` file rendered from
|
||||
`vault_atlas_borg_passphrase`.
|
||||
|
||||
The daily backup starts at 04:30 with up to 30 minutes of randomized delay. It creates a temporary,
|
||||
recursive ZFS snapshot and reconstructs every dataset below `/zpool` as a read-only bind-mounted tree,
|
||||
so parent and child datasets enter one consistent Borg archive. The wrapper recursively unmounts its
|
||||
private source tree; a narrowly scoped `ExecStopPost` helper removes any remaining host-namespace ZFS
|
||||
snapshot mounts and the named temporary snapshot after the backup process exits. Only the root wrapper
|
||||
performs snapshot and mount operations; it launches the Borg client as `borg` with temporary read-search
|
||||
capability and no ZFS, sudo, or pool-management privileges. Borg retains 30 daily, 8 weekly, and 12
|
||||
monthly archives, then compacts the standard
|
||||
read-write repository. A full metadata and repository check runs as `borg` on the fifteenth day of each
|
||||
month at 06:00. Both operations use a common lock, journal logging, and bounded systemd retries.
|
||||
New backup runs also log the create phase and a compact progress line at most once per minute: an
|
||||
**estimated** percentage, dataset, files processed, and original/compressed/deduplicated bytes. The
|
||||
denominator is the summed ZFS `logicalreferenced` size of the backup's own recursive snapshot, not a
|
||||
Borg-reported total: the estimate can exceed 100% and does not cover retention, compaction, or checks.
|
||||
Progress lines omit individual filenames; warnings may still name affected files.
|
||||
Follow the current run with
|
||||
`sudo journalctl -fu atlas-borg-backup.service` on Atlas; changes to the helper do not alter a run
|
||||
already in progress.
|
||||
|
||||
Initial activation remains explicit:
|
||||
|
||||
1. Add a strong unique `vault_atlas_borg_passphrase` with `ansible-vault edit secrets/vault.yml`.
|
||||
2. Generate and display only the dedicated public key with
|
||||
`ansible-playbook ansible/site.yml --limit atlas --tags borg_key`.
|
||||
3. Install that public key in the Hetzner sub-account, then apply with
|
||||
`ansible-playbook ansible/site.yml --limit atlas --tags packages,borg`.
|
||||
4. Copy the ignored `secrets/recovery/atlas-borg-repokey.export` file to genuinely offline storage.
|
||||
The controller-side copy is not an offline backup by itself.
|
||||
|
||||
The role initializes only the missing `repokey` repository and never accepts an unpinned host key or
|
||||
password authentication. It does not start the first backup manually. Validate the rendered state with:
|
||||
|
||||
```bash
|
||||
ANSIBLE_LOCAL_TEMP=/tmp/ansible-local \
|
||||
ansible-playbook ansible/site.yml --limit atlas --tags packages,borg --check --diff
|
||||
```
|
||||
ansible-playbook ansible/site.yml --limit atlas --tags backend_phase1 --check --diff
|
||||
|
||||
Atlas runtime activation is complete: the initial backup and repository check succeeded, a full restore
|
||||
to a temporary directory was validated against the live `Archive` tree, the recovery-key export was copied
|
||||
to offline storage, and the temporary snapshot and bind mounts were cleaned up.
|
||||
The populated-pool archive on 2026-09-29 took 1 h 32 min for 2.18 TB original / 2.04 TB compressed
|
||||
data, with a 13.49 GB deduplicated archive size. Retention and compaction succeeded, but a
|
||||
`RuntimeDirectory` permission error prevented post-exit snapshot cleanup. After correction, the
|
||||
2026-09-30 incremental archive completed in about 22 seconds, removed the stale and current temporary
|
||||
snapshots, and ended with service status 0. The monitor reported 37% Storage Box quota used. These
|
||||
observations do not predict the duration or compression ratio of future runs.
|
||||
On 2026-09-25 a separate ZFS restore smoke test copied a small file from an automatic daily
|
||||
`zpool/archive` snapshot to `/var/tmp`, then confirmed matching contents, ownership, mode, mtime and
|
||||
POSIX ACL. The temporary copy and on-demand snapshot mount were removed; Borg kept running. This
|
||||
does not validate a full dataset recovery.
|
||||
|
||||
The offline USB backup is deployed as a manual-only service (`atlas_manage_usb_backup: true`):
|
||||
Ansible never formats, unlocks, mounts, backs up to, or schedules the disk. Atlas' existing USB disk was verified
|
||||
read-only on 2026-09-23 as LUKS UUID `577b3c43-ea37-4611-81a9-39d555cdfbd4`, containing ext4 UUID
|
||||
`758e2d2e-a427-4797-aad9-39c3a9f17c7e` through mapper `zpool-backup`. It was mounted at
|
||||
`/mnt/zpool-backup` at inspection time. The service deliberately requires the verified mapper to be
|
||||
**not mounted** before starting. When necessary, `systemd-ask-password` requests the LUKS passphrase
|
||||
through the `systemctl start` password agent; it is piped directly to `cryptsetup` without saving it,
|
||||
passing it as a command argument, or caching it. The service then mounts the disk privately, takes a recursive ZFS snapshot,
|
||||
copies every dataset to a versioned `atlas/snapshots/<timestamp>/` directory using `rsync --link-dest`,
|
||||
verifies the result with a checksum-based dry run, atomically updates `atlas/latest`, unmounts and closes
|
||||
LUKS. A failed run never replaces `latest` or removes an earlier complete version. Borg and the USB
|
||||
backup may run concurrently from separate snapshots; both reading the same pool can reduce throughput.
|
||||
The USB copy preserves ACLs but not generic extended attributes; `security.selinux` is also intentionally
|
||||
excluded because the target SELinux policy must recreate labels during a restore. Do not restore data into
|
||||
service paths without relabeling. After restoring an explicit dataset path, apply its destination policy with:
|
||||
|
||||
```bash
|
||||
ansible-playbook ansible/site.yml --limit atlas --tags restorecon \
|
||||
-e '{"atlas_restorecon_paths":["/zpool/archive"]}'
|
||||
```
|
||||
|
||||
The task accepts only paths below the Atlas pool mount root, runs `restorecon -RFv` only for the paths
|
||||
provided at invocation, and is otherwise a no-op. It must not be used on the whole pool during routine runs.
|
||||
Old USB versions are not pruned automatically, to avoid deleting the only offline
|
||||
copy without an explicitly chosen retention policy; capacity checks include an estimated transfer size
|
||||
and a 10 GiB free-space reserve. The disk must be physically disconnected after a successful backup
|
||||
to make the copy offline.
|
||||
|
||||
To check the USB backup and reminder configuration without starting a backup, run:
|
||||
|
||||
```bash
|
||||
ANSIBLE_LOCAL_TEMP=/tmp/ansible-local \
|
||||
ansible-playbook ansible/site.yml --limit atlas --tags usb_backup,usb_reminder --check --diff
|
||||
ansible-playbook ansible/site.yml --limit atlas --tags backend_phase1
|
||||
```
|
||||
|
||||
To validate a planned, explicit post-restore relabel operation without changing labels, run:
|
||||
For the cutover, stop the old Navidrome writer before copying its data directory, verify ownership by
|
||||
the Atlas `admin` account and confirm that the copied SQLite database is present before changing
|
||||
`backend_phase1_start_services: true` in `host_vars/atlas.yml`. Keep the source data and the stopped
|
||||
legacy `navidromedb` container until Navidrome on Atlas and a restore test have been validated.
|
||||
|
||||
```bash
|
||||
ansible-playbook ansible/site.yml --limit atlas --tags restorecon --check \
|
||||
-e '{"atlas_restorecon_paths":["/zpool/archive"]}'
|
||||
```
|
||||
|
||||
Before the first **manual** service start, safely unmount the currently mounted
|
||||
`/mnt/zpool-backup`; never run it on an arbitrary mounted disk. Future starts
|
||||
can begin with the mapper closed: `sudo systemctl start atlas-usb-backup.service` prompts for the
|
||||
passphrase interactively and then performs the backup. Neither the LUKS password nor a key file belongs
|
||||
in Ansible. Inspect the run with
|
||||
`sudo journalctl -fu atlas-usb-backup.service`. There is intentionally no timer. Independently test a
|
||||
read-only mount and restore from `atlas/latest` into an empty temporary directory before marking the
|
||||
USB recovery path complete. Only `atlas-usb-reminder.timer` is enabled, for the first Saturday of each
|
||||
month at 10:00 Europe/Rome. Its warning notification uses the existing 45Drives Houston notifier.
|
||||
A manual test confirmed a notification in 45Drives Alerts, **not** an email. The reminder service log
|
||||
reports notification submission, not email delivery; the role does not depend on SMTP/OAuth settings.
|
||||
The reminder never starts the backup. Check its schedule with
|
||||
`systemctl list-timers atlas-usb-reminder.timer` and the result in 45Drives Alerts.
|
||||
The timer was verified active with its first scheduled run at 2026-10-03 10:00 CEST. No email
|
||||
delivery is claimed.
|
||||
The first manual USB attempt on 2026-09-23 did not complete: rsync was denied while removing
|
||||
`security.selinux` on the USB filesystem, then the interrupted service left its recursive
|
||||
`atlas-usb-20260923T185748Z-2469168` snapshot and the `zpool-backup` LUKS mapper open. The
|
||||
rsync xattr filter was deployed afterward. The incomplete USB directory was absent on inspection;
|
||||
the exact failed snapshot was removed, the verified and unmounted mapper closed, and the service
|
||||
failed state cleared. A final check found no remnant snapshot, mount, mapper, or staging directory.
|
||||
The failed attempt was not a valid backup, and no USB restore had been tested at that point.
|
||||
On 2026-09-24 a later run reported a checksum-verified, published USB version and closed the LUKS
|
||||
mapper, but the service failed while destroying its temporary ZFS snapshot: OpenZFS still had
|
||||
on-demand `.zfs/snapshot` mounts open in the host namespace. Those exact temporary snapshots were
|
||||
unmounted normally and removed; no force or rollback was used. The backup service now records its
|
||||
snapshot name and runs a narrowly scoped `ExecStopPost` cleanup after the private backup process
|
||||
exits. The cleanup helper was tested with a disposable recursive snapshot and an active snapshot
|
||||
mount. A complete run on 2026-09-24 later checksum-verified and published a new USB version; the
|
||||
service ended successfully, the LUKS mapper closed, no temporary USB snapshot remained, and the pool
|
||||
was healthy. On 2026-09-25 an independent restore test opened the configured USB disk read-only, mounted
|
||||
ext4 with `ro,noload`, restored a 5,707,945-byte file from the published `atlas/latest` version to an
|
||||
empty `/var/tmp` directory, and matched its content, owner, mode, size, mtime, and POSIX ACL against
|
||||
the USB source. The test removed its temporary copy and mount, closed the LUKS mapper, and left the
|
||||
pool healthy while Borg continued running. This is a file-level recovery smoke test, not a full dataset
|
||||
or disaster-recovery exercise.
|
||||
|
||||
Atlas health monitoring runs every 30 minutes through `atlas-health-monitor.timer`. Its read-only probes
|
||||
check pool/vdev state and errors, scrub/resilver status, four pool disks and the system NVMe via SMART,
|
||||
disk and CPU temperatures, system/pool/snapshot space, local `zpool/backup` growth, and the Hetzner
|
||||
Storage Box quota via `df -m` over the dedicated `borg` account's pinned-key SSH connection. The remote
|
||||
query never opens the Borg repository or its lock. Growth alerts compare against a roughly 24-hour
|
||||
baseline and therefore begin only after enough samples exist. The monitor also checks
|
||||
maintenance/backup timer activation and freshness; systemd `OnFailure` hooks report snapshot,
|
||||
scrub, Borg, USB, reminder, and monitoring services when they enter the failed state. An ongoing
|
||||
Borg run is never restarted by the monitor; only a run exceeding 14 days raises a warning.
|
||||
Thresholds and stable disk paths are declared in Atlas host variables. Alerts use the existing 45Drives
|
||||
Houston notifier and repeated issues are deduplicated; **email delivery is not verified**. The
|
||||
2026-09-25 live probe found no issues and a labelled test notification was submitted. On 2026-09-30
|
||||
the monitor reported zero issues and 37% Storage Box quota used. The failed-job hook now passes the
|
||||
literal systemd unit name; its expansion was verified without sending a false failure notification.
|
||||
|
||||
```bash
|
||||
ansible-playbook ansible/site.yml --limit atlas --tags monitoring --check --diff
|
||||
sudo /usr/local/libexec/atlas-health-monitor --dry-run
|
||||
sudo journalctl -u atlas-health-monitor.service -n 100 --no-pager
|
||||
systemctl list-timers atlas-health-monitor.timer
|
||||
```
|
||||
|
||||
`--dry-run` sends no alerts and does not change monitor state. A real check is
|
||||
`sudo systemctl start atlas-health-monitor.service`; do not start the backup services merely to test
|
||||
monitoring. For a labelled 45Drives Alerts delivery test, use
|
||||
`sudo /usr/local/libexec/atlas-health-monitor --test-notification`.
|
||||
|
||||
### Atlas systemd timers
|
||||
|
||||
All ten managed timers below are enabled. Times are local to Atlas (`Europe/Rome`); Borg and monitoring
|
||||
add the indicated randomized delay. Every timer has `Persistent=true`, so a missed calendar run is
|
||||
scheduled after the timer becomes active again.
|
||||
|
||||
| Timer | Schedule (`OnCalendar`) | Action |
|
||||
| --- | --- | --- |
|
||||
| `atlas-zfs-snapshot-hourly.timer` | `*-*-* *:05:00` — every hour at :05 | Recursive hourly snapshot and retention |
|
||||
| `atlas-zfs-snapshot-daily.timer` | `*-*-* 00:15:00` — daily at 00:15 | Recursive daily snapshot and retention |
|
||||
| `atlas-zfs-snapshot-weekly.timer` | `Sun *-*-* 01:00:00` — Sunday at 01:00 | Recursive weekly snapshot and retention |
|
||||
| `atlas-zfs-snapshot-monthly.timer` | `*-*-01 02:00:00` — first day of the month at 02:00 | Recursive monthly snapshot and retention |
|
||||
| `zfs-scrub-monthly@zpool.timer` | `Sun *-*-01..07 03:00:00` — first Sunday at 03:00 | ZFS scrub |
|
||||
| `atlas-borg-backup.timer` | `*-*-* 04:30:00` — daily at 04:30, plus 0–30 min random delay | Encrypted offsite backup |
|
||||
| `atlas-borg-check.timer` | `*-*-15 06:00:00` — 15th of the month at 06:00, plus 0–30 min random delay | Borg repository check |
|
||||
| `atlas-usb-reminder.timer` | `Sat *-*-01..07 10:00:00 Europe/Rome` — first Saturday at 10:00 | 45Drives Alerts reminder only |
|
||||
| `atlas-health-monitor.timer` | `*:0/30` — every half-hour, plus 0–5 min random delay | Read-only health checks |
|
||||
| `atlas-prometheus-pull.timer` | `*-*-* 03:00:00 Europe/Rome` — daily at 03:00 | Pull and verify the prepared Prometheus backup |
|
||||
|
||||
`atlas-usb-backup.service` has **no timer**: the encrypted USB backup must be started manually.
|
||||
The vendor's `zfs-scrub-weekly@zpool.timer` is intentionally disabled in favor of the monthly scrub.
|
||||
The Prometheus export timer runs at 02:00 Europe/Rome. Its first scheduled export and Atlas pull
|
||||
passed on 2026-10-01; a manual post-NPM-Quadlet export, pull, and temporary restore passed on
|
||||
2026-10-03. The first scheduled cycle after that cutover remains to be observed. While a
|
||||
Borg backup is still running, `systemctl list-timers` may show `-` for its next trigger; this does not
|
||||
mean the timer has been disabled. Inspect the current schedule on Atlas with
|
||||
`systemctl list-timers --all`.
|
||||
|
||||
A temporary Nextcloud deployment on Atlas is also planned before Uranus: it requires separately
|
||||
declared persistent application, database, and cache storage, Vault-backed credentials, NPM-only
|
||||
publishing through Aegis, and defined backup, upgrade, and eventual migration procedures. Do not deploy
|
||||
it before the data-protection checklist is complete.
|
||||
|
||||
Atlas is the declared iCloud photo-ingestion host. Ansible manages the rootless Quadlet, a private
|
||||
Vault-backed `icloudpd.conf`, photos under `/zpool/archive/Pictures/iCloudPD`, and separate state in
|
||||
`zpool/services/data/icloudpd`. The service was started manually; Ansible does not enable automatic
|
||||
startup or manage the password and MFA keyring. The operator initialized MFA interactively; on
|
||||
2026-10-03 the initial photo/video download completed. Aegis iCloudPD, including its service data,
|
||||
has been removed and verified; the Aegis role no longer manages it. Backup/restore and SMB access
|
||||
for the new data remain unverified. The Photobook NFS export remains untouched. See
|
||||
[`docs/atlas-icloudpd-migration.md`](docs/atlas-icloudpd-migration.md).
|
||||
|
||||
The first scheduled Prometheus backup runs and production-size disaster-recovery tests remain follow-up work. The prioritized
|
||||
operational backlog is kept in `AGENTS.md`.
|
||||
|
||||
Priority 2 procedures and decisions are recorded in
|
||||
[`docs/atlas-recovery.md`](docs/atlas-recovery.md),
|
||||
[`docs/atlas-updates.md`](docs/atlas-updates.md), and
|
||||
[`docs/atlas-sharing-decision.md`](docs/atlas-sharing-decision.md).
|
||||
The provisional Atlas recovery objectives are RPO 24 hours and RTO 72 hours;
|
||||
an isolated small-VM OS rebuild, pool import, Ansible reapplication, and
|
||||
snapshot restore passed, but full-size recovery time is unmeasured. `Archive` (SMB) and
|
||||
`photobook` (NFS) remain deliberately separate.
|
||||
The Prometheus pull architecture and manual export/pull/restore evidence are in
|
||||
[`docs/prometheus-backup.md`](docs/prometheus-backup.md). Both daily timers are
|
||||
enabled; their first scheduled runs remain to be verified.
|
||||
Snapshot retention, Syncthing topology, WireGuard/firewall validation, Prometheus backup pulls,
|
||||
encrypted Borg backups to a Hetzner Storage Box, USB backup, monitoring, and disaster-recovery tests
|
||||
remain follow-up work. The detailed operational backlog is kept in `AGENTS.md`.
|
||||
|
||||
## How layering works
|
||||
|
||||
@@ -577,10 +327,9 @@ ansible-playbook ansible/site.yml --limit <host> --tags emacs -e emacs_enabled=t
|
||||
## AI coding agents
|
||||
|
||||
The shared npm-managed agents are OpenCode, Claude Code, Codex, Gemini CLI, and
|
||||
GitHub Copilot; IBM Bob is also managed on Fedora workstations. Codex Relay is installed
|
||||
only on `ikaros`. On WSL (`deadalus`), Claude Code is the only installed coding agent. Each agent has its own lifecycle flags in
|
||||
`ansible/inventory/group_vars/all.yml`, so one agent can be installed,
|
||||
configured, or removed without affecting the others:
|
||||
GitHub Copilot; IBM Bob is also managed on `deadalus`. Each agent has its own
|
||||
lifecycle flags in `ansible/inventory/group_vars/all.yml`, so one agent can be
|
||||
installed, configured, or removed without affecting the others:
|
||||
|
||||
```yaml
|
||||
ai_agents:
|
||||
@@ -598,48 +347,6 @@ instructions, credentials, and user data. Installation and removal are mutually
|
||||
exclusive per agent: the playbook fails before making changes when both flags are
|
||||
true for the same agent. Servers set `ai_agents: {}` and therefore manage none.
|
||||
|
||||
On WSL (`deadalus`), Claude Code, Codex and the Cline CLI are installed through
|
||||
`profile_workstation_dev_common`. Every other managed coding agent is disabled through
|
||||
host overrides and its managed npm package or `bob` binary is selected for removal.
|
||||
`cline_deploy_enabled: true` also keeps Cline's cross-tool AGENTS pointer, global rules,
|
||||
and shared `~/.config/ai` context deployed on the WSL host for the ecaas/cdp devcontainers.
|
||||
Existing configuration, credentials, and user data are left untouched.
|
||||
|
||||
The shared agent context is centralized in `dotfiles/common/.config/ai/` and
|
||||
deployed to `~/.config/ai/` for every enabled agent: `bootstrap.md` (operating
|
||||
context), `AGENTS.md` (task-specific file dispatcher), plus `knowledge/`,
|
||||
`rules/`, and `patterns/`. Each agent is wired to it: OpenCode through the
|
||||
`instructions` array in `opencode.json`, Codex through `model_instructions_file`
|
||||
plus the global `~/.codex/AGENTS.md`, Gemini CLI through its settings context
|
||||
files, Claude Code through the `@` imports in `~/.claude/CLAUDE.md`, and Cline
|
||||
through both the cross-tool `~/.agents/AGENTS.md` pointer and the always-on
|
||||
global rule `~/.cline/rules/ai-context.md`, which binds `bootstrap.md`, the
|
||||
dispatcher, the safety directives, and the distilled ChatGPT knowledge under
|
||||
`memory/chatgpt/` (both deployed with `cline_deploy_enabled: true`). Cline
|
||||
shows the rule in its Rules panel as `global:ai-context`, where it can be
|
||||
toggled per project.
|
||||
|
||||
ChatGPT conversation memory lives in
|
||||
`dotfiles/common/.config/ai/memory/chatgpt/`: one Markdown transcript per
|
||||
conversation, a generated `INDEX.md`, and topic-distilled knowledge files under
|
||||
`memory/chatgpt/knowledge/` that agents load through the dispatcher. Regenerate
|
||||
it incrementally from an official ChatGPT data export with:
|
||||
|
||||
```bash
|
||||
python3 scripts/chatgpt_export_to_memory.py --export-dir ~/Downloads/<export>
|
||||
```
|
||||
|
||||
Binary and personal assets (PDFs, images) are deliberately not imported;
|
||||
textual ones are copied under `memory/chatgpt/assets/`. Non-technical personal
|
||||
conversations are excluded from import by a privacy blocklist in the script,
|
||||
which also prunes any previously imported copy.
|
||||
|
||||
The `opencode-mobile` npm package is no longer installed on managed hosts: its
|
||||
agent entry sets `install_enabled: false` and `uninstall_enabled: true`, so the
|
||||
playbook removes the managed package. The plugin declaration and `/mobile`
|
||||
command are still deployed with the OpenCode dotfiles, and pairing and
|
||||
connectivity remain manual; see the [upstream instructions](https://github.com/doza62/opencode-mobile#readme).
|
||||
|
||||
Run a focused dry run with:
|
||||
|
||||
```bash
|
||||
@@ -654,86 +361,6 @@ only in the entry for the agent being removed, then run:
|
||||
ansible-playbook ansible/site.yml --limit deadalus --tags ai_agents --check --diff
|
||||
```
|
||||
|
||||
### AI desktop applications
|
||||
|
||||
The same lifecycle-flag pattern manages the Fedora desktop applications
|
||||
through `ai_desktop_apps` in `ansible/inventory/group_vars/fedora.yml`.
|
||||
`chatgpt_desktop`, `opencode_desktop` and `cline_desktop` each expose
|
||||
`install_enabled` and `uninstall_enabled`, and the common pre-task rejects
|
||||
both being true for the same app. ChatGPT opts in per host (`ikaros`, `nymph`),
|
||||
Cline opts in through `desktop_gnome` group vars, and OpenCode Desktop keeps
|
||||
removal selected because Cline replaced it.
|
||||
|
||||
Removal deletes only what the playbook manages — the installed RPM package,
|
||||
ChatGPT's managed repository and signing key, and every cached download — and
|
||||
leaves GNOME favorites, user data, and the npm-managed CLI counterparts
|
||||
untouched. To switch an app between installed and removed, flip exactly one
|
||||
of its lifecycle flags, then preview with:
|
||||
|
||||
```bash
|
||||
ansible-playbook ansible/site.yml --limit ikaros --tags chatgpt,opencode_desktop,cline_desktop --check --diff
|
||||
```
|
||||
|
||||
### Cline Desktop on Fedora
|
||||
|
||||
The [official Cline Desktop RPM](https://cline.bot/desktop) is managed on the
|
||||
Fedora/GNOME workstations `ikaros` and `nymph`. WSL, Fedora IoT, Void and servers
|
||||
are excluded. The GNOME profile pins `Cline.desktop` in the position of an old
|
||||
OpenCode favorite, or appends it if there was no OpenCode favorite. Other
|
||||
favorites keep their order. Run the playbook from an active GNOME session.
|
||||
|
||||
The version and per-architecture SHA-256 digests are pinned in
|
||||
`ansible/inventory/group_vars/fedora.yml`; update both together from the official
|
||||
[Desktop release](https://github.com/cline/cline/releases/tag/desktop-v0.0.49).
|
||||
Only the checksum-verified local RPM installation disables DNF signature
|
||||
checking; no repository policy is changed. The Cline VS Code extension and
|
||||
npm-managed CLIs are independent of this app.
|
||||
|
||||
```bash
|
||||
ansible-playbook ansible/site.yml --limit ikaros --tags cline_desktop --check --diff
|
||||
ansible-playbook ansible/site.yml --limit ikaros --tags cline_desktop -K
|
||||
```
|
||||
|
||||
Run locally on each workstation (`ansible_connection: local`); use `--limit nymph`
|
||||
on the laptop. With a cold RPM cache, check mode reports that dependency resolution
|
||||
is not validated; the real run downloads, verifies, and installs the package.
|
||||
Cline replaced OpenCode Desktop: its `ai_desktop_apps` entry keeps
|
||||
`opencode_desktop_uninstall_enabled: true` by default, so a previously
|
||||
installed `opencode` RPM converges away on graphical hosts. Flip the entry's
|
||||
flags to reinstall the pinned release instead. Neither removal touches the
|
||||
npm CLI or user data.
|
||||
|
||||
### Thunderbird iCloud profile on Fedora
|
||||
|
||||
`profile_desktop_gnome` seeds a Thunderbird profile for `ikaros` and `nymph` so the
|
||||
iCloud account is already declared: IMAP `imap.mail.me.com:993` over SSL/TLS, SMTP
|
||||
`smtp.mail.me.com:587` over STARTTLS, the identity and folder mapping, one CalDAV
|
||||
calendar (`caldav.icloud.com`) and one CardDAV address book (`contacts.icloud.com`).
|
||||
|
||||
Before provisioning, the role checks both `~/.thunderbird` and
|
||||
`~/.config/thunderbird`, including registered absolute profile paths. If a profile
|
||||
already has a configured mail account, it selects that profile without modifying
|
||||
its account preferences, passwords, calendars or address books. Registered default
|
||||
profiles take priority over other discovered profiles. The active registry keeps
|
||||
its other profiles and is backed up before changes, including installation defaults.
|
||||
|
||||
Only when no configured account exists does the role create the iCloud profile
|
||||
and seed `user.js` without overwriting an existing file. Thunderbird must be closed
|
||||
before applying this tag; the playbook never stops it automatically. No profile or
|
||||
mail data is deleted or copied. A fresh installation uses `~/.config/thunderbird`;
|
||||
an existing legacy `~/.thunderbird` directory is retained.
|
||||
|
||||
The address comes from `vault_icloud_email` and the display name from
|
||||
`vault_personal_full_name`. The password is deliberately not stored: iCloud mail
|
||||
requires an app-specific password, which Thunderbird requests on first use and
|
||||
keeps in its own credential store. Set `thunderbird_icloud_enabled: false` to stop
|
||||
managing the profile without deleting it.
|
||||
|
||||
```bash
|
||||
ansible-playbook ansible/site.yml --limit ikaros --tags thunderbird --check --diff
|
||||
ansible-playbook ansible/site.yml --limit ikaros --tags thunderbird -K
|
||||
```
|
||||
|
||||
## Main roles
|
||||
|
||||
| Role | What it does |
|
||||
@@ -753,8 +380,8 @@ ansible-playbook ansible/site.yml --limit ikaros --tags thunderbird -K
|
||||
| `profile_workstation_dev_wsl` | WSL development setup. |
|
||||
| `profile_server` | Server setup. |
|
||||
| `profile_atlas` | Rocky Linux 9 NAS setup. |
|
||||
| `profile_backend_phase1` | Temporary rootless Atlas Navidrome and Syncthing services. |
|
||||
| `wireguard_overlay` | Prometheus/Aegis WireGuard LAN gateway. |
|
||||
| `profile_backend_phase1` | Rootless Navidrome and Syncthing on Atlas. |
|
||||
| `wireguard_overlay` | Prometheus/Atlas WireGuard overlay. |
|
||||
| `profile_aegis` | Fedora IoT always-on LAN node. |
|
||||
| `dotfiles_common` | Shared user dotfiles. |
|
||||
|
||||
@@ -766,8 +393,8 @@ platform_void -> packages_void + services_runit
|
||||
platform_void & graphical_desktop -> profile_desktop_common + profile_desktop_sway + profile_desktop_niri + profile_desktop_host
|
||||
platform_fedora -> packages_fedora + services_systemd
|
||||
platform_rocky -> packages_rocky + services_systemd
|
||||
wireguard_overlay -> wireguard_overlay (after platform_rocky)
|
||||
role_aegis -> profile_aegis
|
||||
wireguard_overlay -> wireguard_overlay (after Aegis profile and platform_rocky)
|
||||
atlas -> profile_atlas
|
||||
role_backend_phase1 -> profile_backend_phase1 (after atlas)
|
||||
rocky_server -> dotfiles_common + profile_server (after platform_rocky)
|
||||
@@ -837,9 +464,8 @@ ansible-playbook ansible/site.yml --limit <host> --tags <tag1>,<tag2> --check --
|
||||
ansible-playbook ansible/site.yml --limit <host> --start-at-task "<task name>" --check --diff
|
||||
ansible-lint ansible/roles/<role>
|
||||
yamllint ansible/path/to/file.yml
|
||||
ansible-playbook ansible/site.yml --limit prometheus --tags server_legacy_cleanup --check --diff -e server_legacy_cleanup=true
|
||||
podman-compose -f /opt/docker/server/docker-compose.yml config
|
||||
ansible-playbook ansible/site.yml --limit atlas --tags storage,sharing,containers --check --diff
|
||||
ansible-playbook ansible/site.yml --limit atlas --tags music_sync --check --diff
|
||||
```
|
||||
|
||||
## Tags
|
||||
@@ -873,7 +499,7 @@ ansible-playbook ansible/site.yml --list-tags
|
||||
| `sharing` | Atlas NFSv4 and SMB3 configuration. |
|
||||
| `storage` | Atlas child ZFS datasets. |
|
||||
| `tmux` | tmux configuration and plugins. |
|
||||
| `wireguard` | Prometheus/Aegis WireGuard LAN gateway. |
|
||||
| `wireguard` | Prometheus/Atlas WireGuard overlay. |
|
||||
| `wsl` | WSL bootstrap and configuration. |
|
||||
|
||||
## Bootstrapping a new machine
|
||||
@@ -893,13 +519,3 @@ For a future Void desktop host:
|
||||
4. Put hardware-specific details in `host_vars/<host>.yml`.
|
||||
|
||||
The legacy `void` and `desktop` groups remain compatibility parents, so hosts in `platform_void` and `graphical_desktop` still receive the existing Void and desktop variables.
|
||||
|
||||
## Project devcontainer generator
|
||||
|
||||
Generate a reusable language environment for an existing project with
|
||||
`devcontainer ~/src/project --language python --agents codex,cline`.
|
||||
Git and selected coding-agent configuration are shared from the development host.
|
||||
See [profiles, host requirements and validation](docs/project-devcontainers.md).
|
||||
|
||||
Deploy `~/.local/bin/devcontainer` on a Fedora desktop/workstation with
|
||||
`ansible-playbook ansible/site.yml --limit ikaros --tags devcontainer_generator -K`.
|
||||
|
||||
@@ -93,75 +93,36 @@ common_dotfiles:
|
||||
# AI coding-agent lifecycle controls are independent for every agent.
|
||||
# Installation and removal are mutually exclusive per agent; the common
|
||||
# pre-task enforces this before any changes are made.
|
||||
opencode_install_enabled: true
|
||||
opencode_deploy_enabled: true
|
||||
opencode_uninstall_enabled: false
|
||||
codex_install_enabled: true
|
||||
codex_deploy_enabled: true
|
||||
codex_uninstall_enabled: false
|
||||
codex_relay_install_enabled: false
|
||||
codex_relay_uninstall_enabled: false
|
||||
gemini_cli_install_enabled: true
|
||||
gemini_cli_deploy_enabled: true
|
||||
gemini_cli_uninstall_enabled: false
|
||||
claude_code_install_enabled: false
|
||||
claude_code_uninstall_enabled: true
|
||||
cline_install_enabled: true
|
||||
cline_deploy_enabled: true
|
||||
cline_uninstall_enabled: false
|
||||
ibm_bob_install_enabled: true
|
||||
ibm_bob_uninstall_enabled: false
|
||||
|
||||
# npm registry requests can be interrupted transiently. Keep retries bounded
|
||||
# so persistent proxy, DNS, or registry failures still fail the play clearly.
|
||||
ai_agents_npm_install_retries: 3
|
||||
ai_agents_npm_install_retry_delay: 10
|
||||
|
||||
ai_agents:
|
||||
opencode:
|
||||
npm_package: opencode-ai
|
||||
install_enabled: "{{ opencode_install_enabled }}"
|
||||
deploy_enabled: "{{ opencode_deploy_enabled }}"
|
||||
uninstall_enabled: "{{ opencode_uninstall_enabled }}"
|
||||
opencode_mobile:
|
||||
npm_package: opencode-mobile
|
||||
install_enabled: true
|
||||
deploy_enabled: true
|
||||
uninstall_enabled: false
|
||||
claude_code:
|
||||
npm_package: "@anthropic-ai/claude-code"
|
||||
install_enabled: false
|
||||
deploy_enabled: false
|
||||
uninstall_enabled: true
|
||||
claude_code:
|
||||
npm_package: "@anthropic-ai/claude-code"
|
||||
install_enabled: "{{ claude_code_install_enabled }}"
|
||||
deploy_enabled: false
|
||||
uninstall_enabled: "{{ claude_code_uninstall_enabled }}"
|
||||
codex:
|
||||
npm_package: "@openai/codex"
|
||||
install_enabled: "{{ codex_install_enabled }}"
|
||||
deploy_enabled: "{{ codex_deploy_enabled }}"
|
||||
uninstall_enabled: "{{ codex_uninstall_enabled }}"
|
||||
codex_relay:
|
||||
npm_package: codex-relay
|
||||
install_enabled: "{{ codex_relay_install_enabled }}"
|
||||
deploy_enabled: false
|
||||
uninstall_enabled: "{{ codex_relay_uninstall_enabled }}"
|
||||
install_enabled: true
|
||||
deploy_enabled: true
|
||||
uninstall_enabled: false
|
||||
gemini_cli:
|
||||
npm_package: "@google/gemini-cli"
|
||||
install_enabled: "{{ gemini_cli_install_enabled }}"
|
||||
deploy_enabled: "{{ gemini_cli_deploy_enabled }}"
|
||||
uninstall_enabled: "{{ gemini_cli_uninstall_enabled }}"
|
||||
cline:
|
||||
npm_package: cline
|
||||
install_enabled: "{{ cline_install_enabled }}"
|
||||
deploy_enabled: "{{ cline_deploy_enabled }}"
|
||||
uninstall_enabled: "{{ cline_uninstall_enabled }}"
|
||||
install_enabled: true
|
||||
deploy_enabled: true
|
||||
uninstall_enabled: false
|
||||
github_copilot:
|
||||
npm_package: "@github/copilot"
|
||||
install_enabled: false
|
||||
deploy_enabled: false
|
||||
uninstall_enabled: true
|
||||
ibm_bob:
|
||||
install_enabled: "{{ ibm_bob_install_enabled }}"
|
||||
install_enabled: true
|
||||
deploy_enabled: false
|
||||
uninstall_enabled: "{{ ibm_bob_uninstall_enabled }}"
|
||||
uninstall_enabled: false
|
||||
|
||||
ai_agents_deploy_enabled_names: >-
|
||||
{{ ai_agents | dict2items | selectattr('value.deploy_enabled') | map(attribute='key') | list }}
|
||||
@@ -175,7 +136,6 @@ ai_agents_dotfiles:
|
||||
- opencode
|
||||
- codex
|
||||
- gemini_cli
|
||||
- cline
|
||||
- name: Gemini CLI config
|
||||
src: .gemini/
|
||||
dest: .gemini/
|
||||
@@ -194,24 +154,6 @@ ai_agents_dotfiles:
|
||||
mode: preserve
|
||||
agents:
|
||||
- claude_code
|
||||
- name: Codex global AGENTS instructions
|
||||
src: .codex/AGENTS.md
|
||||
dest: .codex/AGENTS.md
|
||||
mode: "0644"
|
||||
agents:
|
||||
- codex
|
||||
- name: Cline cross-tool AGENTS instructions
|
||||
src: .agents/AGENTS.md
|
||||
dest: .agents/AGENTS.md
|
||||
mode: "0644"
|
||||
agents:
|
||||
- cline
|
||||
- name: Cline global rules
|
||||
src: .cline/rules/
|
||||
dest: .cline/rules/
|
||||
mode: preserve
|
||||
agents:
|
||||
- cline
|
||||
|
||||
ai_agents_templates:
|
||||
- name: Codex config
|
||||
|
||||
@@ -42,6 +42,10 @@ desktop_uv_tools:
|
||||
- python-lsp-server
|
||||
|
||||
desktop_common_dotfiles:
|
||||
- name: XDG autostart entries
|
||||
src: .config/autostart/
|
||||
dest: .config/autostart/
|
||||
mode: preserve
|
||||
- name: fastfetch config
|
||||
src: .config/fastfetch/
|
||||
dest: .config/fastfetch/
|
||||
@@ -214,6 +218,7 @@ desktop_niri_dotfiles:
|
||||
|
||||
desktop_flatpak_packages:
|
||||
- be.alexandervanhee.gradia
|
||||
- ch.protonmail.protonmail-bridge
|
||||
- com.discordapp.Discord
|
||||
- com.calibre_ebook.calibre
|
||||
- com.github.tchx84.Flatseal
|
||||
|
||||
@@ -4,9 +4,6 @@ desktop_environment: gnome
|
||||
desktop_sessions_enabled: []
|
||||
desktop_default_session: gnome
|
||||
emacs_enabled: true
|
||||
# Cline Desktop is installed (and pinned in the GNOME favorites) on every
|
||||
# GNOME host; set cline_desktop_uninstall_enabled here to remove it instead.
|
||||
cline_desktop_install_enabled: true
|
||||
|
||||
# Fedora Workstation/GNOME desktop applications. Keep this profile separate from
|
||||
# workstation_* so nymph can remain a desktop laptop rather than a dev workstation.
|
||||
@@ -25,7 +22,7 @@ fedora_desktop_packages:
|
||||
- croc
|
||||
- delve
|
||||
- dnsmasq
|
||||
- thunderbird
|
||||
- evolution
|
||||
- fastfetch
|
||||
- poppler-glib
|
||||
- poppler-utils
|
||||
@@ -45,7 +42,6 @@ fedora_desktop_packages:
|
||||
- libXft-devel
|
||||
- meld
|
||||
- mpv
|
||||
- nextcloud-client
|
||||
- pdfarranger
|
||||
- pinentry-gnome3
|
||||
- plocate
|
||||
@@ -76,10 +72,6 @@ fedora_desktop_packages:
|
||||
- yt-dlp
|
||||
- zstd
|
||||
|
||||
fedora_removed_packages:
|
||||
- evolution
|
||||
- evolution-langpacks
|
||||
|
||||
fedora_nerd_fonts_version: v3.3.0
|
||||
fedora_nerd_fonts:
|
||||
- Hack
|
||||
@@ -90,82 +82,7 @@ fedora_nerd_fonts:
|
||||
|
||||
fedora_flatpak_packages:
|
||||
- be.alexandervanhee.gradia
|
||||
- ch.protonmail.protonmail-bridge
|
||||
- com.spotify.Client
|
||||
- org.desktop_plus.desktop-plus
|
||||
- org.onlyoffice.desktopeditors
|
||||
- org.telegram.desktop
|
||||
|
||||
# GNOME-only dotfiles. Kept out of desktop_common_dotfiles so the Void desktops
|
||||
# do not receive XDG autostart entries for applications they do not install.
|
||||
# Nextcloud desktop is the `nextcloud-client` package in fedora_desktop_packages;
|
||||
# this entry matches what the client itself writes when "Launch on startup" is on.
|
||||
desktop_gnome_dotfiles:
|
||||
- name: Nextcloud autostart entry
|
||||
src: .config/autostart/Nextcloud.desktop
|
||||
dest: .config/autostart/Nextcloud.desktop
|
||||
mode: "0644"
|
||||
|
||||
# Thunderbird is provisioned from a seeded profile plus a managed user.js:
|
||||
# Existing Thunderbird accounts are reused without changing their preferences.
|
||||
# Only a new profile receives account, calendar and address book defaults in user.js.
|
||||
# The address comes from Vault; the app-specific password is never stored here
|
||||
# and is requested by Thunderbird on first use.
|
||||
thunderbird_icloud_enabled: true
|
||||
thunderbird_profile_name: "{{ username }}"
|
||||
thunderbird_profile_dir: "{{ username }}.default-release"
|
||||
thunderbird_full_name: "{{ vault_personal_full_name | default(username) }}"
|
||||
thunderbird_icloud_email: "{{ vault_icloud_email }}"
|
||||
thunderbird_icloud_account_name: iCloud
|
||||
thunderbird_icloud_imap_host: imap.mail.me.com
|
||||
thunderbird_icloud_imap_port: 993
|
||||
thunderbird_icloud_smtp_host: smtp.mail.me.com
|
||||
thunderbird_icloud_smtp_port: 587
|
||||
thunderbird_icloud_caldav_url: https://caldav.icloud.com/
|
||||
thunderbird_icloud_carddav_url: https://contacts.icloud.com/
|
||||
thunderbird_icloud_calendar_id: 4f2c1d6e-9b3a-4f7c-8e21-6d5a0c9b7e13
|
||||
thunderbird_icloud_addressbook_uid: 9e0b7c4a-2d51-4a8f-b6c3-1f7d5e2a8b46
|
||||
|
||||
# Native VS Code; opt in to managing settings only after defining them.
|
||||
vscode_extensions:
|
||||
- esbenp.prettier-vscode
|
||||
- github.remotehub
|
||||
- ms-azuretools.vscode-containers
|
||||
# ms-azuretools.vscode-docker is deprecated: since June 2025 it is just an
|
||||
# extension pack wrapping Container Tools. Only the real extension is kept.
|
||||
- ms-vscode-remote.remote-containers
|
||||
- ms-vscode-remote.remote-ssh
|
||||
- ms-vscode-remote.remote-ssh-edit
|
||||
- ms-vscode-remote.remote-wsl
|
||||
- ms-vscode-remote.vscode-remote-extensionpack
|
||||
- ms-vscode.azure-repos
|
||||
- ms-vscode.remote-explorer
|
||||
- ms-vscode.remote-repositories
|
||||
- ms-vscode.remote-server
|
||||
- pkief.material-icon-theme
|
||||
- redhat.vscode-xml
|
||||
- redhat.vscode-yaml
|
||||
- saoudrizwan.claude-dev
|
||||
- vscodevim.vim
|
||||
# Managed user settings deploy as a full-file overlay with a timestamped backup;
|
||||
# any manual settings.json edit is converged away on the next run. These keys cover
|
||||
# the podman Dev Containers engine selection and the Container Tools clients.
|
||||
# editor.fontFamily uses the canonical 'JetBrainsMono Nerd Font' family name: the
|
||||
# live 'JetBriansMono NF' was a typo whose fallback chain rendered Liberation Mono.
|
||||
vscode_settings:
|
||||
containers.containerClient: com.microsoft.visualstudio.containers.podman
|
||||
containers.orchestratorClient: com.microsoft.visualstudio.orchestrators.podmancompose
|
||||
dev.containers.dockerPath: podman
|
||||
editor.cursorStyle: block
|
||||
editor.fontFamily: "'JetBrainsMono Nerd Font', 'Droid Sans Mono', monospace"
|
||||
editor.formatOnPaste: true
|
||||
workbench.iconTheme: material-icon-theme
|
||||
workbench.startupEditor: none
|
||||
# User-level keybindings apply to every window, including Dev Containers, SSH and WSL remotes.
|
||||
# Keys avoid Ctrl+<letter>, which the Vim extension uses for its motions; Alt is not bound by Vim.
|
||||
vscode_keybindings:
|
||||
- key: alt+j
|
||||
command: workbench.action.terminal.toggleTerminal
|
||||
when: "!terminalFocus"
|
||||
- key: alt+j
|
||||
command: workbench.action.togglePanel
|
||||
when: terminalFocus
|
||||
|
||||
@@ -8,11 +8,7 @@ fedora_packages_base:
|
||||
- htop
|
||||
- jq
|
||||
- make
|
||||
# Keep the LTS stream explicit. Fedora 45's rolling `nodejs` package
|
||||
# conflicts with the nodejs22-bin alternative installed by the F44→F45
|
||||
# upgrade.
|
||||
- nodejs22
|
||||
- openssl
|
||||
- nodejs
|
||||
- ripgrep
|
||||
|
||||
fedora_manage_docker_repo: true
|
||||
@@ -62,57 +58,3 @@ fedora_dev_packages:
|
||||
|
||||
fedora_flatpak_remote_name: flathub
|
||||
fedora_flatpak_remote_url: https://dl.flathub.org/repo/flathub.flatpakrepo
|
||||
|
||||
cline_desktop_version: "0.0.49"
|
||||
# Launcher file shipped by the pinned RPM; the GNOME profile pins it in the
|
||||
# favorites while installation stays enabled.
|
||||
cline_desktop_launcher: Cline.desktop
|
||||
# Digests published with the official GitHub release; update with the version.
|
||||
cline_desktop_rpm_checksums:
|
||||
x86_64: sha256:e10036a036ee531451695559e2c96feceb3d621408a6615bdd708ffcf9e778ab
|
||||
aarch64: sha256:aec36edb594bdc400b0c2275230f29de6814a78ad60add4938347d20cfb93b74
|
||||
cline_desktop_rpm_url: >-
|
||||
https://github.com/cline/cline/releases/download/desktop-v{{ cline_desktop_version }}/Cline_{{ cline_desktop_version }}_{{ ansible_facts['architecture'] }}.rpm
|
||||
cline_desktop_rpm_path: "/var/cache/cline-desktop-{{ cline_desktop_version }}-{{ ansible_facts['architecture'] }}.rpm"
|
||||
|
||||
# OpenCode Desktop was replaced by Cline Desktop. The pinned release stays
|
||||
# available for reinstall, while removal is selected in the lifecycle flags
|
||||
# below so leftovers from the switch converge away on graphical hosts.
|
||||
opencode_desktop_version: "2.2.5"
|
||||
# Digests published with the official GitHub release; update with the version.
|
||||
opencode_desktop_rpm_checksums:
|
||||
x86_64: sha256:4feb27fe98df9b7579abd31a790d331e9aff87c95f67081beefa2aaaa76ebada
|
||||
aarch64: sha256:e84b1e03e2b4fb337ddfe015b6457a7aa0dfe171338be08e643ad66b1657033a
|
||||
opencode_desktop_rpm_url: >-
|
||||
https://github.com/anomalyco/opencode/releases/download/v{{ opencode_desktop_version }}/opencode-desktop-linux-{{ ansible_facts['architecture'] }}.rpm
|
||||
opencode_desktop_rpm_path: "/var/cache/opencode-desktop-{{ opencode_desktop_version }}-{{ ansible_facts['architecture'] }}.rpm"
|
||||
|
||||
# AI desktop-app lifecycle controls are independent for every app and mirror
|
||||
# the CLI coding-agent flags. Installation and removal are mutually exclusive
|
||||
# per app; the common pre-task enforces this before any changes are made.
|
||||
# ChatGPT opts in per host, Cline opts in through desktop_gnome group vars.
|
||||
chatgpt_desktop_install_enabled: false
|
||||
chatgpt_desktop_uninstall_enabled: false
|
||||
opencode_desktop_install_enabled: false
|
||||
opencode_desktop_uninstall_enabled: true
|
||||
|
||||
ai_desktop_apps:
|
||||
chatgpt_desktop:
|
||||
install_enabled: "{{ chatgpt_desktop_install_enabled }}"
|
||||
uninstall_enabled: "{{ chatgpt_desktop_uninstall_enabled }}"
|
||||
opencode_desktop:
|
||||
install_enabled: "{{ opencode_desktop_install_enabled }}"
|
||||
uninstall_enabled: "{{ opencode_desktop_uninstall_enabled }}"
|
||||
cline_desktop:
|
||||
install_enabled: "{{ cline_desktop_install_enabled | default(false) }}"
|
||||
uninstall_enabled: "{{ cline_desktop_uninstall_enabled | default(false) }}"
|
||||
|
||||
chatgpt_desktop_supported_fedora_versions:
|
||||
- "43"
|
||||
- "44"
|
||||
- "45"
|
||||
chatgpt_desktop_supported_architectures:
|
||||
- x86_64
|
||||
- aarch64
|
||||
chatgpt_desktop_rpm_gpg_key: RPM-GPG-KEY-chatgpt-3BFA0E4AE8B8CC16A2D9BA684A3B4A566C4660E4.asc
|
||||
chatgpt_desktop_rpm_repository: https://persistent.oaistatic.com/codex-app-prod/linux/rpm/$basearch
|
||||
|
||||
@@ -5,9 +5,6 @@ platform_package_manager: dnf
|
||||
platform_service_manager: systemd
|
||||
|
||||
rocky_openzfs_release_rpm: https://zfsonlinux.org/epel/zfs-release-3-0.el9.noarch.rpm
|
||||
rocky_openzfs_gpg_key_url: >-
|
||||
https://raw.githubusercontent.com/zfsonlinux/zfsonlinux.github.com/master/zfs-release/RPM-GPG-KEY-openzfs-key2
|
||||
rocky_openzfs_gpg_key_fingerprint: 7DC7 299D CF7C 7FD9 CD87 701B A599 FD5E 9DB8 4141
|
||||
rocky_syncthing_version: 2.1.3
|
||||
rocky_syncthing_archive_checksum: sha256:f929eb8e5b72a85543eeeefb2c38f34a68e0c530e70758a2905b78840c76602c
|
||||
rocky_syncthing_archive_url: >-
|
||||
|
||||
@@ -40,3 +40,4 @@ server_firewalld_services:
|
||||
server_firewalld_ports: []
|
||||
server_sshd_service_name: sshd
|
||||
server_compose_selinux_mount_option: Z
|
||||
server_syncthing_enabled: false
|
||||
|
||||
@@ -6,10 +6,6 @@ effective_username: "{{ server_username }}"
|
||||
effective_user_group: "{{ server_user_group }}"
|
||||
effective_user_home: "{{ server_user_home }}"
|
||||
server_container_stack_dir: /opt/docker/server
|
||||
server_npm_quadlet_stage: false
|
||||
server_npm_quadlet_cutover: false
|
||||
server_legacy_stack_retired: false
|
||||
server_legacy_cleanup: false
|
||||
ai_agents: {}
|
||||
vim_plugins_enabled: false
|
||||
|
||||
@@ -79,41 +75,25 @@ server_directories:
|
||||
group: root
|
||||
mode: "0755"
|
||||
|
||||
server_syncthing_enabled: true
|
||||
server_syncthing_directories:
|
||||
- path: /opt/syncthing/config
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0755"
|
||||
- path: /srv/syncthing
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0755"
|
||||
- path: /srv/syncthing/data
|
||||
owner: "1000"
|
||||
group: "1000"
|
||||
mode: "0755"
|
||||
|
||||
server_sshd_settings:
|
||||
PermitRootLogin: "no"
|
||||
|
||||
server_sshd_allow_users:
|
||||
- "{{ server_username }}"
|
||||
server_backup_export_enabled: false
|
||||
server_backup_username: prometheus-backup
|
||||
server_backup_public_key_name: atlas-pull
|
||||
server_backup_export_root: /var/lib/prometheus-backup-export
|
||||
server_backup_rrsync_path: /usr/share/doc/rsync/support/rrsync
|
||||
server_backup_export_calendar: "*-*-* 02:00:00 Europe/Rome"
|
||||
server_backup_export_start_timer: false
|
||||
# Ongoing public Gitea proxy configuration.
|
||||
server_gitea_proxy_enabled: false
|
||||
server_gitea_on_atlas: false
|
||||
server_gitea_atlas_address: "{{ hostvars['atlas'].ansible_host }}"
|
||||
server_gitea_npm_domains: []
|
||||
server_gitea_ssh_public_port: 2222
|
||||
server_gitea_ssh_target_port: 2222
|
||||
server_backup_export_source_keep: 3
|
||||
server_backup_export_paths: >-
|
||||
{{ ['opt/npm/data', 'opt/npm/letsencrypt']
|
||||
+ ([] if server_gitea_on_atlas | bool else ['opt/gitea/data', 'home/git/.ssh'])
|
||||
+ ([] if server_legacy_stack_retired | bool else
|
||||
['opt/docker/server/docker-compose.yml',
|
||||
'etc/systemd/system/podman-compose-server.service'])
|
||||
+ (['etc/containers/systemd/prometheus-npm.container',
|
||||
'etc/containers/systemd/server-web.network']
|
||||
if server_npm_quadlet_stage | bool else [])
|
||||
+ ['etc/ssh/sshd_config', 'etc/ssh/sshd_config.d',
|
||||
'etc/firewalld', 'etc/wireguard/wg0.conf'] }}
|
||||
server_backup_export_excludes: >-
|
||||
{{ ['opt/npm/data/logs']
|
||||
+ ([] if server_gitea_on_atlas | bool else
|
||||
['opt/gitea/data/gitea/log', 'opt/gitea/data/gitea/tmp',
|
||||
'opt/gitea/data/gitea/sessions', 'opt/gitea/data/gitea/indexers']) }}
|
||||
server_ssh_authorized_keys: []
|
||||
server_ssh_authorized_key_directory: "{{ server_user_home }}/.ssh/authorized_keys.d"
|
||||
|
||||
@@ -183,7 +183,7 @@ profile_packages:
|
||||
- deluge-gtk
|
||||
- delve
|
||||
- dnsmasq
|
||||
- thunderbird
|
||||
- evolution
|
||||
- poppler-glib
|
||||
- poppler-utils
|
||||
- fontconfig-devel
|
||||
@@ -224,8 +224,5 @@ profile_packages:
|
||||
- yaru-plus
|
||||
- zstd
|
||||
|
||||
void_removed_packages:
|
||||
- evolution
|
||||
|
||||
profile_emacs_packages:
|
||||
- emacs-pgtk
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
---
|
||||
emacs_enabled: true
|
||||
|
||||
workstation_git_https_cas:
|
||||
- url: https://gitlab.ecaas.datacenter.comune.roma
|
||||
certificate: ecaas.datacenter.comune.roma.crt
|
||||
- url: https://gitlab.datacenter.comune.roma
|
||||
certificate: datacenter.comune.roma.crt
|
||||
|
||||
workstation_user_directories:
|
||||
- path: "{{ user_home }}/.config"
|
||||
mode: "0755"
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
---
|
||||
# Claude Code is managed only on the Fedora WSL development profile.
|
||||
claude_code_install_enabled: true
|
||||
claude_code_uninstall_enabled: false
|
||||
|
||||
enabled_services:
|
||||
- docker
|
||||
|
||||
workstation_dev_wsl_packages:
|
||||
- buildah
|
||||
- helm
|
||||
# Fedora ships the kubectl client binary in the kubernetes-client package.
|
||||
- kubernetes-client
|
||||
- mise
|
||||
- pinentry-curses
|
||||
- python3-pip
|
||||
- tmux
|
||||
|
||||
# Maven version pinned in the devcontainer images; update it deliberately.
|
||||
workstation_maven_version: 3.9.16
|
||||
workstation_cdp_node_version: 20.18.3
|
||||
# Java 11 and Maven are managed by Mise on this Fedora WSL profile. Keep their
|
||||
# versions pinned; update them deliberately.
|
||||
workstation_mise_java_version: temurin-11.0.31+11
|
||||
workstation_mise_maven_version: 3.9.16
|
||||
|
||||
workstation_is_wsl: true
|
||||
workstation_wsl_systemd_enabled: true
|
||||
workstation_dev_wsl_dotfiles:
|
||||
- src: .bashrc.d/30-mise.sh
|
||||
dest: .bashrc.d/30-mise.sh
|
||||
mode: "0644"
|
||||
- src: .config/mise/
|
||||
dest: .config/mise/
|
||||
mode: preserve
|
||||
- src: .gnupg/gpg-agent.conf
|
||||
dest: .gnupg/gpg-agent.conf
|
||||
mode: "0600"
|
||||
|
||||
@@ -9,32 +9,6 @@ ansible_ssh_use_tty: false
|
||||
|
||||
aegis_lan_subnet: 192.168.178.0/24
|
||||
aegis_adguard_web_port: 80
|
||||
aegis_network_connection_name: FRITZ!Box 7530 NR
|
||||
aegis_network_connection_uuid: a52fda3d-3eb6-351f-bf04-753edcb76944
|
||||
aegis_host_dns_servers:
|
||||
- 192.168.178.1
|
||||
aegis_host_dns_search_domains:
|
||||
- fritz.box
|
||||
|
||||
# Aegis is the internal WireGuard endpoint and NAT gateway for the LAN.
|
||||
wireguard_overlay_enabled: true
|
||||
wireguard_address: 10.0.0.2/24
|
||||
wireguard_enable_ipv4_forwarding: true
|
||||
wireguard_reload_rootful_podman_networks: true
|
||||
wireguard_forwarding_policies:
|
||||
- name: aegis-wireguard-to-lan
|
||||
ingress_zone: wireguard
|
||||
egress_zone: public
|
||||
source: 10.0.0.0/24
|
||||
destination: "{{ aegis_lan_subnet }}"
|
||||
masquerade: true
|
||||
wireguard_peers:
|
||||
- name: prometheus
|
||||
host: prometheus
|
||||
endpoint: "{{ hostvars['prometheus']['ansible_host'] }}:{{ hostvars['prometheus']['wireguard_listen_port'] }}"
|
||||
allowed_ips:
|
||||
- 10.0.0.0/24
|
||||
persistent_keepalive: 25
|
||||
aegis_ssh_authorized_keys:
|
||||
- name: ikaros
|
||||
key: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINrIxXjA3ffPwziKGR5gzc4gAoBehQPlnEMcXF4Wl0ZS ikaros"
|
||||
@@ -42,3 +16,5 @@ aegis_ssh_authorized_keys:
|
||||
key: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEH/7GJfGt0ZVmKeEzceoFkFkeCXFryKK9vAbaip+HCx nymph"
|
||||
- name: siren
|
||||
key: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIA95wYlzpfN3rjUhpMeP4KHn8I6ZrjQXoDTgwgRIa++b siren"
|
||||
|
||||
aegis_icloudpd_apple_id: "{{ vault_aegis_icloudpd_apple_id | default('') }}"
|
||||
|
||||
@@ -28,189 +28,38 @@ atlas_manage_firewall: true
|
||||
atlas_firewalld_zone: public
|
||||
atlas_zfs_pool: zpool
|
||||
# Populate only for the first pool bootstrap with four real persistent disk paths.
|
||||
# Confirmed empty 4 TB IronWolf data disks; the NVMe system disk is intentionally excluded.
|
||||
atlas_zpool_disks:
|
||||
- /dev/disk/by-id/ata-ST4000VN006-3CW104_WW6AC1XM
|
||||
- /dev/disk/by-id/ata-ST4000VN006-3CW104_WW6A73T2
|
||||
- /dev/disk/by-id/ata-ST4000VN006-3CW104_WW6A6VJK
|
||||
- /dev/disk/by-id/ata-ST4000VN006-3CW104_WW6AC1LM
|
||||
# Example: /dev/disk/by-id/ata-Seagate_IronWolf_...
|
||||
atlas_zpool_disks: []
|
||||
atlas_create_pool: false
|
||||
atlas_zfs_dataset_work: work
|
||||
atlas_zfs_dataset_archive: archive
|
||||
atlas_zfs_dataset_services: services
|
||||
atlas_zfs_dataset_app_data: services/data
|
||||
atlas_zfs_dataset_navidrome: services/data/navidrome
|
||||
atlas_zfs_dataset_syncthing: services/data/syncthing
|
||||
atlas_zfs_dataset_app_data: archive/app_data
|
||||
atlas_zfs_dataset_navidrome: archive/app_data/navidrome
|
||||
atlas_zfs_dataset_syncthing: archive/app_data/syncthing
|
||||
atlas_zfs_dataset_media: media
|
||||
atlas_zfs_dataset_music: media/music
|
||||
atlas_zfs_dataset_backup: backup
|
||||
atlas_zfs_dataset_host_backups: backup/hosts
|
||||
atlas_zfs_dataset_backup_prometheus: backup/hosts/prometheus
|
||||
atlas_zfs_backup_reservation: 500G
|
||||
atlas_zfs_dataset_backup_prometheus: backup_prometheus
|
||||
atlas_zfs_dataset_photobook: media/photobook
|
||||
atlas_zfs_dataset_backups: backups
|
||||
atlas_zfs_dataset_service_backups: backups/services
|
||||
atlas_mount_root: /zpool
|
||||
atlas_manage_storage: true
|
||||
atlas_manage_nextcloud: true
|
||||
# Two local consistent bundles; long-term history stays in Borg/USB and ZFS.
|
||||
atlas_nextcloud_backup_keep: 2
|
||||
atlas_nextcloud_domain: cloud.fscotto.co
|
||||
atlas_onlyoffice_domain: office.fscotto.co
|
||||
# Resolved official amd64 images on 2026-10-03; updates are deliberate.
|
||||
atlas_nextcloud_image: docker.io/library/nextcloud:33.0.9-apache@sha256:a97666d6ae931bde78a80cfba8abdf46d436d7b540f31895803f6fb0a012d689
|
||||
atlas_nextcloud_postgres_image: docker.io/library/postgres:17-bookworm@sha256:639ab7ceb90e13123085b741fb31ef493fba25463002f6da665352e7b534b652
|
||||
atlas_nextcloud_redis_image: docker.io/library/redis:7.4-bookworm@sha256:c6eabf748fc7a61dbb5a705c78bcf3d6377b1127a97d0ce965c11c44ba46896f
|
||||
atlas_onlyoffice_image: docker.io/onlyoffice/documentserver:9.4.0.1@sha256:3ab6ebc7c605e5a32b7ae3ff19daed4925090245acc8100ce2230bd766c88212
|
||||
atlas_nextcloud_users:
|
||||
- username: fabio
|
||||
display_name: Fabio
|
||||
password: "{{ vault_nextcloud_fabio_password }}"
|
||||
- username: chiara
|
||||
display_name: Chiara
|
||||
password: "{{ vault_nextcloud_chiara_password }}"
|
||||
atlas_nextcloud_external_mounts:
|
||||
- name: Documenti
|
||||
user: fabio
|
||||
source: /zpool/archive/Documents
|
||||
target: /mnt/archive-documents
|
||||
readonly: false
|
||||
# Expose the iCloudPD originals directly in Fabio's canonical Photos folder.
|
||||
# This remains a read-only external mount; iCloudPD is the sole writer.
|
||||
- name: Photos
|
||||
user: fabio
|
||||
source: /zpool/archive/Pictures/iCloudPD
|
||||
target: /mnt/archive-icloud
|
||||
readonly: true
|
||||
atlas_nextcloud_apps:
|
||||
- id: groupfolders
|
||||
version: 21.0.9
|
||||
url: https://github.com/nextcloud-releases/groupfolders/releases/download/v21.0.9/groupfolders-v21.0.9.tar.gz
|
||||
checksum: sha256:d8b95f0778425f646f2311ba5b42d8e2fcfdf37dc2fd35fcac8d3f01bde38a21
|
||||
- id: onlyoffice
|
||||
version: 10.2.1
|
||||
url: https://github.com/ONLYOFFICE/onlyoffice-nextcloud/releases/download/v10.2.1/onlyoffice.tar.gz
|
||||
checksum: sha256:144998af0610ccd17ee8d7025e2f8001472da03f6dab90ff38039247825e3a9b
|
||||
- id: contacts
|
||||
version: 8.9.1
|
||||
url: https://github.com/nextcloud-releases/contacts/releases/download/v8.9.1/contacts-v8.9.1.tar.gz
|
||||
checksum: sha256:a25cdf448b192631b8e8eb7addc31b40382b33871b10521f4308ac5a6e0457bf
|
||||
- id: calendar
|
||||
version: 6.6.2
|
||||
url: https://github.com/nextcloud-releases/calendar/releases/download/v6.6.2/calendar-v6.6.2.tar.gz
|
||||
checksum: sha256:7e83632d4436d3037a34d1c73cbc06d5ccb6e8fc10f096a86a43a0515588529c
|
||||
# Rootless Gitea was restored from the stopped-source export before production activation.
|
||||
# Paperless runs rootless on dedicated ZFS datasets; NPM remains on Prometheus.
|
||||
atlas_manage_paperless: true
|
||||
atlas_paperless_domain: documents.fscotto.co
|
||||
# Resolved official amd64 images on 2026-10-12; upgrades remain deliberate.
|
||||
atlas_paperless_image: ghcr.io/paperless-ngx/paperless-ngx:3.2.1@sha256:5fa76604a81df6945086e0837b14b56543d137e8ce4f311cc5d9ebe907e74e79
|
||||
atlas_paperless_postgres_image: docker.io/library/postgres:17-bookworm@sha256:3645570cccdfa447589da9f57dd740faa29b30938e861289a5574b6ca6b03826
|
||||
atlas_paperless_valkey_image: docker.io/valkey/valkey:8-bookworm@sha256:fea8b3e67b15729d4bb70589eb03367bab9ad1ee89c876f54327fc7c6e618571
|
||||
atlas_paperless_tika_image: docker.io/apache/tika:3.3.1.0@sha256:90b7fa1dc018434075fce9e1d9b88b1e3d0ea6979d0cf86e116c79a8073ae973
|
||||
atlas_paperless_gotenberg_image: docker.io/gotenberg/gotenberg:8.37@sha256:f29984bd1e226bf1b93ba90af06000afa8b315853e99d27b9aaa41b93f15c769
|
||||
atlas_paperless_ollama_image: docker.io/ollama/ollama:0.40.3@sha256:adca95a12c2b386a8f9a995e7fa0600e187e3323b5e5522f5a6c3b1ec73eff99
|
||||
|
||||
atlas_manage_gitea: true
|
||||
atlas_gitea_production_enabled: true
|
||||
atlas_gitea_public_domain: git.fscotto.co
|
||||
atlas_prometheus_pull_start_timer: true
|
||||
atlas_manage_zfs_snapshots: true
|
||||
atlas_zfs_snapshot_prefix: atlas-auto
|
||||
atlas_zfs_snapshot_policies:
|
||||
- name: hourly
|
||||
calendar: "*-*-* *:05:00"
|
||||
keep: 24
|
||||
- name: daily
|
||||
calendar: "*-*-* 00:15:00"
|
||||
keep: 30
|
||||
- name: weekly
|
||||
calendar: "Sun *-*-* 01:00:00"
|
||||
keep: 8
|
||||
- name: monthly
|
||||
calendar: "*-*-01 02:00:00"
|
||||
keep: 12
|
||||
atlas_manage_zfs_scrub: true
|
||||
atlas_zfs_scrub_calendar: "Sun *-*-01..07 03:00:00"
|
||||
atlas_manage_borg_backup: true
|
||||
atlas_borg_repository_host: u660064-sub1.your-storagebox.de
|
||||
atlas_borg_repository_user: u660064-sub1
|
||||
atlas_borg_repository_port: 23
|
||||
atlas_borg_repository_path: ./borg-data
|
||||
atlas_borg_remote_path: borg-1.4
|
||||
# Verified against Hetzner's published ED25519 fingerprint on 2026-09-17:
|
||||
# SHA256:XqONwb1S0zuj5A1CDxpOSuD2hnAArV1A3wKY7Z3sdgM
|
||||
atlas_borg_host_key: >-
|
||||
[u660064-sub1.your-storagebox.de]:23 ssh-ed25519
|
||||
AAAAC3NzaC1lZDI1NTE5AAAAIICf9svRenC/PLKIL9nk6K/pxQgoiFC41wTNvoIncOxs
|
||||
atlas_borg_backup_calendar: "*-*-* 04:30:00"
|
||||
atlas_borg_check_calendar: "*-*-15 06:00:00"
|
||||
atlas_borg_randomized_delay: 30m
|
||||
atlas_borg_keep_daily: 30
|
||||
atlas_borg_keep_weekly: 8
|
||||
atlas_borg_keep_monthly: 12
|
||||
atlas_manage_usb_backup: true
|
||||
# Read-only lsblk verification on Atlas, 2026-09-23. Never store the LUKS password here.
|
||||
atlas_usb_backup_luks_uuid: 577b3c43-ea37-4611-81a9-39d555cdfbd4
|
||||
atlas_usb_backup_fs_uuid: 758e2d2e-a427-4797-aad9-39c3a9f17c7e
|
||||
atlas_usb_backup_mapper_name: zpool-backup
|
||||
atlas_manage_usb_reminder: true
|
||||
atlas_usb_reminder_calendar: "Sat *-*-01..07 10:00:00 Europe/Rome"
|
||||
atlas_manage_monitoring: true
|
||||
atlas_manage_prometheus_backup_pull: true
|
||||
# Prometheus ED25519 host key read through the controller's strict SSH trust on 2026-09-30.
|
||||
# Fingerprint: SHA256:rfedk7DHI9mLB3UHk/4F3HHlSIiswtCAFsAXvfh6iXk
|
||||
atlas_prometheus_ssh_host_key: >-
|
||||
179.237.102.172 ssh-ed25519
|
||||
AAAAC3NzaC1lZDI1NTE5AAAAIC4b+QXlPupoEx71W9NKs9tTeYjBqTkVMqbGB97nMNWv
|
||||
# Physical pool disks and the system NVMe; the disconnected USB disk is intentionally excluded.
|
||||
atlas_monitor_smart_devices:
|
||||
- { name: pool-1, path: "{{ atlas_zpool_disks[0] }}", warning_c: 50, critical_c: 55 }
|
||||
- { name: pool-2, path: "{{ atlas_zpool_disks[1] }}", warning_c: 50, critical_c: 55 }
|
||||
- { name: pool-3, path: "{{ atlas_zpool_disks[2] }}", warning_c: 50, critical_c: 55 }
|
||||
- { name: pool-4, path: "{{ atlas_zpool_disks[3] }}", warning_c: 50, critical_c: 55 }
|
||||
- name: system-nvme
|
||||
path: /dev/disk/by-id/nvme-Patriot_M.2_P320_256GB_P320ADB26011606111
|
||||
warning_c: 70
|
||||
critical_c: 85
|
||||
atlas_monitor_timers:
|
||||
- { name: atlas-zfs-snapshot-hourly.timer, max_age_hours: 3 }
|
||||
- { name: atlas-zfs-snapshot-daily.timer, max_age_hours: 36 }
|
||||
- { name: atlas-zfs-snapshot-weekly.timer, max_age_hours: 216 }
|
||||
- { name: atlas-zfs-snapshot-monthly.timer, max_age_hours: 960 }
|
||||
- { name: zfs-scrub-monthly@zpool.timer, max_age_hours: 960 }
|
||||
- { name: atlas-borg-backup.timer, max_age_hours: 48 }
|
||||
- { name: atlas-borg-check.timer, max_age_hours: 960 }
|
||||
# The first manual USB reminder is not due until October; activation is checked, not age.
|
||||
- { name: atlas-usb-reminder.timer, max_age_hours: 0 }
|
||||
atlas_monitor_failure_units:
|
||||
- atlas-zfs-snapshot@.service
|
||||
- zfs-scrub@zpool.service
|
||||
- atlas-borg-backup.service
|
||||
- atlas-borg-check.service
|
||||
- atlas-usb-backup.service
|
||||
- atlas-usb-reminder.service
|
||||
- atlas-health-monitor.service
|
||||
atlas_monitor_remote_capacity:
|
||||
user: "{{ atlas_borg_repository_user }}"
|
||||
host: "{{ atlas_borg_repository_host }}"
|
||||
run_as: "{{ atlas_borg_username }}"
|
||||
ssh_wrapper: "{{ atlas_borg_ssh_wrapper_path }}"
|
||||
warning_percent: 80
|
||||
critical_percent: 90
|
||||
growth_warning_gib_day: 500
|
||||
atlas_manage_sharing: true
|
||||
atlas_manage_media_stack: false
|
||||
# Planned after data-protection validation: move iCloudPD photo ingestion from
|
||||
# Aegis to Atlas, with photos under /zpool/archive/Pictures/iCloudPD and
|
||||
# application/MFA state in a separate dataset. Do not deploy or cut over yet.
|
||||
|
||||
# WireGuard is retired on Atlas. These rootless services are a temporary home
|
||||
# until Uranus replaces them.
|
||||
wireguard_overlay_enabled: true
|
||||
wireguard_address: 10.0.0.2/24
|
||||
wireguard_peers:
|
||||
- name: prometheus
|
||||
host: prometheus
|
||||
endpoint: "{{ hostvars['prometheus']['ansible_host'] }}:{{ hostvars['prometheus']['wireguard_listen_port'] }}"
|
||||
allowed_ips:
|
||||
- 10.0.0.0/24
|
||||
persistent_keepalive: 25
|
||||
|
||||
backend_phase1_enabled: true
|
||||
backend_phase1_start_services: true
|
||||
backend_phase1_bind_address: "{{ ansible_host }}"
|
||||
backend_phase1_firewalld_zone: "{{ atlas_firewalld_zone }}"
|
||||
backend_phase1_npm_source_ip: "{{ atlas_aegis_ip }}"
|
||||
backend_phase1_syncthing_native_subnet: "{{ atlas_lan_subnet }}"
|
||||
backend_phase1_music_sync_enabled: true
|
||||
backend_phase1_start_services: false
|
||||
backend_phase1_wireguard_address: 10.0.0.2
|
||||
|
||||
rocky_manage_openzfs_repo: true
|
||||
rocky_manage_syncthing_binary: false
|
||||
@@ -220,21 +69,13 @@ rocky_podman_packages:
|
||||
|
||||
host_packages:
|
||||
- cockpit
|
||||
- cockpit-podman
|
||||
- cockpit-storaged
|
||||
- realmd
|
||||
- pcp
|
||||
- python3-pcp
|
||||
- cryptsetup
|
||||
- nfs-utils
|
||||
- policycoreutils
|
||||
- policycoreutils-python-utils
|
||||
- python3-libselinux
|
||||
- setroubleshoot-server
|
||||
- samba
|
||||
- samba-client
|
||||
- samba-common-tools
|
||||
- borgbackup
|
||||
- zfs
|
||||
|
||||
atlas_nfs_exports:
|
||||
@@ -268,18 +109,4 @@ atlas_firewalld_rich_rules:
|
||||
host_enabled_services:
|
||||
- sshd
|
||||
- cockpit.socket
|
||||
- pmlogger.service
|
||||
- zfs.target
|
||||
|
||||
# Torrent Web UI: LAN and the existing Aegis gateway for the manual NPM proxy.
|
||||
atlas_manage_qbittorrent: true
|
||||
atlas_qbittorrent_image: docker.io/qbittorrentofficial/qbittorrent-nox@sha256:92bfd78d731e254ba64f62b77b0696add6447a33642ee5feda106a26b285aa7f
|
||||
atlas_qbittorrent_reverse_proxy_enabled: true
|
||||
atlas_qbittorrent_public_domain: torrent.fscotto.co
|
||||
|
||||
# LAN-only HTTP downloader; RPC secret is generated and retained privately on Atlas.
|
||||
atlas_manage_aria2: true
|
||||
atlas_aria2_gateway_enabled: true
|
||||
atlas_aria2_public_domain: downloads.fscotto.co
|
||||
atlas_aria2_image: docker.io/p3terx/aria2-pro@sha256:086d1a37c586edb07ec0fb956bf9edd89d1d38d138ad5309ff96d510c8c9a011
|
||||
atlas_ariang_image: docker.io/p3terx/ariang@sha256:73849cf75fe9f959229222622e887310df505cbf868eb9c735e2af376523c010
|
||||
|
||||
@@ -1,30 +1,6 @@
|
||||
---
|
||||
hostname: deadalus
|
||||
workstation_wsl_windows_user_home: /mnt/c/Users/FABIOSCOTTODISANTOLO
|
||||
workstation_ecaas_workspace: "{{ user_home }}/Work/sipo/ecaas"
|
||||
workstation_cdp_workspace: "{{ user_home }}/Work/sipo/cdp"
|
||||
workstation_ecaas_git_required_ca: ecaas.datacenter.comune.roma.crt
|
||||
|
||||
# Claude Code, Codex and the Cline CLI are the coding agents installed on WSL; every
|
||||
# other managed agent is disabled. Cline's cross-tool instructions (.agents/AGENTS.md,
|
||||
# .cline/rules/) and the shared ~/.config/ai context are deployed for the ecaas/cdp
|
||||
# devcontainers, and the cline npm package is installed by profile_workstation_dev_common.
|
||||
claude_code_install_enabled: true
|
||||
claude_code_uninstall_enabled: false
|
||||
opencode_install_enabled: false
|
||||
opencode_deploy_enabled: false
|
||||
opencode_uninstall_enabled: true
|
||||
codex_install_enabled: true
|
||||
codex_deploy_enabled: false
|
||||
codex_uninstall_enabled: false
|
||||
gemini_cli_install_enabled: false
|
||||
gemini_cli_deploy_enabled: false
|
||||
gemini_cli_uninstall_enabled: true
|
||||
cline_install_enabled: true
|
||||
cline_deploy_enabled: true
|
||||
cline_uninstall_enabled: false
|
||||
ibm_bob_install_enabled: false
|
||||
ibm_bob_uninstall_enabled: true
|
||||
|
||||
host_packages: []
|
||||
host_enabled_services: []
|
||||
|
||||
@@ -1,20 +1,7 @@
|
||||
---
|
||||
hostname: ikaros
|
||||
|
||||
codex_relay_install_enabled: false
|
||||
codex_relay_uninstall_enabled: true
|
||||
gemini_cli_install_enabled: false
|
||||
gemini_cli_deploy_enabled: false
|
||||
gemini_cli_uninstall_enabled: true
|
||||
chatgpt_desktop_install_enabled: true
|
||||
desktop_ai_media_enabled: true
|
||||
desktop_ai_media_external_storage_enabled: true
|
||||
desktop_ai_media_external_luks_uuid: 6948c504-2d60-4cc8-9e7f-3ccdf28e80d7
|
||||
desktop_ai_media_external_mountpoint: /run/media/fscotto/Backup
|
||||
desktop_ai_media_external_source: /run/media/fscotto/Backup/ai-media
|
||||
|
||||
host_packages:
|
||||
- podman
|
||||
- openssh-clients
|
||||
- openssh-server
|
||||
- mesa-vulkan-drivers
|
||||
@@ -151,7 +138,7 @@ gnome_gsettings_settings:
|
||||
value: "'file:///usr/share/backgrounds/gnome/morphogenesis-l.svg'"
|
||||
- schema: org.gnome.desktop.search-providers
|
||||
key: sort-order
|
||||
value: "['org.gnome.Settings.desktop', 'org.gnome.Contacts.desktop', 'org.gnome.Nautilus.desktop', 'org.mozilla.firefox.desktop', 'org.gnome.seahorse.Application.desktop', 'org.gnome.Calculator.desktop', 'org.gnome.Calendar.desktop', 'org.gnome.Software.desktop', 'org.gnome.Characters.desktop', 'org.gnome.Boxes.desktop', 'org.gnome.clocks.desktop', 'com.mattjakeman.ExtensionManager.desktop']"
|
||||
value: "['org.gnome.Settings.desktop', 'org.gnome.Contacts.desktop', 'org.gnome.Nautilus.desktop']"
|
||||
- schema: org.gnome.desktop.wm.keybindings
|
||||
key: switch-to-workspace-1
|
||||
value: "['<Super>1']"
|
||||
@@ -214,7 +201,7 @@ gnome_gsettings_settings:
|
||||
value: "false"
|
||||
- schema: org.gnome.nautilus.preferences
|
||||
key: default-folder-viewer
|
||||
value: "'icon-view'"
|
||||
value: "'list-view'"
|
||||
- schema: org.gnome.nautilus.preferences
|
||||
key: show-create-link
|
||||
value: "true"
|
||||
@@ -242,19 +229,19 @@ gnome_gsettings_settings:
|
||||
- schema: org.gnome.shell
|
||||
key: app-picker-layout
|
||||
value: >-
|
||||
[{'System': <{'position': <0>}>, 'Utilities': <{'position': <1>}>, 'org.fedoraproject.MediaWriter.desktop': <{'position': <2>}>, 'org.gnome.Contacts.desktop': <{'position': <3>}>, 'org.gnome.Calendar.desktop': <{'position': <4>}>, 'org.gnome.Calculator.desktop': <{'position': <5>}>, 'org.gnome.Weather.desktop': <{'position': <6>}>, 'org.gnome.clocks.desktop': <{'position': <7>}>, 'org.gnome.Maps.desktop': <{'position': <8>}>, 'org.gnome.SimpleScan.desktop': <{'position': <9>}>, 'org.gnome.TextEditor.desktop': <{'position': <10>}>, 'org.gnome.Settings.desktop': <{'position': <11>}>, 'org.gnome.Boxes.desktop': <{'position': <12>}>, 'org.gnome.Showtime.desktop': <{'position': <13>}>, 'org.gnome.Snapshot.desktop': <{'position': <14>}>, 'org.gnome.Characters.desktop': <{'position': <15>}>, 'org.gnome.Tour.desktop': <{'position': <16>}>, 'org.gnome.Yelp.desktop': <{'position': <17>}>, 'org.gnome.Software.desktop': <{'position': <18>}>, 'be.alexandervanhee.gradia.desktop': <{'position': <19>}>, 'com.github.jeromerobert.pdfarranger.desktop': <{'position': <20>}>, 'org.onlyoffice.desktopeditors.desktop': <{'position': <21>}>, 'org.gnome.Meld.desktop': <{'position': <22>}>, 'com.mattjakeman.ExtensionManager.desktop': <{'position': <23>}>}, {'com.raspberrypi.rpi-imager.desktop': <{'position': <0>}>, 'org.remmina.Remmina.desktop': <{'position': <1>}>, 'com.nextcloud.desktopclient.nextcloud.desktop': <{'position': <2>}>, 'syncthing-start.desktop': <{'position': <3>}>, 'syncthing-ui.desktop': <{'position': <4>}>, 'emacs.desktop': <{'position': <5>}>, 'emacs-client.desktop': <{'position': <6>}>, 'chatgpt.desktop': <{'position': <7>}>, 'org.gnome.gitlab.somas.Apostrophe.desktop': <{'position': <8>}>, 'mpv.desktop': <{'position': <9>}>, 'htop.desktop': <{'position': <10>}>, 'ai-media-facefusion.desktop': <{'position': <11>}>, 'ai-media-rvc.desktop': <{'position': <12>}>}]
|
||||
[{'System': <{'position': <0>}>, 'Utilities': <{'position': <1>}>, 'org.fedoraproject.MediaWriter.desktop': <{'position': <2>}>, 'org.gnome.Contacts.desktop': <{'position': <3>}>, 'org.gnome.Calendar.desktop': <{'position': <4>}>, 'org.gnome.Calculator.desktop': <{'position': <5>}>, 'org.gnome.Weather.desktop': <{'position': <6>}>, 'org.gnome.clocks.desktop': <{'position': <7>}>, 'org.gnome.Maps.desktop': <{'position': <8>}>, 'org.gnome.SimpleScan.desktop': <{'position': <9>}>, 'org.gnome.TextEditor.desktop': <{'position': <10>}>, 'org.gnome.Settings.desktop': <{'position': <11>}>, 'org.gnome.Boxes.desktop': <{'position': <12>}>, 'org.gnome.Showtime.desktop': <{'position': <13>}>, 'org.gnome.Snapshot.desktop': <{'position': <14>}>, 'org.gnome.Characters.desktop': <{'position': <15>}>, 'org.gnome.Tour.desktop': <{'position': <16>}>, 'org.gnome.Yelp.desktop': <{'position': <17>}>, 'org.gnome.Software.desktop': <{'position': <18>}>, 'be.alexandervanhee.gradia.desktop': <{'position': <19>}>, 'com.github.jeromerobert.pdfarranger.desktop': <{'position': <20>}>, 'org.onlyoffice.desktopeditors.desktop': <{'position': <21>}>, 'org.gnome.Meld.desktop': <{'position': <22>}>, 'com.mattjakeman.ExtensionManager.desktop': <{'position': <23>}>}, {'org.remmina.Remmina.desktop': <{'position': <0>}>, 'ch.protonmail.protonmail-bridge.desktop': <{'position': <1>}>, 'syncthing-start.desktop': <{'position': <2>}>, 'syncthing-ui.desktop': <{'position': <3>}>, 'emacs.desktop': <{'position': <4>}>, 'emacs-client.desktop': <{'position': <5>}>, 'org.gnome.gitlab.somas.Apostrophe.desktop': <{'position': <6>}>, 'mpv.desktop': <{'position': <7>}>, 'htop.desktop': <{'position': <8>}>, 'org.mozilla.thunderbird.desktop': <{'position': <9>}>}]
|
||||
- schema: org.gnome.shell
|
||||
key: disabled-extensions
|
||||
value: >-
|
||||
['window-list@gnome-shell-extensions.gcampax.github.com', 'background-logo@fedorahosted.org', 'apps-menu@gnome-shell-extensions.gcampax.github.com', 'places-menu@gnome-shell-extensions.gcampax.github.com', 'maximize-new-windows@VitalyOstanin']
|
||||
['window-list@gnome-shell-extensions.gcampax.github.com', 'background-logo@fedorahosted.org', 'apps-menu@gnome-shell-extensions.gcampax.github.com', 'places-menu@gnome-shell-extensions.gcampax.github.com']
|
||||
- schema: org.gnome.shell
|
||||
key: enabled-extensions
|
||||
value: >-
|
||||
['status-icons@gnome-shell-extensions.gcampax.github.com', 'gnome-ui-tune@itstime.tech', 'appindicatorsupport@rgcjonas.gmail.com', 'bluetooth-battery-monitor@v8v88v8v88.com', 'clipboard-indicator@tudmotu.com', 'status-area-horizontal-spacing@mathematical.coffee.gmail.com', 'MaximizeWindowIntoNewWorkspace@kyleross.com', 'gnome-shell-extension-maximized-by-default@stiggimy.github.com']
|
||||
['status-icons@gnome-shell-extensions.gcampax.github.com', 'gnome-ui-tune@itstime.tech', 'appindicatorsupport@rgcjonas.gmail.com', 'bluetooth-battery-monitor@v8v88v8v88.com', 'clipboard-indicator@tudmotu.com', 'status-area-horizontal-spacing@mathematical.coffee.gmail.com', 'MaximizeWindowIntoNewWorkspace@kyleross.com', 'maximize-new-windows@VitalyOstanin']
|
||||
- schema: org.gnome.shell
|
||||
key: favorite-apps
|
||||
value: >-
|
||||
['org.gnome.Nautilus.desktop', 'org.mozilla.firefox.desktop', 'com.spotify.Client.desktop', 'net.thunderbird.Thunderbird.desktop', 'org.telegram.desktop.desktop', 'Cline.desktop', 'org.desktop_plus.desktop-plus.desktop', 'com.microsoft.VSCode.desktop', 'org.gnome.Ptyxis.desktop', 'virt-manager.desktop']
|
||||
['org.gnome.Nautilus.desktop', 'org.mozilla.firefox.desktop', 'com.spotify.Client.desktop', 'org.gnome.Evolution.desktop', 'org.telegram.desktop.desktop', 'org.gnome.Ptyxis.desktop', 'virt-manager.desktop']
|
||||
- schema: org.gnome.shell
|
||||
key: remember-mount-password
|
||||
value: "true"
|
||||
|
||||
@@ -1,14 +1,6 @@
|
||||
---
|
||||
hostname: nymph
|
||||
|
||||
codex_relay_install_enabled: false
|
||||
codex_relay_uninstall_enabled: true
|
||||
gemini_cli_install_enabled: false
|
||||
gemini_cli_deploy_enabled: false
|
||||
gemini_cli_uninstall_enabled: true
|
||||
|
||||
chatgpt_desktop_install_enabled: true
|
||||
|
||||
# Fedora Workstation/GNOME laptop target. GNOME is provided by the base Fedora
|
||||
# Workstation install; Ansible deploys shared desktop dotfiles but leaves GNOME
|
||||
# settings unmanaged for now.
|
||||
|
||||
@@ -6,26 +6,7 @@ ansible_port: 22
|
||||
ansible_ssh_private_key_file: /home/fscotto/.ssh/id_ed25519
|
||||
|
||||
server_username: rocky
|
||||
server_legacy_stack_retired: true
|
||||
# Destructive deletion runs only with an explicit extra-var and cleanup tag.
|
||||
server_legacy_cleanup: false
|
||||
# Explicit opt-in cleanup; no data, volumes, networks or NPM images are removed.
|
||||
server_legacy_image_cleanup: false
|
||||
server_legacy_images:
|
||||
- docker.gitea.com/gitea:1.25.2
|
||||
- docker.io/deluan/navidrome:latest
|
||||
- docker.io/library/postgres:13
|
||||
server_npm_quadlet_stage: true
|
||||
server_npm_quadlet_image: docker.io/jc21/nginx-proxy-manager@sha256:52b2c59994f3d36acfcf70a1626f29734df0ed8c71bacc0269f78b6f939858bb
|
||||
# The stopped-source export and live Quadlet cutover passed on 2026-10-03.
|
||||
server_npm_quadlet_cutover: true
|
||||
server_backup_export_enabled: true
|
||||
server_backup_export_start_timer: true
|
||||
# Install the final-copy helper only; it is never run by a normal playbook invocation.
|
||||
server_gitea_proxy_enabled: true
|
||||
server_gitea_on_atlas: true
|
||||
server_gitea_npm_domains:
|
||||
- git.fscotto.duckdns.org
|
||||
server_duckdns_domain: fscotto
|
||||
server_ssh_authorized_keys:
|
||||
- name: ikaros
|
||||
key: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINrIxXjA3ffPwziKGR5gzc4gAoBehQPlnEMcXF4Wl0ZS ikaros"
|
||||
@@ -38,25 +19,16 @@ wireguard_overlay_enabled: true
|
||||
wireguard_address: 10.0.0.1/24
|
||||
wireguard_listen_port: 51820
|
||||
wireguard_enable_ipv4_forwarding: true
|
||||
wireguard_reload_rootful_podman_networks: true
|
||||
wireguard_peers:
|
||||
- name: aegis
|
||||
host: aegis
|
||||
# TODO: Aggiungere VIP di Uranus in futuro
|
||||
- name: atlas
|
||||
host: atlas
|
||||
allowed_ips:
|
||||
- 10.0.0.2/32
|
||||
- 192.168.178.0/24
|
||||
|
||||
host_packages:
|
||||
- cockpit
|
||||
- cockpit-navigator
|
||||
- cockpit-podman
|
||||
- cockpit-storaged
|
||||
- realmd
|
||||
- pcp
|
||||
- python3-pcp
|
||||
- setroubleshoot-server
|
||||
|
||||
host_enabled_services:
|
||||
- cockpit.socket
|
||||
- pmlogger.service
|
||||
|
||||
@@ -99,7 +99,7 @@ all:
|
||||
wireguard_overlay:
|
||||
hosts:
|
||||
prometheus:
|
||||
aegis:
|
||||
atlas:
|
||||
|
||||
role_backend_phase1:
|
||||
hosts:
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
---
|
||||
desktop_ai_media_enabled: false
|
||||
desktop_ai_media_root: "{{ user_home }}/.local/share/ai-media"
|
||||
desktop_ai_media_build_root: "{{ user_home }}/.local/share/ai-media-build"
|
||||
desktop_ai_media_external_storage_enabled: false
|
||||
desktop_ai_media_external_luks_uuid: ""
|
||||
desktop_ai_media_external_mountpoint: ""
|
||||
desktop_ai_media_external_source: ""
|
||||
desktop_ai_media_debian_snapshot: "20261013T000000Z"
|
||||
desktop_ai_media_base_image: >-
|
||||
docker.io/library/python@sha256:34386ef0cb081344d7ec1c103ba398e6e9f64e9ab3a1509accc92a4e24a07258
|
||||
desktop_ai_media_facefusion_revision: 72470819a0373be3388b3929c8f8f311f418fc3c
|
||||
desktop_ai_media_rvc_revision: 81eed5e8f68b6bed1789f682fe78cdd324495afc
|
||||
desktop_ai_media_apps: [facefusion, rvc]
|
||||
@@ -1,56 +0,0 @@
|
||||
import configparser
|
||||
import pathlib
|
||||
import re
|
||||
import sys
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
root = pathlib.Path(sys.argv[1]).resolve()
|
||||
home = pathlib.Path.home()
|
||||
local_filesystems = {
|
||||
"btrfs", "ext2", "ext3", "ext4", "xfs", "zfs", "tmpfs", "overlay",
|
||||
"ramfs", "ntfs3", "vfat", "exfat",
|
||||
}
|
||||
mounts = []
|
||||
for line in pathlib.Path("/proc/self/mountinfo").read_text().splitlines():
|
||||
fields, description = line.split(" - ", 1)
|
||||
mount = re.sub(r"\\([0-7]{3})", lambda m: chr(int(m[1], 8)), fields.split()[4])
|
||||
mounts.append((pathlib.Path(mount), description.split()[0]))
|
||||
automount_at_root = any(p == root and kind == "autofs" for p, kind in mounts)
|
||||
backing_mount_at_root = any(
|
||||
p == root and kind != "autofs" for p, kind in mounts
|
||||
)
|
||||
if automount_at_root and not backing_mount_at_root:
|
||||
raise SystemExit("Media storage is not mounted; refusing to start")
|
||||
covering = [
|
||||
(p, kind) for p, kind in mounts
|
||||
if kind != "autofs" and (root == p or root.is_relative_to(p))
|
||||
]
|
||||
if covering:
|
||||
selected = max(covering, key=lambda entry: len(entry[0].parts))
|
||||
if selected[1] not in local_filesystems:
|
||||
raise SystemExit("Media storage is not on a local filesystem; refusing to start")
|
||||
for mount, kind in mounts:
|
||||
if mount == root and kind == "autofs":
|
||||
continue
|
||||
if mount.is_relative_to(root) and kind not in local_filesystems:
|
||||
raise SystemExit("Non-local mount beneath media storage; refusing to start")
|
||||
sync_roots = []
|
||||
nextcloud = home / ".config/Nextcloud/nextcloud.cfg"
|
||||
if nextcloud.exists():
|
||||
configuration = configparser.ConfigParser(interpolation=None, strict=False)
|
||||
configuration.read(nextcloud)
|
||||
for section in configuration.sections():
|
||||
for key, value in configuration.items(section):
|
||||
if key.lower().endswith("localpath"):
|
||||
sync_roots.append(pathlib.Path(value).expanduser().resolve())
|
||||
for configuration in (
|
||||
home / ".config/syncthing/config.xml",
|
||||
home / ".local/state/syncthing/config.xml",
|
||||
):
|
||||
if configuration.exists():
|
||||
for folder in ET.parse(configuration).getroot().findall("folder"):
|
||||
if folder.get("path"):
|
||||
sync_roots.append(pathlib.Path(folder.get("path")).expanduser().resolve())
|
||||
for path in sync_roots:
|
||||
if root == path or root.is_relative_to(path) or path.is_relative_to(root):
|
||||
raise SystemExit("Media storage overlaps a Nextcloud/Syncthing folder; refusing to start")
|
||||
@@ -1,88 +0,0 @@
|
||||
import hashlib
|
||||
import pathlib
|
||||
import sys
|
||||
import zipfile
|
||||
|
||||
app = sys.argv[1]
|
||||
root = pathlib.Path("/opt/app")
|
||||
if app == "facefusion":
|
||||
sys.path.insert(0, str(root))
|
||||
from facefusion import state_manager
|
||||
from facefusion.args import apply_args
|
||||
from facefusion.program import create_program
|
||||
from facefusion.core import common_pre_check, processors_pre_check
|
||||
|
||||
args = vars(create_program().parse_args([
|
||||
"run", "--execution-providers", "cpu",
|
||||
"--processors", "face_swapper",
|
||||
]))
|
||||
apply_args(args, state_manager.init_item)
|
||||
if not common_pre_check() or not processors_pre_check():
|
||||
raise RuntimeError("FaceFusion model preparation failed")
|
||||
else:
|
||||
for relative in (
|
||||
"hubert_base/config.json",
|
||||
"hubert_base/preprocessor_config.json",
|
||||
"hubert_base/pytorch_model.bin",
|
||||
"rmvpe.pt",
|
||||
):
|
||||
destination = root / "assets" / relative
|
||||
if relative == "rmvpe.pt":
|
||||
destination = root / "assets/rmvpe/rmvpe.pt"
|
||||
destination.parent.mkdir(parents=True, exist_ok=True)
|
||||
if not destination.is_file():
|
||||
raise FileNotFoundError("Missing checksum-pinned public model: " + str(destination))
|
||||
for directory in ("weights", "indices", "pretrained", "pretrained_v2", "pymss_weights"):
|
||||
(root / "assets" / directory).mkdir(parents=True, exist_ok=True)
|
||||
# Mutable working data stays outside the immutable application tree.
|
||||
for name, destination in (
|
||||
("TEMP", "/tmp/rvc-temp"),
|
||||
("assets/weights", "/work/state/weights"),
|
||||
("logs", "/work/state"),
|
||||
):
|
||||
path = root / name
|
||||
if path.exists():
|
||||
import shutil
|
||||
shutil.rmtree(path)
|
||||
path.symlink_to(destination)
|
||||
|
||||
# Expose only separation models that are actually baked into this image.
|
||||
separation = root / "tools/pymss_webui.py"
|
||||
original = "PYMSS_MODEL_CHOICES = [spec.label for spec in MODEL_SPECS]"
|
||||
replacement = """PYMSS_MODEL_CHOICES = [
|
||||
spec.label for spec in MODEL_SPECS
|
||||
if (weight_pymss_root / spec.model_file).is_file()
|
||||
and (weight_pymss_root / spec.config_file).is_file()
|
||||
]"""
|
||||
code = separation.read_text()
|
||||
if code.count(original) != 1:
|
||||
raise RuntimeError("Pinned RVC separation model selector has changed")
|
||||
separation.write_text(code.replace(original, replacement))
|
||||
webui = root / "webui.py"
|
||||
code = webui.read_text()
|
||||
for label, destination in (
|
||||
("主结果文件夹", "/work/output/vocals"),
|
||||
("分离残余文件夹", "/work/output/instrumental"),
|
||||
):
|
||||
original = 'label=i18n("' + label + '"), value="opt"'
|
||||
if code.count(original) != 1:
|
||||
raise RuntimeError("Pinned RVC separation output selector has changed")
|
||||
code = code.replace(original, 'label=i18n("' + label + '"), value="' + destination + '"')
|
||||
webui.write_text(code)
|
||||
|
||||
# Bake only the public silence fixture; personal datasets never enter the build.
|
||||
with zipfile.ZipFile(root / "assets/mute.zip") as archive:
|
||||
destination = pathlib.Path("/opt/training-fixture")
|
||||
for entry in archive.infolist():
|
||||
target = (destination / entry.filename).resolve()
|
||||
if not target.is_relative_to(destination):
|
||||
raise ValueError("Invalid public silence archive member")
|
||||
archive.extractall(destination)
|
||||
|
||||
with open("/opt/model-checksums.sha256", "w") as manifest:
|
||||
for directory in (root / ".assets", root / "assets"):
|
||||
if directory.exists():
|
||||
for path in sorted(directory.rglob("*")):
|
||||
if path.is_file():
|
||||
digest = hashlib.file_digest(path.open("rb"), "sha256").hexdigest()
|
||||
manifest.write(digest + " " + str(path) + "\n")
|
||||
@@ -1,384 +0,0 @@
|
||||
"""Small host-side orchestrator for offline ai-media presets."""
|
||||
|
||||
import argparse
|
||||
from datetime import datetime
|
||||
import ipaddress
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
from urllib.parse import urlsplit
|
||||
import uuid
|
||||
|
||||
|
||||
NAME = re.compile(r"[A-Za-z0-9][A-Za-z0-9._-]*\Z")
|
||||
SOURCE_NAMES = tuple(f"source{number}.jpg" for number in range(11, 19))
|
||||
|
||||
|
||||
def video_url(value):
|
||||
parsed = urlsplit(value)
|
||||
if parsed.scheme not in ("http", "https") or not parsed.hostname or parsed.username or parsed.password:
|
||||
raise ValueError("Use an HTTP(S) video URL without embedded credentials")
|
||||
host = parsed.hostname.lower().rstrip(".")
|
||||
if host == "localhost" or host.endswith(".localhost"):
|
||||
raise ValueError("Local URLs are not accepted")
|
||||
try:
|
||||
address = ipaddress.ip_address(host)
|
||||
except ValueError:
|
||||
pass
|
||||
else:
|
||||
if not address.is_global:
|
||||
raise ValueError("Private or local IP URLs are not accepted")
|
||||
return value
|
||||
|
||||
|
||||
def media_file(root, name, *, video=False):
|
||||
if not NAME.fullmatch(name) or name in (".", ".."):
|
||||
raise ValueError("Use a simple filename in the ai-media input directory")
|
||||
path = root / "input" / name
|
||||
if not path.is_file() or path.is_symlink():
|
||||
raise FileNotFoundError(path)
|
||||
if video and path.suffix.lower() != ".mp4":
|
||||
raise ValueError("The video must be an MP4 file")
|
||||
return path
|
||||
|
||||
|
||||
def audio_file(root, name):
|
||||
if not name or any(not NAME.fullmatch(part) or part in (".", "..")
|
||||
for part in name.split("/")):
|
||||
raise ValueError("Use an audio path relative to input/ or output/ without traversal")
|
||||
matches = [root / directory / name for directory in ("input", "output")]
|
||||
matches = [path for path in matches if path.is_file() and path.resolve() == path]
|
||||
if len(matches) != 1:
|
||||
raise ValueError("Audio must exist in exactly one of input/ or output/")
|
||||
return matches[0]
|
||||
|
||||
|
||||
def container_path(root, path):
|
||||
directory = path.relative_to(root).parts[0]
|
||||
if directory not in ("input", "output"):
|
||||
raise ValueError("Media path outside input/output")
|
||||
return "/work/" + str(path.relative_to(root))
|
||||
|
||||
|
||||
def run(*command):
|
||||
print("+", " ".join(map(str, command)), flush=True)
|
||||
subprocess.run([str(part) for part in command], check=True)
|
||||
|
||||
|
||||
def has_stream(path, kind):
|
||||
result = subprocess.run([
|
||||
"ffprobe", "-v", "error", "-show_entries", "stream=codec_type",
|
||||
"-of", "json", str(path),
|
||||
], check=True, capture_output=True, text=True)
|
||||
return kind in [stream["codec_type"] for stream in json.loads(result.stdout)["streams"]]
|
||||
|
||||
|
||||
def probe(path, kind):
|
||||
if not has_stream(path, kind):
|
||||
raise RuntimeError(f"Missing {kind} stream: {path}")
|
||||
|
||||
|
||||
def duration(path):
|
||||
result = subprocess.run([
|
||||
"ffprobe", "-v", "error", "-show_entries", "format=duration",
|
||||
"-of", "default=noprint_wrappers=1:nokey=1", str(path),
|
||||
], check=True, capture_output=True, text=True)
|
||||
return float(result.stdout.strip())
|
||||
|
||||
|
||||
def output_path(root, video, suffix, extension="mp4"):
|
||||
return root / "output" / f"{video.stem}-{suffix}.{extension}"
|
||||
|
||||
|
||||
def mix_target(root, args):
|
||||
name = args.output or f"{Path(args.vocals).stem}-mix.wav"
|
||||
return wav_target(root, name)
|
||||
|
||||
|
||||
def wav_target(root, name):
|
||||
if not NAME.fullmatch(name) or Path(name).suffix.lower() != ".wav":
|
||||
raise ValueError("Use a simple WAV output filename")
|
||||
target = root / "output" / name
|
||||
if target.exists() or target.is_symlink():
|
||||
raise FileExistsError(target)
|
||||
return target
|
||||
|
||||
|
||||
def process_voice(args, root, launcher):
|
||||
source = audio_file(root, args.audio)
|
||||
probe(source, "audio")
|
||||
target = wav_target(root, args.output or f"{source.stem}-mia_voce.wav")
|
||||
job = root / "output" / f".{source.stem}-voice-convert-{args.job_id}"
|
||||
job.mkdir(mode=0o700)
|
||||
print("Working directory:", job, flush=True)
|
||||
prepared = job / "audio.wav"
|
||||
run(launcher, "ffmpeg", "-hide_banner", "-loglevel", "error", "-n",
|
||||
"-i", container_path(root, source), "-map", "0:a:0", "-vn",
|
||||
"-c:a", "pcm_s16le", container_path(root, prepared))
|
||||
run(launcher, "rvc", "cli", container_path(root, prepared),
|
||||
container_path(root, job), "--convert-only")
|
||||
converted = job / "vocals-mia_voce.wav"
|
||||
probe(converted, "audio")
|
||||
os.link(converted, target)
|
||||
return target
|
||||
|
||||
|
||||
def process_mix(args, root, launcher):
|
||||
vocals = audio_file(root, args.vocals)
|
||||
instrumental = audio_file(root, args.instrumental)
|
||||
target = mix_target(root, args)
|
||||
for source in (vocals, instrumental):
|
||||
probe(source, "audio")
|
||||
run(launcher, "ffmpeg", "-hide_banner", "-loglevel", "error", "-n",
|
||||
"-i", container_path(root, vocals), "-i", container_path(root, instrumental),
|
||||
"-filter_complex", "[0:a][1:a]amix=inputs=2:duration=longest:normalize=0[a]",
|
||||
"-map", "[a]", "-c:a", "pcm_s16le", container_path(root, target))
|
||||
probe(target, "audio")
|
||||
return target
|
||||
|
||||
|
||||
def mux(launcher, root, video, audio, target):
|
||||
run(launcher, "ffmpeg", "-hide_banner", "-loglevel", "error", "-n",
|
||||
"-i", container_path(root, video), "-i", container_path(root, audio),
|
||||
"-map", "0:v:0", "-map", "1:a:0", "-c:v", "copy", "-c:a", "aac",
|
||||
"-b:a", "192k", "-shortest", "-movflags", "+faststart",
|
||||
container_path(root, target))
|
||||
probe(target, "video")
|
||||
probe(target, "audio")
|
||||
|
||||
|
||||
def download_video(root, url, job_id):
|
||||
video_url(url)
|
||||
if not job_id or not NAME.fullmatch(job_id):
|
||||
raise ValueError("Invalid job ID")
|
||||
if shutil.which("yt-dlp") is None:
|
||||
raise RuntimeError("yt-dlp is required for URL downloads")
|
||||
prefix = f"download-{job_id}"
|
||||
destination = root / "input" / f"{prefix}.mp4"
|
||||
if list((root / "input").glob(prefix + ".*")):
|
||||
raise FileExistsError(destination)
|
||||
print("Downloading one video into input/ with yt-dlp", flush=True)
|
||||
subprocess.run([
|
||||
"yt-dlp", "--ignore-config", "--no-playlist", "--no-overwrites",
|
||||
"--no-progress", "-t", "mp4", "--recode-video", "mp4",
|
||||
"--output", str(root / "input" / f"{prefix}.%(ext)s"), url,
|
||||
], check=True)
|
||||
if not destination.is_file() or destination.is_symlink():
|
||||
raise RuntimeError("yt-dlp did not produce the expected MP4 in input/")
|
||||
probe(destination, "video")
|
||||
return destination
|
||||
|
||||
|
||||
def process_split(args, root, launcher, video):
|
||||
probe(video, "audio")
|
||||
target = root / "output" / f"{video.stem}-{args.preset}"
|
||||
if target.exists():
|
||||
raise FileExistsError(target)
|
||||
job = root / "output" / f".{video.stem}-{args.preset}-{args.job_id}"
|
||||
job.mkdir(mode=0o700)
|
||||
print("Working directory:", job, flush=True)
|
||||
silent = job / "video.mp4"
|
||||
audio = job / "audio.wav"
|
||||
run(launcher, "ffmpeg", "-hide_banner", "-loglevel", "error", "-n",
|
||||
"-i", container_path(root, video), "-map", "0:v:0", "-c:v", "copy",
|
||||
"-an", "-movflags", "+faststart", container_path(root, silent))
|
||||
probe(silent, "video")
|
||||
if has_stream(silent, "audio"):
|
||||
raise RuntimeError("Unexpected audio stream in split video")
|
||||
run(launcher, "ffmpeg", "-hide_banner", "-loglevel", "error", "-n",
|
||||
"-i", container_path(root, video), "-map", "0:a:0", "-vn",
|
||||
"-c:a", "pcm_s16le", container_path(root, audio))
|
||||
probe(audio, "audio")
|
||||
files = {"video.mp4": silent, "audio.wav": audio}
|
||||
if args.preset == "split-stems":
|
||||
run(launcher, "rvc", "cli", container_path(root, audio),
|
||||
container_path(root, job), "--separate-only")
|
||||
for stem in ("vocals", "instrumental"):
|
||||
matches = list((job / stem).glob("*.wav"))
|
||||
if len(matches) != 1:
|
||||
raise RuntimeError(f"Expected exactly one {stem} stem")
|
||||
probe(matches[0], "audio")
|
||||
files[f"{stem}.wav"] = matches[0]
|
||||
# Publish only after every processing step and stream check succeeded.
|
||||
target.mkdir(mode=0o700)
|
||||
for name, source in files.items():
|
||||
os.link(source, target / name)
|
||||
return target
|
||||
|
||||
|
||||
def process(args, root, launcher):
|
||||
video = media_file(root, args.video, video=True)
|
||||
probe(video, "video")
|
||||
if args.preset in ("split", "split-stems"):
|
||||
return process_split(args, root, launcher, video)
|
||||
if args.preset == "merge":
|
||||
audio = audio_file(root, args.audio)
|
||||
probe(audio, "audio")
|
||||
target = output_path(root, video, "unito")
|
||||
if target.exists():
|
||||
raise FileExistsError(target)
|
||||
mux(launcher, root, video, audio, target)
|
||||
return target
|
||||
|
||||
suffix = "mia_voce" if args.preset == "audio-convert" else "facefusion"
|
||||
target = output_path(root, video, suffix, "wav" if args.preset == "audio-convert" else "mp4")
|
||||
if target.exists():
|
||||
raise FileExistsError(target)
|
||||
job = root / "output" / f".{video.stem}-{suffix}-{args.job_id}"
|
||||
job.mkdir(mode=0o700)
|
||||
print("Working directory:", job, flush=True)
|
||||
if args.preset == "audio-convert":
|
||||
probe(video, "audio")
|
||||
extracted = job / "audio.wav"
|
||||
run(launcher, "ffmpeg", "-hide_banner", "-loglevel", "error", "-n",
|
||||
"-i", container_path(root, video), "-vn", "-c:a", "pcm_s16le",
|
||||
container_path(root, extracted))
|
||||
run(launcher, "rvc", "cli", container_path(root, extracted), container_path(root, job))
|
||||
instrumental = list((job / "instrumental").glob("*.wav"))
|
||||
if len(instrumental) != 1:
|
||||
raise RuntimeError("Expected exactly one instrumental stem")
|
||||
converted = job / "vocals-mia_voce.wav"
|
||||
probe(converted, "audio")
|
||||
mixed = job / "mix.wav"
|
||||
run(launcher, "ffmpeg", "-hide_banner", "-loglevel", "error", "-n",
|
||||
"-i", container_path(root, instrumental[0]),
|
||||
"-i", container_path(root, converted),
|
||||
"-filter_complex", "[0:a][1:a]amix=inputs=2:duration=longest:normalize=0[a]",
|
||||
"-map", "[a]", "-c:a", "pcm_s16le", container_path(root, mixed))
|
||||
probe(mixed, "audio")
|
||||
os.link(mixed, target)
|
||||
else:
|
||||
original_has_audio = has_stream(video, "audio")
|
||||
sources = [media_file(root, name) for name in SOURCE_NAMES]
|
||||
processed = job / "swapped.mp4"
|
||||
run(launcher, "facefusion", "cli", "headless-run",
|
||||
"--source-paths", *[container_path(root, path) for path in sources],
|
||||
"--target-path", container_path(root, video),
|
||||
"--output-path", container_path(root, processed),
|
||||
"--processors", "face_swapper", "--face-swapper-model", "hyperswap_1a_256",
|
||||
"--face-swapper-pixel-boost", "256x256", "--face-swapper-weight", "0.5",
|
||||
"--face-detector-model", "yolo_face", "--face-detector-size", "640x640",
|
||||
"--face-detector-angles", "0", "90", "180", "270",
|
||||
"--face-detector-score", "0.5", "--face-selector-mode", "one",
|
||||
"--face-selector-order", "large-small", "--face-selector-gender", "female",
|
||||
"--face-selector-race", "white",
|
||||
"--face-mask-types", "occlusion", "region", "area", "box",
|
||||
"--face-occluder-model", "xseg_1",
|
||||
"--face-parser-model", "bisenet_resnet_34", "--face-mask-blur", "0.3",
|
||||
"--output-video-encoder", "libx264", "--output-video-preset", "veryfast",
|
||||
"--output-video-quality", "80", "--output-video-fps", "30",
|
||||
"--execution-providers", "cpu", "--output-audio-encoder", "aac",
|
||||
"--jobs-path", "/work/state", "--temp-path", "/work/state/tmp")
|
||||
probe(processed, "video")
|
||||
if abs(duration(processed) - duration(video)) > 0.5:
|
||||
raise RuntimeError("FaceFusion output duration differs from the input; refusing a partial result")
|
||||
if original_has_audio:
|
||||
# Restore the original soundtrack explicitly. Some completed
|
||||
# FaceFusion jobs have produced video-only MP4 files.
|
||||
mux(launcher, root, processed, video, target)
|
||||
else:
|
||||
run(launcher, "ffmpeg", "-hide_banner", "-loglevel", "error", "-n",
|
||||
"-i", container_path(root, processed), "-map", "0:v:0",
|
||||
"-c:v", "copy", "-an", "-movflags", "+faststart",
|
||||
container_path(root, target))
|
||||
probe(target, "video")
|
||||
if has_stream(target, "audio"):
|
||||
raise RuntimeError("Unexpected audio stream in silent FaceFusion output")
|
||||
return target
|
||||
|
||||
|
||||
def process_complete(args, root, launcher):
|
||||
video = media_file(root, args.video, video=True)
|
||||
if not has_stream(video, "audio"):
|
||||
raise RuntimeError("The video has no audio to convert")
|
||||
common = {"video": video.name, "job_id": args.job_id}
|
||||
audio = process(argparse.Namespace(preset="audio-convert", **common), root, launcher)
|
||||
swapped = process(argparse.Namespace(preset="video-convert", **common), root, launcher)
|
||||
target = output_path(root, video, "completo")
|
||||
if target.exists():
|
||||
raise FileExistsError(target)
|
||||
mux(launcher, root, swapped, audio, target)
|
||||
return target
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(prog="ai-media preset")
|
||||
parser.add_argument("root", type=Path, help=argparse.SUPPRESS)
|
||||
parser.add_argument("launcher", type=Path, help=argparse.SUPPRESS)
|
||||
parser.add_argument("--run", action="store_true", help=argparse.SUPPRESS)
|
||||
parser.add_argument("--job-id", help=argparse.SUPPRESS)
|
||||
sub = parser.add_subparsers(dest="preset", required=True)
|
||||
for name in ("audio-convert", "video-convert", "merge", "split", "split-stems", "convert"):
|
||||
command = sub.add_parser(name)
|
||||
command.add_argument("video", help="MP4 filename inside input/ or HTTP(S) video URL")
|
||||
if name == "merge":
|
||||
command.add_argument("audio", help="unique audio filename in input/ or output/")
|
||||
mix = sub.add_parser("mix", help="mix vocal and instrumental audio into one WAV")
|
||||
mix.add_argument("vocals", help="vocal audio path relative to input/ or output/")
|
||||
mix.add_argument("instrumental", help="instrumental audio path relative to input/ or output/")
|
||||
mix.add_argument("--output", help="WAV filename in output/ (default: <vocals>-mix.wav)")
|
||||
voice = sub.add_parser("voice-convert", help="apply mia_voce directly to an audio file")
|
||||
voice.add_argument("audio", help="audio path relative to input/ or output/")
|
||||
voice.add_argument("--output", help="WAV filename in output/ (default: <audio>-mia_voce.wav)")
|
||||
args = parser.parse_args()
|
||||
root = args.root.resolve(strict=True)
|
||||
launcher = args.launcher.resolve(strict=True)
|
||||
audio_only = args.preset in ("mix", "voice-convert")
|
||||
remote_video = not audio_only and not NAME.fullmatch(args.video)
|
||||
if args.preset == "voice-convert":
|
||||
source = audio_file(root, args.audio)
|
||||
wav_target(root, args.output or f"{source.stem}-mia_voce.wav")
|
||||
preset_inputs = [args.audio]
|
||||
if args.output:
|
||||
preset_inputs += ["--output", args.output]
|
||||
elif args.preset == "mix":
|
||||
audio_file(root, args.vocals)
|
||||
audio_file(root, args.instrumental)
|
||||
mix_target(root, args)
|
||||
preset_inputs = [args.vocals, args.instrumental]
|
||||
if args.output:
|
||||
preset_inputs += ["--output", args.output]
|
||||
elif remote_video:
|
||||
video_url(args.video)
|
||||
if shutil.which("yt-dlp") is None:
|
||||
raise RuntimeError("yt-dlp is required for URL downloads")
|
||||
else:
|
||||
media_file(root, args.video, video=True)
|
||||
if not audio_only:
|
||||
preset_inputs = [args.video] + ([args.audio] if args.preset == "merge" else [])
|
||||
if args.preset == "merge":
|
||||
audio_file(root, args.audio)
|
||||
if args.preset in ("video-convert", "convert"):
|
||||
for name in SOURCE_NAMES:
|
||||
media_file(root, name)
|
||||
if args.run:
|
||||
if remote_video:
|
||||
args.video = download_video(root, args.video, args.job_id).name
|
||||
if args.preset == "voice-convert":
|
||||
result = process_voice(args, root, launcher)
|
||||
elif args.preset == "mix":
|
||||
result = process_mix(args, root, launcher)
|
||||
else:
|
||||
result = (process_complete(args, root, launcher)
|
||||
if args.preset == "convert" else process(args, root, launcher))
|
||||
print("Completed:", result, flush=True)
|
||||
return
|
||||
unit = "ai-media-preset-" + datetime.now().strftime("%Y%m%d-%H%M%S") + "-" + uuid.uuid4().hex[:8]
|
||||
subprocess.run(["systemd-run", "--user", "--collect", f"--unit={unit}",
|
||||
"--property=Type=exec", "--property=Restart=no",
|
||||
"/usr/bin/python3", str(Path(__file__).resolve()), str(root), str(launcher),
|
||||
"--run", "--job-id", unit, args.preset,
|
||||
*preset_inputs], check=True)
|
||||
print("Job:", unit)
|
||||
print("Logs: journalctl --user -fu", unit)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
main()
|
||||
except (ValueError, FileNotFoundError, FileExistsError, subprocess.CalledProcessError) as error:
|
||||
raise SystemExit(str(error)) from error
|
||||
@@ -1,94 +0,0 @@
|
||||
"""Offline RVC worker for the voice preset (runs inside the RVC container)."""
|
||||
|
||||
import argparse
|
||||
import os
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("input_wav", type=Path)
|
||||
parser.add_argument("job_dir", type=Path)
|
||||
mode = parser.add_mutually_exclusive_group()
|
||||
mode.add_argument("--separate-only", action="store_true")
|
||||
mode.add_argument("--convert-only", action="store_true")
|
||||
args = parser.parse_args()
|
||||
source = args.input_wav.resolve(strict=True)
|
||||
job = args.job_dir.resolve(strict=True)
|
||||
output = Path("/work/output").resolve(strict=True)
|
||||
if not source.is_relative_to(output) or not job.is_relative_to(output):
|
||||
raise ValueError("RVC preset paths must be inside /work/output")
|
||||
if source.parent != job or not source.is_file():
|
||||
raise ValueError("Expected the extracted WAV inside the job directory")
|
||||
|
||||
weights = Path("/work/state/weights/mia_voce.pth")
|
||||
index = Path("/work/state/mia_voce/added_IVF256_Flat_nprobe_1_mia_voce_v2.index")
|
||||
if not args.separate_only and not weights.is_file():
|
||||
raise FileNotFoundError(weights)
|
||||
if not args.separate_only and not index.is_file():
|
||||
raise FileNotFoundError(index)
|
||||
os.environ.update(
|
||||
weight_root="/work/state/weights",
|
||||
outside_index_root="/work/models/indices",
|
||||
index_root="/work/state",
|
||||
weight_pymss_root="/opt/app/assets/pymss_weights",
|
||||
rmvpe_root="/opt/app/assets/rmvpe",
|
||||
OMP_NUM_THREADS="4",
|
||||
MKL_NUM_THREADS="4",
|
||||
)
|
||||
|
||||
# The pinned WebUI imports its own argparse configuration at module load.
|
||||
sys.argv = sys.argv[:1]
|
||||
vocal_source = source
|
||||
if not args.convert_only:
|
||||
from tools.pymss_webui import pymss_separate
|
||||
|
||||
vocals_dir = job / "vocals"
|
||||
instrumental_dir = job / "instrumental"
|
||||
vocals_dir.mkdir()
|
||||
instrumental_dir.mkdir()
|
||||
failures = []
|
||||
|
||||
def on_event(event):
|
||||
if event.get("event") in ("fatal", "cancelled", "busy"):
|
||||
failures.append(event.get("message", str(event)))
|
||||
|
||||
for progress in pymss_separate(
|
||||
"vocals-bs-roformer-368", str(source), str(vocals_dir), None,
|
||||
str(instrumental_dir), "wav", event_callback=on_event,
|
||||
):
|
||||
print(progress, flush=True)
|
||||
if failures:
|
||||
raise RuntimeError("RVC separation failed: " + "; ".join(failures))
|
||||
vocals = list(vocals_dir.glob("*.wav"))
|
||||
instrumental = list(instrumental_dir.glob("*.wav"))
|
||||
if len(vocals) != 1 or len(instrumental) != 1:
|
||||
raise RuntimeError("RVC did not produce exactly one vocal and instrumental stem")
|
||||
|
||||
if args.separate_only:
|
||||
print("Vocal and instrumental stems ready (no voice conversion)", flush=True)
|
||||
return
|
||||
|
||||
vocal_source = vocals[0]
|
||||
|
||||
from configs.config import Config
|
||||
from infer.vc.modules import VC
|
||||
import soundfile as sf
|
||||
|
||||
voice = VC(Config())
|
||||
voice.get_vc(weights.name)
|
||||
status, result = voice.vc_single(
|
||||
0, str(vocal_source), 0, "rmvpe", str(index), 0.75, 0, 1, 0.33,
|
||||
)
|
||||
if result is None or result[0] is None or result[1] is None:
|
||||
raise RuntimeError("RVC voice conversion failed: " + str(status))
|
||||
converted = job / "vocals-mia_voce.wav"
|
||||
sf.write(converted, result[1], result[0])
|
||||
if converted.stat().st_size == 0:
|
||||
raise RuntimeError("RVC produced an empty converted voice")
|
||||
print("RVC converted voice ready", flush=True)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1,63 +0,0 @@
|
||||
--index-url https://pypi.org/simple
|
||||
aiofiles==24.1.0
|
||||
annotated-doc==0.0.5
|
||||
annotated-types==0.8.0
|
||||
anyio==4.15.1
|
||||
brotli==1.2.0
|
||||
certifi==2026.7.22
|
||||
click==8.5.0
|
||||
fastapi==0.143.0
|
||||
ffmpy==1.0.0
|
||||
filelock==4.1.1
|
||||
flatbuffers==25.12.19
|
||||
fsspec==2026.9.0
|
||||
gradio==5.50.0
|
||||
gradio_client==1.14.0
|
||||
gradio_rangeslider==0.0.8
|
||||
groovy==0.1.2
|
||||
h11==0.16.0
|
||||
hf-xet==1.7.0
|
||||
httpcore==1.0.9
|
||||
httpx==0.28.1
|
||||
huggingface_hub==1.33.0
|
||||
idna==3.20
|
||||
Jinja2==3.1.6
|
||||
markdown-it-py==4.2.0
|
||||
MarkupSafe==3.0.4
|
||||
mdurl==0.1.2
|
||||
ml_dtypes==0.6.0
|
||||
numpy==2.4.6
|
||||
onnx==1.23.1
|
||||
onnxruntime==1.30.0
|
||||
opencv-python-headless==5.0.0.93
|
||||
opentelemetry-api==1.45.1
|
||||
orjson==3.13.0
|
||||
packaging==26.3
|
||||
pandas==2.3.3
|
||||
pillow==11.3.0
|
||||
pip==25.0.1
|
||||
protobuf==7.36.2
|
||||
pydantic==2.12.3
|
||||
pydantic_core==2.41.4
|
||||
pydub==0.25.1
|
||||
Pygments==2.21.0
|
||||
python-dateutil==2.9.0.post0
|
||||
python-multipart==0.0.32
|
||||
pytz==2026.5
|
||||
PyYAML==6.0.3
|
||||
rich==15.0.0
|
||||
ruff==0.17.0
|
||||
safehttpx==0.1.7
|
||||
scipy==1.18.1
|
||||
semantic-version==2.10.0
|
||||
shellingham==1.5.4
|
||||
six==1.17.0
|
||||
starlette==0.52.1
|
||||
tomlkit==0.13.3
|
||||
tqdm==4.70.1
|
||||
typer==0.27.3
|
||||
typing-inspection==0.4.4
|
||||
typing_extensions==4.16.0
|
||||
tzdata==2026.5
|
||||
uvicorn==0.54.0
|
||||
websockets==15.0.1
|
||||
@@ -1,120 +0,0 @@
|
||||
--index-url https://pypi.org/simple
|
||||
--extra-index-url https://download.pytorch.org/whl/cpu
|
||||
absl-py==2.5.1
|
||||
aiohappyeyeballs==2.7.1
|
||||
aiohttp==3.14.5
|
||||
aiosignal==1.4.0
|
||||
altair==4.2.2
|
||||
anyio==3.7.1
|
||||
attrs==26.1.0
|
||||
audioread==3.1.0
|
||||
av==15.1.0
|
||||
certifi==2026.7.22
|
||||
cffi==2.1.1
|
||||
charset-normalizer==3.5.2
|
||||
click==8.5.0
|
||||
cloudpickle==3.1.2
|
||||
coloredlogs==15.0.1
|
||||
contourpy==1.3.3
|
||||
cycler==0.12.1
|
||||
decorator==5.3.1
|
||||
einops==0.8.2
|
||||
entrypoints==0.4
|
||||
faiss-cpu==1.15.1
|
||||
fastapi==0.99.1
|
||||
ffmpeg-python==0.2.0
|
||||
ffmpy==1.0.0
|
||||
filelock==4.1.1
|
||||
flatbuffers==25.12.19
|
||||
fonttools==4.66.1
|
||||
FreeSimpleGUI==5.1.1
|
||||
frozenlist==1.8.0
|
||||
fsspec==2026.9.0
|
||||
future==1.0.0
|
||||
gradio==3.14.0
|
||||
grpcio==1.84.0
|
||||
h11==0.14.0
|
||||
hf-xet==1.7.0
|
||||
httpcore==0.16.3
|
||||
httpx==0.23.3
|
||||
huggingface_hub==0.36.2
|
||||
humanfriendly==10.0
|
||||
hyper-connections==0.4.2
|
||||
idna==3.20
|
||||
Jinja2==3.1.6
|
||||
joblib==1.6.0
|
||||
jsonschema==4.26.0
|
||||
jsonschema-specifications==2025.9.1
|
||||
kiwisolver==1.5.1
|
||||
lazy-loader==0.6
|
||||
librosa==0.10.2.post1
|
||||
linkify-it-py==2.2.0
|
||||
llvmlite==0.50.0
|
||||
local-attention==1.11.2
|
||||
Markdown==3.11
|
||||
markdown-it-py==2.2.0
|
||||
MarkupSafe==3.0.4
|
||||
matplotlib==3.11.2
|
||||
mdit-py-plugins==0.3.5
|
||||
mdurl==0.1.2
|
||||
mpmath==1.3.0
|
||||
msgpack==1.2.3
|
||||
multidict==7.1.0
|
||||
narwhals==2.27.1
|
||||
networkx==3.7
|
||||
numba==0.68.0
|
||||
numpy==1.26.4
|
||||
onnxruntime==1.31.0
|
||||
opencv-python-headless==4.11.0.86
|
||||
orjson==3.13.0
|
||||
packaging==26.3
|
||||
pandas==3.0.6
|
||||
pillow==12.3.0
|
||||
pip==25.0.1
|
||||
platformdirs==4.13.0
|
||||
pooch==1.9.0
|
||||
praat-parselmouth==0.4.7
|
||||
propcache==0.5.4
|
||||
protobuf==7.36.2
|
||||
pycparser==3.11
|
||||
pycryptodome==3.24.1
|
||||
pydantic==1.10.26
|
||||
pydub==0.25.1
|
||||
pyparsing==3.0.9
|
||||
python-dateutil==2.9.0.post0
|
||||
python-multipart==0.0.32
|
||||
PyYAML==6.0.3
|
||||
referencing==0.37.0
|
||||
regex==2026.9.29
|
||||
requests==2.34.2
|
||||
rfc3986==1.5.0
|
||||
rpds-py==2026.9.1
|
||||
safetensors==0.8.0
|
||||
scikit-learn==1.9.1
|
||||
scipy==1.17.1
|
||||
setuptools==80.10.2
|
||||
six==1.17.0
|
||||
sniffio==1.3.1
|
||||
sounddevice==0.5.6
|
||||
soundfile==0.14.0
|
||||
soxr==1.1.0
|
||||
starlette==0.27.0
|
||||
sympy==1.14.0
|
||||
tensorboard==2.21.0
|
||||
tensorboard-data-server==0.7.2
|
||||
threadpoolctl==3.7.0
|
||||
tokenizers==0.21.4
|
||||
toolz==1.2.0
|
||||
torch==2.4.1+cpu
|
||||
torchaudio==2.4.1+cpu
|
||||
torchfcpe==0.0.4
|
||||
torchvision==0.19.1+cpu
|
||||
tqdm==4.70.1
|
||||
transformers==4.49.0
|
||||
typing_extensions==4.16.0
|
||||
urllib3==2.8.0
|
||||
uvicorn==0.22.0
|
||||
websockets==10.4
|
||||
Werkzeug==3.1.9
|
||||
wheel==0.48.0
|
||||
yarl==1.25.1
|
||||
@@ -1,111 +0,0 @@
|
||||
import os
|
||||
import pathlib
|
||||
import signal
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
import urllib.request
|
||||
|
||||
app = os.environ["APP"]
|
||||
os.chdir("/opt/app")
|
||||
if sys.argv[1:] == ["verify"]:
|
||||
os.execv(sys.executable, [sys.executable, "/opt/verify.py"])
|
||||
if sys.argv[1:2] == ["ffmpeg"]:
|
||||
os.execv("/usr/bin/ffmpeg", ["ffmpeg", *sys.argv[2:]])
|
||||
if sys.argv[1:2] == ["cli"]:
|
||||
if app != "facefusion":
|
||||
raise SystemExit("CLI is available for FaceFusion only")
|
||||
os.execv(sys.executable, [sys.executable, "facefusion.py", *sys.argv[2:]])
|
||||
if app == "facefusion":
|
||||
command = [
|
||||
sys.executable, "facefusion.py", "run",
|
||||
"--execution-providers", "cpu", "--processors", "face_swapper",
|
||||
"--temp-path", "/work/state/tmp", "--jobs-path", "/work/state",
|
||||
"--output-path", "/work/output",
|
||||
]
|
||||
port = 7860
|
||||
else:
|
||||
pathlib.Path("/tmp/rvc-temp").mkdir(exist_ok=True)
|
||||
weights = pathlib.Path("/work/state/weights")
|
||||
weights.mkdir(exist_ok=True)
|
||||
for source in pathlib.Path("/work/models/weights").glob("*.pth"):
|
||||
target = weights / source.name
|
||||
if not target.exists() and not target.is_symlink():
|
||||
target.symlink_to(source)
|
||||
fixture = pathlib.Path("/opt/training-fixture/mute")
|
||||
for source in fixture.rglob("*"):
|
||||
target = pathlib.Path("/work/state/mute") / source.relative_to(fixture)
|
||||
if source.is_dir():
|
||||
target.mkdir(parents=True, exist_ok=True)
|
||||
elif not target.exists():
|
||||
shutil.copyfile(source, target)
|
||||
os.environ.update(
|
||||
weight_root="/work/state/weights",
|
||||
outside_index_root="/work/models/indices",
|
||||
index_root="/work/state",
|
||||
weight_pymss_root="/opt/app/assets/pymss_weights",
|
||||
)
|
||||
command = [sys.executable, "webui.py", "--noautoopen", "--port", "7865"]
|
||||
port = 7865
|
||||
server = subprocess.Popen(command)
|
||||
browser = None
|
||||
profile = pathlib.Path("/tmp/browser")
|
||||
profile.mkdir(exist_ok=True)
|
||||
(profile / "user.js").write_text('''
|
||||
user_pref("browser.download.folderList", 2);
|
||||
user_pref("browser.download.dir", "/work/output");
|
||||
user_pref("browser.download.useDownloadDir", true);
|
||||
user_pref("widget.use-xdg-desktop-portal.file-picker", 0);
|
||||
user_pref("browser.shell.checkDefaultBrowser", false);
|
||||
user_pref("browser.aboutwelcome.enabled", false);
|
||||
user_pref("datareporting.policy.dataSubmissionEnabled", false);
|
||||
user_pref("toolkit.telemetry.enabled", false);
|
||||
''')
|
||||
bookmarks = pathlib.Path.home() / ".config/gtk-3.0/bookmarks"
|
||||
bookmarks.parent.mkdir(parents=True, exist_ok=True)
|
||||
bookmarks.write_text("file:///work/input Input\nfile:///work/output Output\nfile:///work/models Models\n")
|
||||
|
||||
|
||||
def stop(*_):
|
||||
if browser is not None and browser.poll() is None:
|
||||
browser.terminate()
|
||||
if server.poll() is None:
|
||||
server.terminate()
|
||||
|
||||
|
||||
signal.signal(signal.SIGTERM, stop)
|
||||
signal.signal(signal.SIGINT, stop)
|
||||
try:
|
||||
url = f"http://127.0.0.1:{port}"
|
||||
for _ in range(180):
|
||||
if server.poll() is not None:
|
||||
raise RuntimeError(f"{app} exited: {server.returncode}")
|
||||
try:
|
||||
with urllib.request.urlopen(url, timeout=1) as response:
|
||||
if response.status == 200:
|
||||
break
|
||||
except OSError:
|
||||
time.sleep(1)
|
||||
else:
|
||||
raise RuntimeError("Offline WebUI did not become ready")
|
||||
print(f"{app}: offline WebUI ready", flush=True)
|
||||
if sys.argv[1:] == ["smoke"]:
|
||||
subprocess.run([
|
||||
"firefox-esr", "--headless", "--no-remote", "--profile", "/tmp/browser",
|
||||
"--screenshot", "/tmp/offline-ui.png", url,
|
||||
], check=True, timeout=90)
|
||||
assert pathlib.Path("/tmp/offline-ui.png").stat().st_size > 1000
|
||||
raise SystemExit(0)
|
||||
browser = subprocess.Popen([
|
||||
"firefox-esr", "--no-remote", "--profile", "/tmp/browser", url,
|
||||
])
|
||||
while browser.poll() is None:
|
||||
if server.poll() is not None:
|
||||
raise RuntimeError("WebUI terminated unexpectedly")
|
||||
time.sleep(1)
|
||||
finally:
|
||||
stop()
|
||||
if browser is not None:
|
||||
browser.wait(timeout=15)
|
||||
server.wait(timeout=15)
|
||||
@@ -1,139 +0,0 @@
|
||||
import os
|
||||
import gc
|
||||
import pathlib
|
||||
import socket
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
interfaces = {p.name for p in pathlib.Path("/sys/class/net").iterdir()}
|
||||
assert interfaces == {"lo"}, interfaces
|
||||
for family, address in (
|
||||
(socket.AF_INET, ("1.1.1.1", 443)),
|
||||
(socket.AF_INET6, ("2606:4700:4700::1111", 443, 0, 0)),
|
||||
):
|
||||
with socket.socket(family, socket.SOCK_STREAM) as connection:
|
||||
connection.settimeout(2)
|
||||
try:
|
||||
connection.connect(address)
|
||||
except OSError:
|
||||
pass
|
||||
else:
|
||||
raise RuntimeError("External networking is available")
|
||||
subprocess.run(["sha256sum", "--quiet", "--check", "/opt/model-checksums.sha256"], check=True)
|
||||
if os.environ["APP"] == "facefusion":
|
||||
sys.path.insert(0, "/opt/app")
|
||||
from facefusion import state_manager
|
||||
from facefusion.args import apply_args
|
||||
from facefusion.program import create_program
|
||||
from facefusion.core import common_pre_check, processors_pre_check
|
||||
args = vars(create_program().parse_args([
|
||||
"run", "--execution-providers", "cpu", "--processors", "face_swapper",
|
||||
]))
|
||||
apply_args(args, state_manager.init_item)
|
||||
assert common_pre_check() and processors_pre_check()
|
||||
import numpy as np
|
||||
import onnxruntime as ort
|
||||
options = ort.SessionOptions()
|
||||
options.intra_op_num_threads = 4
|
||||
options.inter_op_num_threads = 1
|
||||
model = ort.InferenceSession(
|
||||
"/opt/app/.assets/models/hyperswap_1a_256.onnx",
|
||||
sess_options=options, providers=["CPUExecutionProvider"],
|
||||
)
|
||||
feeds = {}
|
||||
for argument in model.get_inputs():
|
||||
assert argument.type == "tensor(float)"
|
||||
shape = [size if isinstance(size, int) and size > 0 else 1 for size in argument.shape]
|
||||
feeds[argument.name] = np.full(shape, 0.01, dtype=np.float32)
|
||||
assert all(np.isfinite(result).all() for result in model.run(None, feeds))
|
||||
else:
|
||||
sys.path.insert(0, "/opt/app")
|
||||
import numpy as np
|
||||
import torch
|
||||
import transformers
|
||||
import onnxruntime
|
||||
assert not torch.cuda.is_available()
|
||||
torch.set_num_threads(4)
|
||||
from infer.hubert import load_hubert_model, extract_hubert_features
|
||||
from infer.rmvpe import RMVPE
|
||||
with torch.inference_mode():
|
||||
hubert = load_hubert_model("cpu", False)
|
||||
features = extract_hubert_features(hubert, torch.zeros(1, 16000), "v2")
|
||||
assert torch.isfinite(features).all()
|
||||
del hubert, features
|
||||
pitch = RMVPE("/opt/app/assets/rmvpe/rmvpe.pt", False, "cpu")
|
||||
result = pitch.infer_from_audio(np.zeros(16000, dtype=np.float32))
|
||||
assert len(result) > 0 and np.isfinite(result).all()
|
||||
del pitch
|
||||
gc.collect()
|
||||
# Exercise the exact WebUI subprocess entrypoint, not only in-process imports.
|
||||
from scipy.io import wavfile
|
||||
with tempfile.TemporaryDirectory(prefix="rvc-slicing-") as temporary:
|
||||
directory = pathlib.Path(temporary)
|
||||
dataset = directory / "input"
|
||||
experiment = directory / "experiment"
|
||||
dataset.mkdir()
|
||||
experiment.mkdir()
|
||||
samples = np.arange(4 * 40000, dtype=np.float32) / 40000
|
||||
waveform = (0.2 * np.sin(2 * np.pi * 220 * samples)).astype(np.float32)
|
||||
wavfile.write(dataset / "synthetic.wav", 40000, waveform)
|
||||
subprocess.run([
|
||||
sys.executable, "train/preprocess.py", str(dataset), "40000", "1",
|
||||
str(experiment), "False", "3.7",
|
||||
], check=True, timeout=120)
|
||||
assert list((experiment / "0_gt_wavs").glob("*.wav"))
|
||||
assert list((experiment / "1_16k_wavs").glob("*.wav"))
|
||||
print("rvc: synthetic data slicing subprocess verified", flush=True)
|
||||
# Check the v2/40k training baseline and writable inference-model export.
|
||||
from train.utils import get_hparams_from_file
|
||||
from train.process_ckpt import savee
|
||||
hps = get_hparams_from_file("configs/v1/40k.json")
|
||||
checkpoint = torch.load("assets/pretrained_v2/f0G40k.pth", map_location="cpu")
|
||||
assert checkpoint["model"]
|
||||
pathlib.Path("/work/state/weights").mkdir(exist_ok=True)
|
||||
savee(checkpoint["model"], "40k", 1, "offline-readiness", 0, "v2", hps)
|
||||
exported = pathlib.Path("assets/weights/offline-readiness.pth")
|
||||
assert exported.is_file()
|
||||
exported.unlink()
|
||||
del checkpoint
|
||||
checkpoint = torch.load("assets/pretrained_v2/f0D40k.pth", map_location="cpu")
|
||||
assert checkpoint["model"]
|
||||
del checkpoint
|
||||
assert pathlib.Path("/opt/training-fixture/mute/0_gt_wavs/mute40k.wav").is_file()
|
||||
print("rvc: v2/40k training assets and model export verified", flush=True)
|
||||
# Exercise the WebUI's real worker and encoder on a synthetic stereo mix.
|
||||
with tempfile.TemporaryDirectory(prefix="rvc-separation-") as temporary:
|
||||
directory = pathlib.Path(temporary)
|
||||
sample_rate = 44100
|
||||
time_axis = np.arange(2 * sample_rate, dtype=np.float32) / sample_rate
|
||||
left = 0.1 * np.sin(2 * np.pi * 220 * time_axis)
|
||||
right = 0.1 * np.sin(2 * np.pi * 330 * time_axis)
|
||||
mix = np.stack((left, right), axis=1).astype(np.float32)
|
||||
wavfile.write(directory / "synthetic.wav", sample_rate, mix)
|
||||
subprocess.run([
|
||||
sys.executable, "-c",
|
||||
"import sys; from pathlib import Path; p=Path(sys.argv[1]); sys.argv=sys.argv[:1]; "
|
||||
"from tools.pymss_webui import pymss_separate, resolve_model, PYMSS_MODEL_CHOICES; "
|
||||
"assert PYMSS_MODEL_CHOICES == [resolve_model('vocals-bs-roformer-368').label]; "
|
||||
"list(pymss_separate('vocals-bs-roformer-368', str(p/'synthetic.wav'), "
|
||||
"str(p/'vocals'), None, str(p/'instrumental'), 'wav'))",
|
||||
str(directory),
|
||||
], check=True, timeout=600, env={
|
||||
**os.environ, "OMP_NUM_THREADS": "4", "MKL_NUM_THREADS": "4",
|
||||
})
|
||||
import soundfile as sf
|
||||
stems = []
|
||||
for name in ("vocals", "instrumental"):
|
||||
files = list((directory / name).glob("*.wav"))
|
||||
assert len(files) == 1, (name, files)
|
||||
data, rate = sf.read(files[0], dtype="float32", always_2d=True)
|
||||
assert rate == sample_rate and data.shape == mix.shape
|
||||
assert np.isfinite(data).all()
|
||||
stems.append(data)
|
||||
assert np.allclose(stems[0] + stems[1], mix, atol=1e-4)
|
||||
print("rvc: offline stereo vocal/instrumental separation verified", flush=True)
|
||||
|
||||
gc.collect()
|
||||
subprocess.run([sys.executable, "/opt/session.py", "smoke"], check=True)
|
||||
print(os.environ["APP"] + ": models verified, offline UI ready, IPv4/IPv6 egress blocked")
|
||||
@@ -1,4 +0,0 @@
|
||||
---
|
||||
- name: Reload systemd units
|
||||
ansible.builtin.systemd_service:
|
||||
daemon_reload: true
|
||||
@@ -1,343 +0,0 @@
|
||||
---
|
||||
- name: Configure on-demand external ai-media storage
|
||||
become: true
|
||||
when: desktop_ai_media_external_storage_enabled | bool
|
||||
tags: [ai_media, ai_media_storage]
|
||||
block:
|
||||
- name: Validate external ai-media storage paths
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- desktop_ai_media_external_mountpoint is match('^/run/media/[^/]+/[^/]+$')
|
||||
- >-
|
||||
not desktop_ai_media_external_luks_uuid or
|
||||
desktop_ai_media_external_luks_uuid is match('^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$')
|
||||
- desktop_ai_media_external_source.startswith(desktop_ai_media_external_mountpoint + '/')
|
||||
- desktop_ai_media_external_source != desktop_ai_media_external_mountpoint
|
||||
- desktop_ai_media_root.startswith(user_home + '/')
|
||||
- desktop_ai_media_root != user_home
|
||||
|
||||
- name: Derive external source mount unit name
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- systemd-escape
|
||||
- -p
|
||||
- --suffix=mount
|
||||
- "{{ desktop_ai_media_external_mountpoint }}"
|
||||
register: desktop_ai_media_external_source_mount_unit
|
||||
changed_when: false
|
||||
check_mode: false
|
||||
|
||||
- name: Derive ai-media bind mount unit name
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- systemd-escape
|
||||
- -p
|
||||
- --suffix=mount
|
||||
- "{{ desktop_ai_media_root }}"
|
||||
register: desktop_ai_media_bind_mount_unit
|
||||
changed_when: false
|
||||
check_mode: false
|
||||
|
||||
- name: Derive ai-media bind automount unit name
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- systemd-escape
|
||||
- -p
|
||||
- --suffix=automount
|
||||
- "{{ desktop_ai_media_root }}"
|
||||
register: desktop_ai_media_bind_automount_unit
|
||||
changed_when: false
|
||||
check_mode: false
|
||||
|
||||
- name: Create ai-media mount destination in the user home
|
||||
ansible.builtin.file:
|
||||
path: "{{ desktop_ai_media_root }}"
|
||||
state: directory
|
||||
owner: "{{ username }}"
|
||||
group: "{{ username }}"
|
||||
mode: "0700"
|
||||
|
||||
- name: Install ai-media bind mount unit
|
||||
ansible.builtin.template:
|
||||
src: ai-media-bind.mount.j2
|
||||
dest: "/etc/systemd/system/{{ desktop_ai_media_bind_mount_unit.stdout }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
notify: Reload systemd units
|
||||
|
||||
- name: Install ai-media bind automount unit
|
||||
ansible.builtin.template:
|
||||
src: ai-media-bind.automount.j2
|
||||
dest: "/etc/systemd/system/{{ desktop_ai_media_bind_automount_unit.stdout }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
notify: Reload systemd units
|
||||
|
||||
- name: Install ai-media bind automount failure restarter
|
||||
ansible.builtin.template:
|
||||
src: ai-media-bind-restarter.service.j2
|
||||
dest: /etc/systemd/system/ai-media-bind-restarter.service
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
notify: Reload systemd units
|
||||
|
||||
- name: Flush systemd unit changes
|
||||
ansible.builtin.meta: flush_handlers
|
||||
|
||||
- name: Stop a stale ai-media bind mount when the Backup source is absent
|
||||
ansible.builtin.systemd_service:
|
||||
name: "{{ desktop_ai_media_bind_mount_unit.stdout }}"
|
||||
state: stopped
|
||||
when:
|
||||
- desktop_ai_media_root in (ansible_facts['mounts'] | default([]) | selectattr('fstype', 'ne', 'autofs') | map(attribute='mount') | list)
|
||||
- desktop_ai_media_external_mountpoint not in (ansible_facts['mounts'] | default([]) | map(attribute='mount') | list)
|
||||
|
||||
- name: Enable and start ai-media bind automount
|
||||
ansible.builtin.systemd_service:
|
||||
name: "{{ desktop_ai_media_bind_automount_unit.stdout }}"
|
||||
enabled: true
|
||||
state: started
|
||||
|
||||
- name: Configure isolated desktop media tools as the desktop user
|
||||
become: false
|
||||
block:
|
||||
- name: Determine whether the ai-media storage source is currently available
|
||||
ansible.builtin.set_fact:
|
||||
desktop_ai_media_external_available: >-
|
||||
{{ (not (desktop_ai_media_external_storage_enabled | bool)) or
|
||||
(desktop_ai_media_external_mountpoint in
|
||||
(ansible_facts['mounts'] | default([]) | map(attribute='mount') | list)) }}
|
||||
|
||||
- name: Load pinned public model manifest
|
||||
ansible.builtin.include_vars: models.yml
|
||||
|
||||
- name: Identify unprivileged desktop user
|
||||
ansible.builtin.command:
|
||||
argv: [id, -un]
|
||||
register: desktop_ai_media_user
|
||||
changed_when: false
|
||||
check_mode: false
|
||||
|
||||
- name: Verify local Fedora desktop scope
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- "'platform_fedora' in group_names"
|
||||
- "'desktop_gnome' in group_names"
|
||||
- ansible_connection == 'local'
|
||||
- desktop_ai_media_user.stdout == username
|
||||
- ansible_facts.architecture == 'x86_64'
|
||||
- desktop_ai_media_root.startswith(user_home + '/')
|
||||
- desktop_ai_media_root != user_home
|
||||
- desktop_ai_media_build_root != desktop_ai_media_root
|
||||
- desktop_ai_media_facefusion_revision is match('^[0-9a-f]{40}$')
|
||||
- desktop_ai_media_rvc_revision is match('^[0-9a-f]{40}$')
|
||||
- "'@sha256:' in desktop_ai_media_base_image"
|
||||
- desktop_ai_media_debian_snapshot is match('^[0-9]{8}T[0-9]{6}Z$')
|
||||
- desktop_ai_media_public_models | length > 0
|
||||
- >-
|
||||
desktop_ai_media_apps | difference(
|
||||
desktop_ai_media_public_models | map(attribute='app') | list) | length == 0
|
||||
|
||||
- name: Verify existing rootless Podman runtime
|
||||
ansible.builtin.command:
|
||||
argv: [podman, --remote=false, info, --format, "{{ '{{.Host.Security.Rootless}}' }}"]
|
||||
register: desktop_ai_media_podman
|
||||
changed_when: false
|
||||
check_mode: false
|
||||
|
||||
- name: Require rootless containers
|
||||
ansible.builtin.assert:
|
||||
that: desktop_ai_media_podman.stdout == 'true'
|
||||
|
||||
- name: Reject remote or synchronized media storage before provisioning
|
||||
ansible.builtin.command:
|
||||
argv: [python3, "-", "{{ desktop_ai_media_root }}"]
|
||||
stdin: "{{ lookup('ansible.builtin.file', role_path + '/files/check_storage.py') }}"
|
||||
changed_when: false
|
||||
check_mode: false
|
||||
when: desktop_ai_media_external_available | bool
|
||||
|
||||
- name: Create the data-free local build context
|
||||
ansible.builtin.file:
|
||||
path: "{{ desktop_ai_media_build_root }}"
|
||||
state: directory
|
||||
mode: "0700"
|
||||
|
||||
- name: Create private application and media directories on mounted media storage
|
||||
ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
mode: "0700"
|
||||
loop:
|
||||
- "{{ desktop_ai_media_root }}"
|
||||
- "{{ desktop_ai_media_root }}/input"
|
||||
- "{{ desktop_ai_media_root }}/input/voice"
|
||||
- "{{ desktop_ai_media_root }}/output"
|
||||
- "{{ desktop_ai_media_root }}/models"
|
||||
- "{{ desktop_ai_media_root }}/models/weights"
|
||||
- "{{ desktop_ai_media_root }}/models/indices"
|
||||
- "{{ desktop_ai_media_root }}/state"
|
||||
- "{{ desktop_ai_media_root }}/state/facefusion"
|
||||
- "{{ desktop_ai_media_root }}/state/rvc"
|
||||
when: desktop_ai_media_external_available | bool
|
||||
|
||||
- name: Ensure user launcher directories exist without changing existing permissions
|
||||
ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
loop:
|
||||
- "{{ user_home }}/.local/bin"
|
||||
- "{{ user_home }}/.local/share/applications"
|
||||
|
||||
- name: Install runtime and model preparation code into the data-free build context
|
||||
ansible.builtin.copy:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ desktop_ai_media_build_root }}/{{ item }}"
|
||||
mode: "0644"
|
||||
loop: [session.py, prepare.py, verify.py, check_storage.py]
|
||||
register: desktop_ai_media_support
|
||||
|
||||
- name: Install host-side offline preset workers without rebuilding images
|
||||
tags: [ai_media_presets]
|
||||
ansible.builtin.copy:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ desktop_ai_media_build_root }}/{{ item }}"
|
||||
mode: "0644"
|
||||
loop: [preset.py, preset_rvc.py]
|
||||
|
||||
- name: Create public model cache directories
|
||||
ansible.builtin.file:
|
||||
path: "{{ desktop_ai_media_build_root }}/models/{{ item.app }}/{{ item.path | dirname }}"
|
||||
state: directory
|
||||
mode: "0700"
|
||||
loop: "{{ desktop_ai_media_public_models }}"
|
||||
loop_control:
|
||||
label: "{{ item.app }}/{{ item.path }}"
|
||||
|
||||
- name: Cache public models using pinned SHA256 checksums without personal data
|
||||
ansible.builtin.get_url:
|
||||
url: "{{ item.url }}"
|
||||
dest: "{{ desktop_ai_media_build_root }}/models/{{ item.app }}/{{ item.path }}"
|
||||
checksum: "sha256:{{ item.sha256 }}"
|
||||
mode: "0644"
|
||||
timeout: 60
|
||||
use_netrc: false
|
||||
use_proxy: false
|
||||
loop: "{{ desktop_ai_media_public_models }}"
|
||||
loop_control:
|
||||
label: "{{ item.app }}/{{ item.path }}"
|
||||
register: desktop_ai_media_model_cache
|
||||
|
||||
- name: Install complete Python dependency locks
|
||||
ansible.builtin.copy:
|
||||
src: "requirements-{{ item }}.lock"
|
||||
dest: "{{ desktop_ai_media_build_root }}/requirements-{{ item }}.lock"
|
||||
mode: "0644"
|
||||
loop: "{{ desktop_ai_media_apps }}"
|
||||
register: desktop_ai_media_locks
|
||||
|
||||
- name: Restrict the build context to code and checksum-pinned public models
|
||||
ansible.builtin.template:
|
||||
src: containerignore.j2
|
||||
dest: "{{ desktop_ai_media_build_root }}/.containerignore"
|
||||
mode: "0644"
|
||||
register: desktop_ai_media_ignore
|
||||
|
||||
- name: Render separate pinned application builds
|
||||
ansible.builtin.template:
|
||||
src: Containerfile.j2
|
||||
dest: "{{ desktop_ai_media_build_root }}/Containerfile.{{ item }}"
|
||||
mode: "0644"
|
||||
loop: "{{ desktop_ai_media_apps }}"
|
||||
register: desktop_ai_media_containerfiles
|
||||
|
||||
- name: Fingerprint the complete application build specification
|
||||
ansible.builtin.set_fact:
|
||||
desktop_ai_media_build_keys: >-
|
||||
{{ desktop_ai_media_build_keys | default({}) | combine({
|
||||
item: (
|
||||
lookup('ansible.builtin.template', role_path + '/templates/Containerfile.j2')
|
||||
+ lookup('ansible.builtin.file', role_path + '/files/prepare.py')
|
||||
+ lookup('ansible.builtin.file', role_path + '/files/session.py')
|
||||
+ lookup('ansible.builtin.file', role_path + '/files/verify.py')
|
||||
+ lookup('ansible.builtin.file', role_path + '/files/requirements-' + item + '.lock')
|
||||
+ lookup('ansible.builtin.file', role_path + '/templates/containerignore.j2')
|
||||
) | hash('sha256')
|
||||
}) }}
|
||||
loop: "{{ desktop_ai_media_apps }}"
|
||||
|
||||
- name: Inspect installed media images
|
||||
ansible.builtin.command:
|
||||
argv: [podman, --remote=false, image, exists, "localhost/ai-media-{{ item }}:managed"]
|
||||
loop: "{{ desktop_ai_media_apps }}"
|
||||
register: desktop_ai_media_images
|
||||
failed_when: desktop_ai_media_images.rc not in [0, 1]
|
||||
changed_when: false
|
||||
check_mode: false
|
||||
|
||||
- name: Inspect committed image build fingerprints
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- podman
|
||||
- --remote=false
|
||||
- image
|
||||
- inspect
|
||||
- --format
|
||||
- "{{ '{{ index .Labels \"io.fscotto.ai-media.build-key\" }}' }}"
|
||||
- "localhost/ai-media-{{ item.item }}:managed"
|
||||
loop: "{{ desktop_ai_media_images.results }}"
|
||||
loop_control:
|
||||
label: "{{ item.item }}"
|
||||
when: item.rc == 0
|
||||
register: desktop_ai_media_image_keys
|
||||
changed_when: false
|
||||
check_mode: false
|
||||
|
||||
- name: Build media images without mounting personal data
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- podman
|
||||
- --remote=false
|
||||
- build
|
||||
- --http-proxy=false
|
||||
- --pull=missing
|
||||
- --label
|
||||
- "io.fscotto.ai-media.build-key={{ desktop_ai_media_build_keys[item.item] }}"
|
||||
- --tag
|
||||
- "localhost/ai-media-{{ item.item }}:managed"
|
||||
- --file
|
||||
- "{{ desktop_ai_media_build_root }}/Containerfile.{{ item.item }}"
|
||||
- "{{ desktop_ai_media_build_root }}"
|
||||
loop: "{{ desktop_ai_media_images.results }}"
|
||||
loop_control:
|
||||
label: "{{ item.item }}"
|
||||
when: >-
|
||||
item.rc != 0 or
|
||||
desktop_ai_media_image_keys.results[desktop_ai_media_apps.index(item.item)].stdout | default('') !=
|
||||
desktop_ai_media_build_keys[item.item]
|
||||
changed_when: true
|
||||
timeout: 3600
|
||||
|
||||
- name: Install offline launcher
|
||||
tags: [ai_media_launcher]
|
||||
ansible.builtin.template:
|
||||
src: ai-media.j2
|
||||
dest: "{{ user_home }}/.local/bin/ai-media"
|
||||
mode: "0755"
|
||||
validate: /usr/bin/bash -n %s
|
||||
|
||||
- name: Install manual offline desktop entries
|
||||
ansible.builtin.template:
|
||||
src: application.desktop.j2
|
||||
dest: "{{ user_home }}/.local/share/applications/ai-media-{{ item }}.desktop"
|
||||
mode: "0644"
|
||||
loop: "{{ desktop_ai_media_apps }}"
|
||||
|
||||
- name: Verify offline networking and application readiness without personal files
|
||||
ansible.builtin.command:
|
||||
argv: ["{{ user_home }}/.local/bin/ai-media", verify]
|
||||
changed_when: false
|
||||
when: not ansible_check_mode
|
||||
@@ -1,40 +0,0 @@
|
||||
FROM {{ desktop_ai_media_base_image }}
|
||||
LABEL io.fscotto.ai-media.models="{{ desktop_ai_media_public_models | selectattr('app', 'equalto', item) | list | to_json | hash('sha256') }}"
|
||||
ENV DEBIAN_FRONTEND=noninteractive PIP_DISABLE_PIP_VERSION_CHECK=1
|
||||
RUN sed -i \
|
||||
-e 's|http://deb.debian.org/debian$|https://snapshot.debian.org/archive/debian/{{ desktop_ai_media_debian_snapshot }}/|' \
|
||||
-e 's|http://deb.debian.org/debian-security$|https://snapshot.debian.org/archive/debian-security/{{ desktop_ai_media_debian_snapshot }}/|' \
|
||||
/etc/apt/sources.list.d/debian.sources \
|
||||
&& apt-get -o Acquire::Check-Valid-Until=false update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
ca-certificates curl git ffmpeg firefox-esr fonts-dejavu-core libgl1 libglib2.0-0 libportaudio2 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
COPY requirements-{{ item }}.lock /opt/requirements.lock
|
||||
WORKDIR /opt/app
|
||||
{% if item == 'facefusion' %}
|
||||
RUN git init . && git remote add origin https://github.com/facefusion/facefusion.git \
|
||||
&& git fetch --depth 1 origin {{ desktop_ai_media_facefusion_revision }} \
|
||||
&& git checkout --detach FETCH_HEAD && rm -rf .git \
|
||||
&& pip install --no-cache-dir -r /opt/requirements.lock
|
||||
{% else %}
|
||||
RUN git init . && git remote add origin https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI.git \
|
||||
&& git fetch --depth 1 origin {{ desktop_ai_media_rvc_revision }} \
|
||||
&& git checkout --detach FETCH_HEAD && rm -rf .git \
|
||||
&& pip install --no-cache-dir -r /opt/requirements.lock
|
||||
{% endif %}
|
||||
{% for model in desktop_ai_media_public_models if model.app == item %}
|
||||
COPY models/{{ model.app }}/{{ model.path }} /opt/app/{{ model.path }}
|
||||
{% endfor %}
|
||||
COPY prepare.py /opt/
|
||||
RUN python /opt/prepare.py {{ item }} \
|
||||
&& pip freeze --all > /opt/python-requirements.lock \
|
||||
&& test -s /opt/model-checksums.sha256
|
||||
COPY session.py verify.py /opt/
|
||||
RUN mkdir -p /work/input /work/output /work/state /work/models /home/media
|
||||
ENV GRADIO_ANALYTICS_ENABLED=False HF_HUB_OFFLINE=1 TRANSFORMERS_OFFLINE=1 \
|
||||
HF_HUB_DISABLE_TELEMETRY=1 DO_NOT_TRACK=1 HOME=/home/media \
|
||||
XDG_RUNTIME_DIR=/run/media MOZ_ENABLE_WAYLAND=1 GTK_USE_PORTAL=0 \
|
||||
LIBGL_ALWAYS_SOFTWARE=1 GRADIO_SERVER_NAME=127.0.0.1 GRADIO_SERVER_PORT=7860 \
|
||||
PYTHONPATH=/opt/app PYTHONSAFEPATH=1 PYTHONDONTWRITEBYTECODE=1 NUMBA_CACHE_DIR=/tmp/numba MPLCONFIGDIR=/tmp/matplotlib \
|
||||
GRADIO_TEMP_DIR=/tmp/gradio APP={{ item }}
|
||||
ENTRYPOINT ["python", "/opt/session.py"]
|
||||
@@ -1,7 +0,0 @@
|
||||
[Unit]
|
||||
Description=Recover the ai-media bind automount after an unavailable Backup volume
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStartPre=/usr/bin/sleep 3
|
||||
ExecStart=/usr/bin/bash -c '/usr/bin/systemctl restart "$(/usr/bin/systemd-escape -p --suffix=automount {{ desktop_ai_media_root }})"'
|
||||
@@ -1,11 +0,0 @@
|
||||
[Unit]
|
||||
Description=On-demand ai-media bind mount from the Backup LUKS volume
|
||||
ConditionPathIsDirectory={{ desktop_ai_media_root }}
|
||||
OnFailure=ai-media-bind-restarter.service
|
||||
|
||||
[Automount]
|
||||
Where={{ desktop_ai_media_root }}
|
||||
TimeoutIdleSec=5min
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -1,12 +0,0 @@
|
||||
[Unit]
|
||||
Description=Bind mount ai-media from the Backup LUKS volume
|
||||
RequiresMountsFor={{ desktop_ai_media_external_mountpoint }}
|
||||
After={{ desktop_ai_media_external_source_mount_unit.stdout }}
|
||||
BindsTo={{ desktop_ai_media_external_source_mount_unit.stdout }}
|
||||
ConditionPathIsMountPoint={{ desktop_ai_media_external_mountpoint }}
|
||||
ConditionPathIsDirectory={{ desktop_ai_media_external_source }}
|
||||
|
||||
[Mount]
|
||||
What={{ desktop_ai_media_external_source }}
|
||||
Where={{ desktop_ai_media_root }}
|
||||
Options=bind
|
||||
@@ -1,193 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
root={{ desktop_ai_media_root | quote }}
|
||||
build_root={{ desktop_ai_media_build_root | quote }}
|
||||
{% set manage_luks = desktop_ai_media_external_storage_enabled | default(false) and desktop_ai_media_external_luks_uuid | default('') %}
|
||||
{% if manage_luks %}
|
||||
encrypted={{ ('/dev/disk/by-uuid/' + desktop_ai_media_external_luks_uuid) | quote }}
|
||||
external_mount={{ desktop_ai_media_external_mountpoint | quote }}
|
||||
bind_fsroot={{ (desktop_ai_media_external_source | replace(desktop_ai_media_external_mountpoint, '', 1)) | quote }}
|
||||
|
||||
fail() { echo "$*" >&2; exit 1; }
|
||||
|
||||
read_mapper() {
|
||||
local devices mapping
|
||||
devices=$(lsblk -nrpo NAME,TYPE,MAJ:MIN -- "$encrypted") ||
|
||||
fail "The configured LUKS volume is not available: $encrypted"
|
||||
mapping=$(awk '$2 == "crypt" {print $1, $3}' <<< "$devices")
|
||||
[[ "$mapping" != *$'\n'* ]] || fail "Multiple mappings for $encrypted; refusing to continue"
|
||||
read -r mapper mapper_id <<< "$mapping"
|
||||
}
|
||||
|
||||
mount_info() {
|
||||
# Inspect the kernel mount table without following the automount path.
|
||||
findmnt -krnC --mountpoint "$1" --types noautofs --output MAJ:MIN,FSROOT || [[ $? == 1 ]]
|
||||
}
|
||||
|
||||
volume_mounts() {
|
||||
[[ -n "$mapper_id" ]] || return 0
|
||||
findmnt -krnC --source "$mapper_id" --output TARGET || [[ $? == 1 ]]
|
||||
}
|
||||
|
||||
require_external_bind() {
|
||||
read_mapper
|
||||
[[ -n "$mapper_id" && "$(mount_info "$root")" == "$mapper_id $bind_fsroot" ]] ||
|
||||
fail "Encrypted media storage is not mounted; run ai-media mount first"
|
||||
}
|
||||
|
||||
manage_volume() {
|
||||
local action=$1 mapper mapper_id bind_unit automount_unit mounted bind jobs containers
|
||||
[[ $# == 1 ]] || fail "Usage: ai-media $action"
|
||||
bind_unit=$(systemd-escape -p --suffix=mount -- "$root")
|
||||
automount_unit=$(systemd-escape -p --suffix=automount -- "$root")
|
||||
read_mapper
|
||||
mounted=$(mount_info "$external_mount")
|
||||
bind=$(mount_info "$root")
|
||||
[[ -z "$mounted" || "$mounted" == "$mapper_id /" ]] ||
|
||||
fail "Unexpected filesystem at $external_mount; refusing to continue"
|
||||
[[ -z "$bind" || "$bind" == "$mapper_id $bind_fsroot" ]] ||
|
||||
fail "Unexpected filesystem at $root; refusing to continue"
|
||||
|
||||
if [[ "$action" == mount ]]; then
|
||||
if [[ -z "$mapper" ]]; then
|
||||
udisksctl unlock --block-device "$encrypted"
|
||||
read_mapper
|
||||
[[ -n "$mapper" ]] || fail "No decrypted block device found after unlock"
|
||||
fi
|
||||
if [[ -z "$mounted" ]]; then
|
||||
[[ -z "$(volume_mounts)" ]] || fail "The LUKS volume is already mounted elsewhere"
|
||||
udisksctl mount --block-device "$mapper"
|
||||
fi
|
||||
[[ "$(mount_info "$external_mount")" == "$mapper_id /" ]] ||
|
||||
fail "The LUKS volume is not mounted at the expected path: $external_mount"
|
||||
sudo systemctl start "$automount_unit" "$bind_unit"
|
||||
require_external_bind
|
||||
echo "Encrypted media storage mounted at $root"
|
||||
else
|
||||
jobs=$(systemctl --user list-units --type=service --state=active,activating,deactivating \
|
||||
--no-legend --no-pager 'ai-media-*.service')
|
||||
containers=$(podman --remote=false ps -q \
|
||||
--filter ancestor=localhost/ai-media-facefusion:managed \
|
||||
--filter ancestor=localhost/ai-media-rvc:managed)
|
||||
[[ -z "$jobs" && -z "$containers" ]] ||
|
||||
fail "Stop the running ai-media jobs and applications before unmounting"
|
||||
sudo systemctl stop ai-media-bind-restarter.service "$automount_unit" "$bind_unit"
|
||||
[[ -z "$(mount_info "$root")" ]] || fail "The media bind mount is still in use"
|
||||
mounted=$(volume_mounts)
|
||||
if [[ -n "$mounted" ]]; then
|
||||
[[ "$mounted" == "$external_mount" && "$(mount_info "$external_mount")" == "$mapper_id /" ]] ||
|
||||
fail "The LUKS volume has other mounts; refusing to unmount or lock it"
|
||||
udisksctl unmount --block-device "$mapper"
|
||||
fi
|
||||
if [[ -n "$mapper" ]]; then
|
||||
[[ -z "$(volume_mounts)" ]] || fail "The LUKS volume is still mounted"
|
||||
udisksctl lock --block-device "$encrypted"
|
||||
fi
|
||||
echo "Encrypted media storage unmounted and locked"
|
||||
fi
|
||||
}
|
||||
{% endif %}
|
||||
app="${1:-}"
|
||||
case "$app" in
|
||||
{% if manage_luks %}
|
||||
mount|umount) manage_volume "$@"; exit ;;
|
||||
{% endif %}
|
||||
facefusion|rvc) shift ;;
|
||||
ffmpeg) app=facefusion; shift; set -- ffmpeg "$@" ;;
|
||||
preset)
|
||||
shift
|
||||
for path in "$root" "$root/input" "$root/output"; do
|
||||
[[ -d "$path" && "$(realpath -- "$path")" == "$path" ]] || {
|
||||
echo "Unsafe or missing media directory: $path" >&2; exit 1;
|
||||
}
|
||||
done
|
||||
{% if manage_luks %}
|
||||
require_external_bind
|
||||
{% endif %}
|
||||
python3 "$build_root/check_storage.py" "$root"
|
||||
exec python3 "$build_root/preset.py" "$root" "$(realpath -- "$0")" "$@" ;;
|
||||
verify)
|
||||
for tool in facefusion rvc; do
|
||||
podman --remote=false run --rm --pull=never --network=none --read-only \
|
||||
--cap-drop=ALL --cap-add=SYS_CHROOT \
|
||||
--security-opt=no-new-privileges --userns=keep-id --http-proxy=false \
|
||||
--tmpfs "/tmp:rw,nosuid,nodev,size=4g,mode=1777" \
|
||||
--tmpfs "/home/media:rw,nosuid,nodev,size=128m,mode=1777" \
|
||||
--tmpfs "/work/state:rw,nosuid,nodev,size=128m,mode=1777" \
|
||||
--tmpfs "/work/models:rw,nosuid,nodev,size=128m,mode=1777" \
|
||||
"localhost/ai-media-$tool:managed" verify
|
||||
done
|
||||
exit 0 ;;
|
||||
*) echo "Usage: ai-media {facefusion|rvc|ffmpeg|preset|verify{% if manage_luks %}|mount|umount{% endif %}} [args ...]" >&2; exit 2 ;;
|
||||
esac
|
||||
# Fail closed if an existing data path was replaced by a symlink.
|
||||
for path in "$root" "$root/input" "$root/output" "$root/models" "$root/state/$app"; do
|
||||
[[ -d "$path" && "$(realpath -- "$path")" == "$path" ]] || {
|
||||
echo "Unsafe or missing media directory: $path" >&2; exit 1;
|
||||
}
|
||||
done
|
||||
{% if manage_luks %}
|
||||
require_external_bind
|
||||
{% endif %}
|
||||
python3 {{ (desktop_ai_media_build_root + "/check_storage.py") | quote }} "$root"
|
||||
# Run interactive sessions under the user manager, not the launching terminal.
|
||||
# No autostart or automatic restart: recovering a training run remains explicit.
|
||||
if [[ "$app" == rvc || "$app" == facefusion ]] && [[ $# -eq 0 ]]; then
|
||||
: "${XDG_RUNTIME_DIR:?Run this launcher from the GNOME Wayland session}"
|
||||
: "${WAYLAND_DISPLAY:?A Wayland session is required}"
|
||||
[[ "$WAYLAND_DISPLAY" != */* && -S "$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY" ]] || exit 1
|
||||
active=$(podman --remote=false ps --filter "ancestor=localhost/ai-media-$app:managed" --format '{{ '{{.ID}}' }}')
|
||||
if [[ -n "$active" ]]; then
|
||||
echo "$app is already running; leave its training session open." >&2
|
||||
exit 1
|
||||
fi
|
||||
exec systemd-run --user --collect --unit="ai-media-$app" \
|
||||
--property=Type=exec --property=Restart=no --property=Delegate=yes \
|
||||
--setenv="XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR" --setenv="WAYLAND_DISPLAY=$WAYLAND_DISPLAY" \
|
||||
-- /usr/bin/bash "$(realpath -- "$0")" "$app" --foreground
|
||||
fi
|
||||
if [[ "${1:-}" == --foreground ]]; then
|
||||
shift
|
||||
fi
|
||||
if [[ "$app" == rvc && "${1:-}" == cli ]]; then
|
||||
shift
|
||||
rvc_cli=1
|
||||
set -- /opt/preset_rvc.py "$@"
|
||||
else
|
||||
rvc_cli=0
|
||||
fi
|
||||
args=(
|
||||
run --rm --pull=never --network=none --read-only --userns=keep-id --http-proxy=false
|
||||
--cap-drop=ALL --security-opt=no-new-privileges
|
||||
--tmpfs "/tmp:rw,nosuid,nodev,size=8g,mode=1777"
|
||||
--tmpfs "/home/media:rw,nosuid,nodev,size=128m,mode=1777"
|
||||
--shm-size=512m
|
||||
--volume "$root/input:/work/input:ro,Z"
|
||||
--volume "$root/output:/work/output:rw,Z"
|
||||
--volume "$root/models:/work/models:ro,Z"
|
||||
--volume "$root/state/$app:/work/state:rw,Z"
|
||||
)
|
||||
if [[ "$rvc_cli" == 1 ]]; then
|
||||
args+=(--volume "$build_root/preset_rvc.py:/opt/preset_rvc.py:ro,Z" --entrypoint python)
|
||||
fi
|
||||
if [[ "$rvc_cli" != 1 && "${1:-}" != cli && "${1:-}" != ffmpeg ]]; then
|
||||
: "${XDG_RUNTIME_DIR:?Run this launcher from the GNOME Wayland session}"
|
||||
: "${WAYLAND_DISPLAY:?A Wayland session is required}"
|
||||
[[ "$WAYLAND_DISPLAY" != */* && -S "$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY" ]] || exit 1
|
||||
# Share only the display socket, never the runtime directory, D-Bus, home
|
||||
# directory or host browser. Do not relabel the compositor's socket.
|
||||
args+=(
|
||||
--cap-add=SYS_CHROOT
|
||||
--security-opt label=disable
|
||||
--tmpfs "/run/media:rw,nosuid,nodev,size=1m,mode=1777"
|
||||
--volume "$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY:/run/media/wayland-0:ro"
|
||||
--env WAYLAND_DISPLAY=wayland-0
|
||||
)
|
||||
if [[ -S "$XDG_RUNTIME_DIR/pulse/native" ]]; then
|
||||
args+=(
|
||||
--volume "$XDG_RUNTIME_DIR/pulse/native:/run/media/pulse-native:ro"
|
||||
--env PULSE_SERVER=unix:/run/media/pulse-native
|
||||
)
|
||||
fi
|
||||
fi
|
||||
exec podman --remote=false "${args[@]}" "localhost/ai-media-$app:managed" "$@"
|
||||
@@ -1,7 +0,0 @@
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name={{ 'FaceFusion' if item == 'facefusion' else 'RVC Voice Conversion' }} (offline)
|
||||
Exec={{ user_home }}/.local/bin/ai-media {{ item }}
|
||||
Terminal=false
|
||||
Categories=AudioVideo;
|
||||
StartupNotify=false
|
||||
@@ -1,15 +0,0 @@
|
||||
*
|
||||
!Containerfile.*
|
||||
!prepare.py
|
||||
!session.py
|
||||
!verify.py
|
||||
!requirements-facefusion.lock
|
||||
!requirements-rvc.lock
|
||||
!models/
|
||||
{% for model in desktop_ai_media_public_models %}
|
||||
!models/{{ model.app }}/
|
||||
{% for depth in range(1, model.path.split('/') | length) %}
|
||||
!models/{{ model.app }}/{{ model.path.split('/')[:depth] | join('/') }}/
|
||||
{% endfor %}
|
||||
!models/{{ model.app }}/{{ model.path }}
|
||||
{% endfor %}
|
||||
Binary file not shown.
@@ -1,584 +0,0 @@
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import socket
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
import wave
|
||||
import struct
|
||||
|
||||
from jinja2 import Environment
|
||||
import shlex
|
||||
|
||||
ROLE = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
class LauncherTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.temp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(self.temp.cleanup)
|
||||
self.root = Path(self.temp.name)
|
||||
self.media = self.root / '.local/share/ai-media'
|
||||
for directory in ('input', 'output', 'models', 'state/facefusion', 'state/rvc'):
|
||||
(self.media / directory).mkdir(parents=True)
|
||||
environment = Environment()
|
||||
environment.filters['quote'] = shlex.quote
|
||||
self.launcher = self.root / 'ai-media'
|
||||
self.launcher.write_text(environment.from_string(
|
||||
(ROLE / 'templates/ai-media.j2').read_text()
|
||||
).render(desktop_ai_media_root=str(self.media), desktop_ai_media_build_root=str(self.root)))
|
||||
(self.root / 'check_storage.py').write_text((ROLE / 'files/check_storage.py').read_text())
|
||||
for name in ('preset.py', 'preset_rvc.py'):
|
||||
(self.root / name).write_text((ROLE / 'files' / name).read_text())
|
||||
self.log = self.root / 'podman.json'
|
||||
podman = self.root / 'podman'
|
||||
podman.write_text('#!/usr/bin/python3\nimport json,os,sys\n'
|
||||
'open(os.environ["TEST_LOG"], "w").write(json.dumps(sys.argv[1:]))\n')
|
||||
podman.chmod(0o755)
|
||||
self.env = dict(os.environ, PATH=str(self.root) + ':' + os.environ['PATH'],
|
||||
TEST_LOG=str(self.log), HOME=str(self.root))
|
||||
|
||||
def launch(self, *args):
|
||||
return subprocess.run(['bash', str(self.launcher), *args], env=self.env,
|
||||
capture_output=True, text=True)
|
||||
|
||||
def fake_media_launcher(self):
|
||||
fake = self.root / 'fake-ai-media'
|
||||
fake.write_text('''#!/usr/bin/python3
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
root = Path(os.environ["TEST_MEDIA"])
|
||||
def host(path):
|
||||
return str(path).replace("/work/input/", str(root / "input") + "/").replace(
|
||||
"/work/output/", str(root / "output") + "/")
|
||||
|
||||
tool = sys.argv[1]
|
||||
args = sys.argv[2:]
|
||||
if tool == "ffmpeg":
|
||||
os.execvp("ffmpeg", ["ffmpeg", *[host(arg) for arg in args]])
|
||||
if tool == "facefusion":
|
||||
(root / "facefusion-args.json").write_text(__import__("json").dumps(args))
|
||||
shutil.copyfile(host(args[args.index("--target-path") + 1]),
|
||||
host(args[args.index("--output-path") + 1]))
|
||||
raise SystemExit(0)
|
||||
if tool == "rvc":
|
||||
(root / "rvc-args.json").write_text(__import__("json").dumps(args))
|
||||
source = Path(host(args[1]))
|
||||
job = Path(host(args[2]))
|
||||
if "--convert-only" not in args:
|
||||
(job / "instrumental").mkdir()
|
||||
shutil.copyfile(source, job / "instrumental/stem.wav")
|
||||
if "--separate-only" in args:
|
||||
(job / "vocals").mkdir()
|
||||
shutil.copyfile(source, job / "vocals/stem.wav")
|
||||
else:
|
||||
shutil.copyfile(source, job / "vocals-mia_voce.wav")
|
||||
raise SystemExit(0)
|
||||
raise SystemExit("Unexpected tool: " + tool)
|
||||
''')
|
||||
fake.chmod(0o755)
|
||||
return fake
|
||||
|
||||
def fake_downloader(self, fixture):
|
||||
downloader = self.root / 'yt-dlp'
|
||||
downloader.write_text('''#!/usr/bin/python3
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
args = sys.argv[1:]
|
||||
Path(os.environ["TEST_LOG"]).write_text(json.dumps(args))
|
||||
destination = args[args.index("--output") + 1].replace("%(ext)s", "mp4")
|
||||
shutil.copyfile(os.environ["TEST_DOWNLOAD_FIXTURE"], destination)
|
||||
''')
|
||||
downloader.chmod(0o755)
|
||||
self.env['TEST_DOWNLOAD_FIXTURE'] = str(fixture)
|
||||
return downloader
|
||||
|
||||
def run_preset(self, fake, *args, job_id='test'):
|
||||
return subprocess.run(['python3', str(self.root / 'preset.py'),
|
||||
str(self.media), str(fake), '--run', '--job-id', job_id, *args],
|
||||
env={**self.env, 'TEST_MEDIA': str(self.media)},
|
||||
capture_output=True, text=True)
|
||||
|
||||
def create_video(self, *, audio=False):
|
||||
video = self.media / 'input/video1.mp4'
|
||||
command = ['ffmpeg', '-hide_banner', '-loglevel', 'error', '-f', 'lavfi',
|
||||
'-i', 'color=c=black:s=64x64:d=1']
|
||||
if audio:
|
||||
command += ['-f', 'lavfi', '-i', 'sine=frequency=440:duration=1']
|
||||
command += ['-c:v', 'mpeg4']
|
||||
if audio:
|
||||
command += ['-c:a', 'aac', '-shortest']
|
||||
subprocess.run([*command, str(video)], check=True)
|
||||
return video
|
||||
|
||||
def stream_types(self, path):
|
||||
probe = subprocess.check_output(['ffprobe', '-v', 'error', '-show_entries',
|
||||
'stream=codec_type', '-of', 'json', str(path)])
|
||||
return {stream['codec_type'] for stream in json.loads(probe)['streams']}
|
||||
|
||||
def create_audio(self, relative, sample=1000, seconds=1):
|
||||
path = self.media / relative
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
with wave.open(str(path), 'wb') as audio:
|
||||
audio.setparams((1, 2, 8000, 0, 'NONE', 'not compressed'))
|
||||
audio.writeframes(struct.pack('<h', sample) * (8000 * seconds))
|
||||
return path
|
||||
|
||||
def test_mix_sums_stems_and_preserves_longest_duration(self):
|
||||
vocals = self.create_audio('output/video1-split-stems/vocals.wav')
|
||||
instrumental = self.create_audio('output/video1-split-stems/instrumental.wav',
|
||||
sample=2000, seconds=2)
|
||||
before = [path.read_bytes() for path in (vocals, instrumental)]
|
||||
result = self.run_preset(self.fake_media_launcher(), 'mix',
|
||||
'video1-split-stems/vocals.wav',
|
||||
'video1-split-stems/instrumental.wav', '--output', 'song.wav')
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
output = self.media / 'output/song.wav'
|
||||
self.assertEqual(self.stream_types(output), {'audio'})
|
||||
with wave.open(str(output), 'rb') as audio:
|
||||
self.assertEqual(audio.getnframes(), 16000)
|
||||
samples = struct.unpack('<16000h', audio.readframes(16000))
|
||||
self.assertAlmostEqual(samples[4000], 3000, delta=1)
|
||||
self.assertAlmostEqual(samples[12000], 2000, delta=1)
|
||||
self.assertEqual([path.read_bytes() for path in (vocals, instrumental)], before)
|
||||
|
||||
def test_voice_convert_audio_skips_separation_and_preserves_input(self):
|
||||
source = self.create_audio('output/video1-split-stems/vocals.wav')
|
||||
before = source.read_bytes()
|
||||
result = self.run_preset(self.fake_media_launcher(), 'voice-convert',
|
||||
'video1-split-stems/vocals.wav')
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
output = self.media / 'output/vocals-mia_voce.wav'
|
||||
self.assertEqual(self.stream_types(output), {'audio'})
|
||||
args = json.loads((self.media / 'rvc-args.json').read_text())
|
||||
self.assertIn('--convert-only', args)
|
||||
self.assertFalse(list((self.media / 'output').rglob('instrumental')))
|
||||
self.assertFalse((self.media / 'facefusion-args.json').exists())
|
||||
self.assertEqual(source.read_bytes(), before)
|
||||
repeated = self.run_preset(self.fake_media_launcher(), 'voice-convert',
|
||||
'video1-split-stems/vocals.wav')
|
||||
self.assertNotEqual(repeated.returncode, 0)
|
||||
|
||||
def test_voice_convert_dispatches_with_custom_output(self):
|
||||
self.create_audio('input/voice.wav')
|
||||
runner = self.root / 'systemd-run'
|
||||
runner.write_text('#!/usr/bin/python3\nimport json,os,sys\n'
|
||||
'open(os.environ["TEST_LOG"], "w").write(json.dumps(sys.argv[1:]))\n')
|
||||
runner.chmod(0o755)
|
||||
result = self.launch('preset', 'voice-convert', 'voice.wav', '--output', 'mine.wav')
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
args = json.loads(self.log.read_text())
|
||||
self.assertIn('--user', args)
|
||||
self.assertEqual(args[-4:], ['voice-convert', 'voice.wav', '--output', 'mine.wav'])
|
||||
|
||||
def test_voice_convert_rejects_invalid_audio_and_output(self):
|
||||
self.create_audio('input/voice.wav')
|
||||
for name in ('missing.wav', '../voice.wav', 'https://example.org/audio.wav'):
|
||||
self.assertNotEqual(self.launch('preset', 'voice-convert', name).returncode, 0)
|
||||
for name in ('../mine.wav', 'mine.mp3'):
|
||||
self.assertNotEqual(self.launch('preset', 'voice-convert', 'voice.wav',
|
||||
'--output', name).returncode, 0)
|
||||
self.create_audio('output/voice.wav')
|
||||
self.assertNotEqual(self.launch('preset', 'voice-convert', 'voice.wav').returncode, 0)
|
||||
self.assertFalse(self.log.exists())
|
||||
|
||||
def test_mix_default_output_and_no_overwrite(self):
|
||||
self.create_audio('input/voice.wav')
|
||||
self.create_audio('output/instrumental.wav')
|
||||
args = ('mix', 'voice.wav', 'instrumental.wav')
|
||||
result = self.run_preset(self.fake_media_launcher(), *args)
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
target = self.media / 'output/voice-mix.wav'
|
||||
original = target.read_bytes()
|
||||
result = self.run_preset(self.fake_media_launcher(), *args)
|
||||
self.assertNotEqual(result.returncode, 0)
|
||||
self.assertEqual(target.read_bytes(), original)
|
||||
|
||||
def test_mix_dispatches_audio_only_background_job(self):
|
||||
self.create_audio('input/voice.wav')
|
||||
self.create_audio('output/instrumental.wav')
|
||||
runner = self.root / 'systemd-run'
|
||||
runner.write_text('#!/usr/bin/python3\nimport json,os,sys\n'
|
||||
'open(os.environ["TEST_LOG"], "w").write(json.dumps(sys.argv[1:]))\n')
|
||||
runner.chmod(0o755)
|
||||
result = self.launch('preset', 'mix', 'voice.wav', 'instrumental.wav',
|
||||
'--output', 'song.wav')
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
args = json.loads(self.log.read_text())
|
||||
self.assertIn('--user', args)
|
||||
self.assertEqual(args[-5:], ['mix', 'voice.wav', 'instrumental.wav',
|
||||
'--output', 'song.wav'])
|
||||
self.assertFalse((self.media / 'output/song.wav').exists())
|
||||
|
||||
def test_mix_rejects_unsafe_paths_and_ambiguous_audio(self):
|
||||
self.create_audio('input/voice.wav')
|
||||
self.create_audio('output/instrumental.wav')
|
||||
for unsafe in ('../voice.wav', '/tmp/voice.wav', 'https://example.org/voice.wav'):
|
||||
result = self.launch('preset', 'mix', unsafe, 'instrumental.wav')
|
||||
self.assertNotEqual(result.returncode, 0)
|
||||
for unsafe in ('../song.wav', '/tmp/song.wav', 'song.mp3'):
|
||||
result = self.launch('preset', 'mix', 'voice.wav', 'instrumental.wav',
|
||||
'--output', unsafe)
|
||||
self.assertNotEqual(result.returncode, 0)
|
||||
(self.media / 'output/linked').symlink_to(self.media / 'input', target_is_directory=True)
|
||||
self.assertNotEqual(self.launch('preset', 'mix', 'linked/voice.wav',
|
||||
'instrumental.wav').returncode, 0)
|
||||
self.create_audio('output/voice.wav')
|
||||
self.assertNotEqual(self.launch('preset', 'mix', 'voice.wav',
|
||||
'instrumental.wav').returncode, 0)
|
||||
self.assertFalse(self.log.exists())
|
||||
|
||||
def test_mix_rejects_missing_audio_stream(self):
|
||||
video = self.create_video()
|
||||
self.create_audio('output/instrumental.wav')
|
||||
result = self.run_preset(self.fake_media_launcher(), 'mix', video.name,
|
||||
'instrumental.wav')
|
||||
self.assertNotEqual(result.returncode, 0)
|
||||
self.assertFalse((self.media / 'output/video1-mix.wav').exists())
|
||||
|
||||
def test_cli_has_no_network_or_host_home(self):
|
||||
result = self.launch('facefusion', 'cli', '--help')
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
args = json.loads(self.log.read_text())
|
||||
for flag in ('--network=none', '--pull=never', '--read-only',
|
||||
'--security-opt=no-new-privileges', '--cap-drop=ALL'):
|
||||
self.assertIn(flag, args)
|
||||
self.assertIn(str(self.media / 'input') + ':/work/input:ro,Z', args)
|
||||
self.assertNotIn('--privileged', args)
|
||||
self.assertNotIn('--security-opt', args)
|
||||
self.assertNotIn('label=disable', args)
|
||||
|
||||
def test_gui_exposes_only_wayland_socket(self):
|
||||
self.env.update(XDG_RUNTIME_DIR=str(self.root), WAYLAND_DISPLAY='wayland-0')
|
||||
with socket.socket(socket.AF_UNIX) as sock:
|
||||
sock.bind(str(self.root / 'wayland-0'))
|
||||
result = self.launch('rvc', '--foreground')
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
args = json.loads(self.log.read_text())
|
||||
self.assertIn('--network=none', args)
|
||||
self.assertIn(str(self.root / 'wayland-0') + ':/run/media/wayland-0:ro', args)
|
||||
self.assertIn('/run/media:rw,nosuid,nodev,size=1m,mode=1777', args)
|
||||
self.assertFalse(any('uid=' in arg or 'gid=' in arg for arg in args))
|
||||
self.assertNotIn('--publish', args)
|
||||
self.assertFalse(any('dbus' in arg for arg in args))
|
||||
|
||||
def test_rvc_cli_is_offline_and_mounts_only_preset_code(self):
|
||||
result = self.launch('rvc', 'cli', '/work/output/job/audio.wav', '/work/output/job')
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
args = json.loads(self.log.read_text())
|
||||
self.assertIn('--network=none', args)
|
||||
self.assertIn('--entrypoint', args)
|
||||
self.assertIn('python', args)
|
||||
self.assertIn(str(self.root / 'preset_rvc.py') + ':/opt/preset_rvc.py:ro,Z', args)
|
||||
self.assertIn('/opt/preset_rvc.py', args)
|
||||
self.assertNotIn('label=disable', args)
|
||||
|
||||
def test_voice_preset_dispatches_to_user_service(self):
|
||||
(self.media / 'input/video1.mp4').write_bytes(b'not processed in dispatch')
|
||||
runner = self.root / 'systemd-run'
|
||||
runner.write_text('#!/usr/bin/python3\nimport json,os,sys\n'
|
||||
'open(os.environ["TEST_LOG"], "w").write(json.dumps(sys.argv[1:]))\n')
|
||||
runner.chmod(0o755)
|
||||
result = self.launch('preset', 'audio-convert', 'video1.mp4')
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
args = json.loads(self.log.read_text())
|
||||
self.assertIn('--user', args)
|
||||
self.assertIn('--property=Restart=no', args)
|
||||
self.assertIn('audio-convert', args)
|
||||
self.assertIn('video1.mp4', args)
|
||||
|
||||
def test_face_preset_requires_all_sources(self):
|
||||
(self.media / 'input/video1.mp4').write_bytes(b'video')
|
||||
self.assertNotEqual(self.launch('preset', 'video-convert', 'video1.mp4').returncode, 0)
|
||||
self.assertFalse(self.log.exists())
|
||||
|
||||
def test_complete_preset_rejects_local_url(self):
|
||||
result = self.launch('preset', 'convert', 'file:///tmp/video.mp4')
|
||||
self.assertNotEqual(result.returncode, 0)
|
||||
self.assertFalse(self.log.exists())
|
||||
|
||||
def test_old_preset_names_are_rejected(self):
|
||||
for name in ('voce', 'volti', 'unisci', 'completo'):
|
||||
with self.subTest(name=name):
|
||||
self.assertEqual(self.launch('preset', name, 'video1.mp4').returncode, 2)
|
||||
|
||||
def test_all_url_presets_dispatch_one_background_job(self):
|
||||
for number in range(11, 19):
|
||||
(self.media / f'input/source{number}.jpg').write_bytes(b'source')
|
||||
runner = self.root / 'systemd-run'
|
||||
runner.write_text('#!/usr/bin/python3\nimport json,os,sys\n'
|
||||
'open(os.environ["TEST_LOG"], "w").write(json.dumps(sys.argv[1:]))\n')
|
||||
runner.chmod(0o755)
|
||||
(self.media / 'input/audio.wav').write_bytes(b'audio')
|
||||
for preset in ('audio-convert', 'video-convert', 'merge', 'split',
|
||||
'split-stems', 'convert'):
|
||||
with self.subTest(preset=preset):
|
||||
extra = ['audio.wav'] if preset == 'merge' else []
|
||||
result = self.launch('preset', preset, 'https://example.org/video', *extra)
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
args = json.loads(self.log.read_text())
|
||||
self.assertIn('--user', args)
|
||||
self.assertIn(preset, args)
|
||||
self.assertIn('https://example.org/video', args)
|
||||
if extra:
|
||||
self.assertEqual(args[-1], 'audio.wav')
|
||||
self.assertFalse(list((self.media / 'input').glob('download-*')))
|
||||
|
||||
def test_mux_preset_rejects_ambiguous_audio(self):
|
||||
(self.media / 'input/video1.mp4').write_bytes(b'video')
|
||||
(self.media / 'input/audio.wav').write_bytes(b'audio')
|
||||
(self.media / 'output/audio.wav').write_bytes(b'audio')
|
||||
self.assertNotEqual(self.launch('preset', 'merge', 'video1.mp4', 'audio.wav').returncode, 0)
|
||||
self.assertFalse(self.log.exists())
|
||||
|
||||
def test_mux_preset_creates_audio_video_with_streams(self):
|
||||
if subprocess.run(['bash', '-c', 'command -v ffmpeg && command -v ffprobe'],
|
||||
capture_output=True).returncode != 0:
|
||||
self.skipTest('ffmpeg and ffprobe required')
|
||||
self.create_video()
|
||||
audio = self.media / 'input/audio.wav'
|
||||
subprocess.run(['ffmpeg', '-hide_banner', '-loglevel', 'error', '-f', 'lavfi',
|
||||
'-i', 'sine=frequency=440:duration=1', str(audio)], check=True)
|
||||
result = self.run_preset(self.fake_media_launcher(), 'merge', 'video1.mp4', 'audio.wav')
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
output = self.media / 'output/video1-unito.mp4'
|
||||
self.assertTrue(output.is_file())
|
||||
self.assertEqual(self.stream_types(output), {'video', 'audio'})
|
||||
|
||||
def test_voice_preset_outputs_audio_only(self):
|
||||
self.create_video(audio=True)
|
||||
result = self.run_preset(self.fake_media_launcher(), 'audio-convert', 'video1.mp4')
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
output = self.media / 'output/video1-mia_voce.wav'
|
||||
self.assertEqual(self.stream_types(output), {'audio'})
|
||||
self.assertFalse((self.media / 'output/video1-mia_voce.mp4').exists())
|
||||
|
||||
def test_split_presets_output_separate_streams_without_conversion(self):
|
||||
original = self.create_video(audio=True).read_bytes()
|
||||
for preset in ('split', 'split-stems'):
|
||||
with self.subTest(preset=preset):
|
||||
result = self.run_preset(self.fake_media_launcher(), preset, 'video1.mp4')
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
output = self.media / 'output' / f'video1-{preset}'
|
||||
expected = {'video.mp4', 'audio.wav'}
|
||||
if preset == 'split-stems':
|
||||
expected |= {'vocals.wav', 'instrumental.wav'}
|
||||
args = json.loads((self.media / 'rvc-args.json').read_text())
|
||||
self.assertIn('--separate-only', args)
|
||||
else:
|
||||
self.assertFalse((self.media / 'rvc-args.json').exists())
|
||||
self.assertEqual({p.name for p in output.iterdir()}, expected)
|
||||
for name in expected:
|
||||
self.assertEqual(self.stream_types(output / name),
|
||||
{'video'} if name == 'video.mp4' else {'audio'})
|
||||
self.assertEqual((self.media / 'input/video1.mp4').read_bytes(), original)
|
||||
self.assertFalse(list((self.media / 'output').rglob('*mia_voce*')))
|
||||
before = {p.name: p.read_bytes() for p in output.iterdir()}
|
||||
repeated = self.run_preset(self.fake_media_launcher(), preset, 'video1.mp4',
|
||||
job_id='repeat')
|
||||
self.assertNotEqual(repeated.returncode, 0)
|
||||
self.assertEqual({p.name: p.read_bytes() for p in output.iterdir()}, before)
|
||||
|
||||
def test_split_presets_reject_video_without_audio(self):
|
||||
self.create_video()
|
||||
for preset in ('split', 'split-stems'):
|
||||
result = self.run_preset(self.fake_media_launcher(), preset, 'video1.mp4')
|
||||
self.assertNotEqual(result.returncode, 0)
|
||||
self.assertFalse(list((self.media / 'output').iterdir()))
|
||||
|
||||
def test_face_preset_preserves_audio_only_when_present(self):
|
||||
for audio in (False, True):
|
||||
with self.subTest(audio=audio):
|
||||
video = self.media / 'input/video1.mp4'
|
||||
if video.exists():
|
||||
video.unlink()
|
||||
self.create_video(audio=audio)
|
||||
for number in range(11, 19):
|
||||
(self.media / f'input/source{number}.jpg').write_bytes(b'source')
|
||||
output = self.media / 'output/video1-facefusion.mp4'
|
||||
if output.exists():
|
||||
output.unlink()
|
||||
result = self.run_preset(self.fake_media_launcher(), 'video-convert', 'video1.mp4',
|
||||
job_id=f'test-{audio}')
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
self.assertEqual(self.stream_types(output),
|
||||
{'video', 'audio'} if audio else {'video'})
|
||||
|
||||
def test_face_preset_uses_requested_options(self):
|
||||
self.create_video(audio=True)
|
||||
for number in range(11, 19):
|
||||
(self.media / f'input/source{number}.jpg').write_bytes(b'source')
|
||||
result = self.run_preset(self.fake_media_launcher(), 'video-convert', 'video1.mp4')
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
args = json.loads((self.media / 'facefusion-args.json').read_text())
|
||||
source_start = args.index('--source-paths') + 1
|
||||
self.assertEqual(args[source_start:source_start + 8],
|
||||
[f'/work/input/source{number}.jpg' for number in range(11, 19)])
|
||||
expected = {
|
||||
'--processors': ['face_swapper'],
|
||||
'--face-swapper-model': ['hyperswap_1a_256'],
|
||||
'--face-swapper-pixel-boost': ['256x256'],
|
||||
'--face-swapper-weight': ['0.5'],
|
||||
'--face-detector-model': ['yolo_face'],
|
||||
'--face-detector-size': ['640x640'],
|
||||
'--face-detector-angles': ['0', '90', '180', '270'],
|
||||
'--face-detector-score': ['0.5'],
|
||||
'--face-selector-mode': ['one'],
|
||||
'--face-selector-order': ['large-small'],
|
||||
'--face-selector-gender': ['female'],
|
||||
'--face-selector-race': ['white'],
|
||||
'--face-mask-types': ['occlusion', 'region', 'area', 'box'],
|
||||
'--face-occluder-model': ['xseg_1'],
|
||||
'--face-parser-model': ['bisenet_resnet_34'],
|
||||
'--face-mask-blur': ['0.3'],
|
||||
'--output-video-encoder': ['libx264'],
|
||||
'--output-video-preset': ['veryfast'],
|
||||
'--output-video-quality': ['80'],
|
||||
'--output-video-fps': ['30'],
|
||||
'--execution-providers': ['cpu'],
|
||||
'--output-audio-encoder': ['aac'],
|
||||
'--jobs-path': ['/work/state'],
|
||||
'--temp-path': ['/work/state/tmp'],
|
||||
}
|
||||
for flag, values in expected.items():
|
||||
with self.subTest(flag=flag):
|
||||
start = args.index(flag) + 1
|
||||
self.assertEqual(args[start:start + len(values)], values)
|
||||
|
||||
def test_complete_preset_downloads_and_combines_both_results(self):
|
||||
fixture = self.create_video(audio=True)
|
||||
for number in range(11, 19):
|
||||
(self.media / f'input/source{number}.jpg').write_bytes(b'source')
|
||||
self.fake_downloader(fixture)
|
||||
result = self.run_preset(self.fake_media_launcher(), 'convert',
|
||||
'https://example.org/video', job_id='test')
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
self.assertTrue((self.media / 'input/download-test.mp4').is_file())
|
||||
self.assertEqual(self.stream_types(self.media / 'output/download-test-mia_voce.wav'),
|
||||
{'audio'})
|
||||
self.assertEqual(self.stream_types(self.media / 'output/download-test-facefusion.mp4'),
|
||||
{'video', 'audio'})
|
||||
self.assertEqual(self.stream_types(self.media / 'output/download-test-completo.mp4'),
|
||||
{'video', 'audio'})
|
||||
face_args = json.loads((self.media / 'facefusion-args.json').read_text())
|
||||
self.assertEqual(face_args[face_args.index('--face-selector-gender') + 1], 'female')
|
||||
self.assertEqual(face_args[face_args.index('--output-video-fps') + 1], '30')
|
||||
downloader_args = json.loads(self.log.read_text())
|
||||
self.assertIn('--ignore-config', downloader_args)
|
||||
self.assertIn('--no-playlist', downloader_args)
|
||||
|
||||
def test_default_gui_uses_independent_user_service(self):
|
||||
self.env.update(XDG_RUNTIME_DIR=str(self.root), WAYLAND_DISPLAY='wayland-0')
|
||||
runner = self.root / 'systemd-run'
|
||||
runner.write_text('#!/usr/bin/python3\nimport json,os,sys\n'
|
||||
'open(os.environ["TEST_LOG"], "w").write(json.dumps(sys.argv[1:]))\n')
|
||||
runner.chmod(0o755)
|
||||
with socket.socket(socket.AF_UNIX) as sock:
|
||||
sock.bind(str(self.root / 'wayland-0'))
|
||||
result = self.launch('rvc')
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
args = json.loads(self.log.read_text())
|
||||
self.assertIn('--user', args)
|
||||
self.assertIn('--unit=ai-media-rvc', args)
|
||||
self.assertIn('--property=Restart=no', args)
|
||||
self.assertIn('--foreground', args)
|
||||
self.assertNotIn('--scope', args)
|
||||
self.assertNotIn('--pty', args)
|
||||
self.assertNotIn('--wait', args)
|
||||
|
||||
def test_all_presets_download_url_before_processing(self):
|
||||
fixture = self.create_video(audio=True)
|
||||
self.fake_downloader(fixture)
|
||||
for number in range(11, 19):
|
||||
(self.media / f'input/source{number}.jpg').write_bytes(b'source')
|
||||
audio = self.media / 'input/audio.wav'
|
||||
subprocess.run(['ffmpeg', '-hide_banner', '-loglevel', 'error', '-i',
|
||||
str(fixture), '-vn', str(audio)], check=True)
|
||||
outputs = {
|
||||
'audio-convert': 'mia_voce.wav', 'video-convert': 'facefusion.mp4',
|
||||
'merge': 'unito.mp4', 'split': 'split', 'split-stems': 'split-stems',
|
||||
'convert': 'completo.mp4',
|
||||
}
|
||||
for preset, suffix in outputs.items():
|
||||
with self.subTest(preset=preset):
|
||||
extra = ['audio.wav'] if preset == 'merge' else []
|
||||
result = self.run_preset(self.fake_media_launcher(), preset,
|
||||
'https://example.org/video?a=1&b=2', *extra,
|
||||
job_id=preset)
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
self.assertEqual(result.stdout.count('Downloading one video'), 1)
|
||||
self.assertTrue((self.media / f'input/download-{preset}.mp4').is_file())
|
||||
output = self.media / f'output/download-{preset}-{suffix}'
|
||||
self.assertTrue(output.exists())
|
||||
if preset in ('split', 'split-stems'):
|
||||
self.assertEqual(self.stream_types(output / 'video.mp4'), {'video'})
|
||||
self.assertEqual(self.stream_types(output / 'audio.wav'), {'audio'})
|
||||
else:
|
||||
self.assertEqual(self.stream_types(output), {'audio'} if
|
||||
preset == 'audio-convert' else {'video', 'audio'})
|
||||
download_args = json.loads(self.log.read_text())
|
||||
self.assertEqual(download_args[-1], 'https://example.org/video?a=1&b=2')
|
||||
for flag in ('--ignore-config', '--no-playlist', '--no-overwrites'):
|
||||
self.assertIn(flag, download_args)
|
||||
|
||||
def test_convert_also_accepts_local_video_without_download(self):
|
||||
fixture = self.create_video(audio=True)
|
||||
self.fake_downloader(fixture)
|
||||
for number in range(11, 19):
|
||||
(self.media / f'input/source{number}.jpg').write_bytes(b'source')
|
||||
result = self.run_preset(self.fake_media_launcher(), 'convert', fixture.name)
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
self.assertFalse(self.log.exists())
|
||||
self.assertEqual(self.stream_types(self.media / 'output/video1-completo.mp4'),
|
||||
{'video', 'audio'})
|
||||
|
||||
def test_all_presets_reject_invalid_urls_before_dispatch(self):
|
||||
for preset in ('split', 'split-stems', 'audio-convert', 'video-convert',
|
||||
'merge', 'convert'):
|
||||
for url in ('file:///tmp/video.mp4', 'https://localhost/video',
|
||||
'http://192.168.1.1/video', 'https://user:password@example.org/video'):
|
||||
with self.subTest(preset=preset, url=url):
|
||||
extra = ['audio.wav'] if preset == 'merge' else []
|
||||
result = self.launch('preset', preset, url, *extra)
|
||||
self.assertNotEqual(result.returncode, 0)
|
||||
self.assertFalse(self.log.exists())
|
||||
|
||||
def test_failed_url_download_does_not_start_processing(self):
|
||||
downloader = self.root / 'yt-dlp'
|
||||
downloader.write_text('#!/bin/sh\nexit 1\n')
|
||||
downloader.chmod(0o755)
|
||||
result = self.run_preset(self.fake_media_launcher(), 'split',
|
||||
'https://example.org/video')
|
||||
self.assertNotEqual(result.returncode, 0)
|
||||
self.assertFalse(list((self.media / 'output').iterdir()))
|
||||
|
||||
def test_symlinked_input_is_rejected(self):
|
||||
(self.media / 'input').rmdir()
|
||||
(self.media / 'input').symlink_to(self.root)
|
||||
self.assertNotEqual(self.launch('facefusion', 'cli', '--help').returncode, 0)
|
||||
self.assertFalse(self.log.exists())
|
||||
|
||||
def test_synced_storage_is_rejected(self):
|
||||
directory = self.root / '.config/Nextcloud'
|
||||
directory.mkdir(parents=True)
|
||||
(directory / 'nextcloud.cfg').write_text(
|
||||
'[Accounts]\n0\\Folders\\1\\localPath=' + str(self.media) + '\n'
|
||||
)
|
||||
self.assertNotEqual(self.launch('facefusion', 'cli', '--help').returncode, 0)
|
||||
self.assertFalse(self.log.exists())
|
||||
|
||||
def test_invalid_tool_is_rejected(self):
|
||||
self.assertEqual(self.launch('--network=host').returncode, 2)
|
||||
self.assertFalse(self.log.exists())
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -1,93 +0,0 @@
|
||||
import importlib.util
|
||||
import os
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import tempfile
|
||||
from types import ModuleType
|
||||
import unittest
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
|
||||
class SeparationWorkerTest(unittest.TestCase):
|
||||
def test_convert_only_applies_mia_voce_without_importing_separator(self):
|
||||
spec = importlib.util.spec_from_file_location(
|
||||
'preset_rvc', Path(__file__).resolve().parents[1] / 'files/preset_rvc.py')
|
||||
worker = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(worker)
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
output = root / 'output'
|
||||
job = output / 'job'
|
||||
job.mkdir(parents=True)
|
||||
source = job / 'audio.wav'
|
||||
source.write_bytes(b'audio')
|
||||
weights = root / 'state/weights/mia_voce.pth'
|
||||
index = root / 'state/mia_voce/added_IVF256_Flat_nprobe_1_mia_voce_v2.index'
|
||||
for path in (weights, index):
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_bytes(b'model')
|
||||
|
||||
def mapped_path(value):
|
||||
return root / str(value).removeprefix('/work/') if str(value).startswith(
|
||||
'/work/') else Path(value)
|
||||
|
||||
config = ModuleType('configs.config')
|
||||
config.Config = Mock()
|
||||
vc = ModuleType('infer.vc.modules')
|
||||
voice = Mock()
|
||||
voice.vc_single.return_value = ('Success', (40000, [0.1, 0.2]))
|
||||
vc.VC = Mock(return_value=voice)
|
||||
sf = ModuleType('soundfile')
|
||||
sf.write = Mock(side_effect=lambda path, data, rate: path.write_bytes(b'converted'))
|
||||
modules = {'configs.config': config, 'infer.vc.modules': vc,
|
||||
'soundfile': sf, 'tools.pymss_webui': None}
|
||||
with patch.object(worker, 'Path', mapped_path), \
|
||||
patch.object(sys, 'argv', ['preset_rvc.py', str(source), str(job),
|
||||
'--convert-only']), \
|
||||
patch.dict(sys.modules, modules), patch.dict(os.environ):
|
||||
worker.main()
|
||||
voice.get_vc.assert_called_once_with('mia_voce.pth')
|
||||
self.assertEqual(voice.vc_single.call_args.args[1], str(source))
|
||||
self.assertEqual(voice.vc_single.call_args.args[4], str(index))
|
||||
self.assertEqual((job / 'vocals-mia_voce.wav').read_bytes(), b'converted')
|
||||
self.assertFalse((job / 'vocals').exists())
|
||||
self.assertFalse((job / 'instrumental').exists())
|
||||
|
||||
def test_separate_only_does_not_require_personal_voice_weights(self):
|
||||
spec = importlib.util.spec_from_file_location(
|
||||
'preset_rvc', Path(__file__).resolve().parents[1] / 'files/preset_rvc.py')
|
||||
worker = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(worker)
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
output = Path(directory)
|
||||
job = output / 'job'
|
||||
job.mkdir()
|
||||
source = job / 'audio.wav'
|
||||
source.write_bytes(b'fixture')
|
||||
separator = ModuleType('tools.pymss_webui')
|
||||
|
||||
def separate(model, audio, vocals, unused, instrumental, fmt, **kwargs):
|
||||
self.assertEqual(model, 'vocals-bs-roformer-368')
|
||||
self.assertEqual(audio, str(source))
|
||||
(Path(vocals) / 'stem.wav').write_bytes(b'vocals')
|
||||
(Path(instrumental) / 'stem.wav').write_bytes(b'instrumental')
|
||||
yield 'Separated'
|
||||
|
||||
separator.pymss_separate = separate
|
||||
|
||||
def mapped_path(value):
|
||||
return output if str(value) == '/work/output' else Path(value)
|
||||
|
||||
with patch.object(worker, 'Path', mapped_path), \
|
||||
patch.object(sys, 'argv', ['preset_rvc.py', str(source), str(job),
|
||||
'--separate-only']), \
|
||||
patch.dict(sys.modules, {'tools.pymss_webui': separator}), \
|
||||
patch.dict(os.environ):
|
||||
worker.main()
|
||||
self.assertTrue((job / 'vocals/stem.wav').is_file())
|
||||
self.assertTrue((job / 'instrumental/stem.wav').is_file())
|
||||
self.assertFalse((job / 'vocals-mia_voce.wav').exists())
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -1,183 +0,0 @@
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shlex
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
from jinja2 import Environment
|
||||
|
||||
|
||||
TEMPLATE = Path(__file__).resolve().parents[1] / "templates/ai-media.j2"
|
||||
UUID = "6948c504-2d60-4cc8-9e7f-3ccdf28e80d7"
|
||||
|
||||
|
||||
class StorageCommandsTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
temp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(temp.cleanup)
|
||||
self.root = Path(temp.name)
|
||||
self.media = self.root / "media"
|
||||
for directory in ("input", "output"):
|
||||
(self.media / directory).mkdir(parents=True)
|
||||
env = Environment()
|
||||
env.filters["quote"] = shlex.quote
|
||||
self.launcher = self.root / "ai-media"
|
||||
self.launcher.write_text(env.from_string(TEMPLATE.read_text()).render(
|
||||
desktop_ai_media_root=str(self.media),
|
||||
desktop_ai_media_build_root=str(self.root),
|
||||
desktop_ai_media_external_storage_enabled=True,
|
||||
desktop_ai_media_external_luks_uuid=UUID,
|
||||
desktop_ai_media_external_mountpoint="/run/media/test/Backup",
|
||||
desktop_ai_media_external_source="/run/media/test/Backup/ai-media",
|
||||
))
|
||||
self.state = self.root / "state.json"
|
||||
self.log = self.root / "commands.jsonl"
|
||||
mock = self.root / "mock"
|
||||
mock.write_text('''#!/usr/bin/env python3
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
cmd = Path(sys.argv[0]).name
|
||||
args = sys.argv[1:]
|
||||
state_file = Path(os.environ["STORAGE_TEST_STATE"])
|
||||
state = json.loads(state_file.read_text())
|
||||
root = os.environ["STORAGE_TEST_ROOT"]
|
||||
external = "/run/media/test/Backup"
|
||||
with open(os.environ["STORAGE_TEST_LOG"], "a") as log:
|
||||
log.write(json.dumps([cmd, *args]) + "\\n")
|
||||
if cmd == "sudo":
|
||||
os.execvp(args[0], args)
|
||||
elif cmd == "lsblk":
|
||||
if state.get("missing"):
|
||||
sys.exit(1)
|
||||
print("/dev/sda1 part 8:1")
|
||||
if state.get("unlocked"):
|
||||
print("/dev/dm-0 crypt 252:0")
|
||||
elif cmd == "findmnt":
|
||||
if "--mountpoint" in args:
|
||||
target = args[args.index("--mountpoint") + 1]
|
||||
match = state.get("bind" if target == root else "mounted")
|
||||
if not match:
|
||||
sys.exit(1)
|
||||
print(match)
|
||||
elif "--source" in args:
|
||||
assert args[args.index("--source") + 1] == "252:0"
|
||||
mounts = ([external] if state.get("mounted") else []) + (
|
||||
[root] if state.get("bind") else []) + state.get("other_mounts", [])
|
||||
if not mounts:
|
||||
sys.exit(1)
|
||||
print(*mounts, sep="\\n")
|
||||
else:
|
||||
sys.exit(2)
|
||||
elif cmd == "systemctl":
|
||||
if args[0] == "--user":
|
||||
if state.get("running"):
|
||||
print("ai-media-preset-test.service loaded active running")
|
||||
elif args[0] == "start":
|
||||
state["bind"] = "252:0 /ai-media"
|
||||
elif args[0] == "stop":
|
||||
state.pop("bind", None)
|
||||
elif cmd == "podman":
|
||||
assert args[:3] == ["--remote=false", "ps", "-q"]
|
||||
if state.get("container"):
|
||||
print("abcdef")
|
||||
elif cmd == "udisksctl":
|
||||
if args[0] == "unlock":
|
||||
state["unlocked"] = True
|
||||
elif args[0] == "mount":
|
||||
state["mounted"] = "252:0 /"
|
||||
elif args[0] == "unmount":
|
||||
if state.get("busy"):
|
||||
sys.exit("Device is busy")
|
||||
state.pop("mounted", None)
|
||||
elif args[0] == "lock":
|
||||
assert not state.get("mounted")
|
||||
state.pop("unlocked")
|
||||
state_file.write_text(json.dumps(state))
|
||||
''')
|
||||
mock.chmod(0o755)
|
||||
for command in ("lsblk", "findmnt", "systemctl", "podman", "udisksctl", "sudo"):
|
||||
(self.root / command).symlink_to(mock)
|
||||
self.env = dict(os.environ, PATH=f"{self.root}:{os.environ['PATH']}",
|
||||
STORAGE_TEST_STATE=str(self.state), STORAGE_TEST_LOG=str(self.log),
|
||||
STORAGE_TEST_ROOT=str(self.media))
|
||||
|
||||
def units(self):
|
||||
return [subprocess.check_output(["systemd-escape", "-p", "--suffix=" + suffix, "--", str(self.media)], text=True).strip()
|
||||
for suffix in ("automount", "mount")]
|
||||
|
||||
def launch(self, *args, **state):
|
||||
self.state.write_text(json.dumps(state))
|
||||
self.log.write_text("")
|
||||
result = subprocess.run(["bash", str(self.launcher), *args], env=self.env,
|
||||
capture_output=True, text=True, timeout=10)
|
||||
operations = [row[:2] if row[0] == "systemctl" else row
|
||||
for line in self.log.read_text().splitlines()
|
||||
if (row := json.loads(line))[0] in ("udisksctl", "systemctl", "sudo")]
|
||||
return result, operations
|
||||
|
||||
def test_mount_unlocks_only_the_configured_volume_then_starts_bind(self):
|
||||
result, operations = self.launch("mount")
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
self.assertEqual(operations, [
|
||||
["udisksctl", "unlock", "--block-device", f"/dev/disk/by-uuid/{UUID}"],
|
||||
["udisksctl", "mount", "--block-device", "/dev/dm-0"],
|
||||
["sudo", "systemctl", "start", *self.units()],
|
||||
["systemctl", "start"],
|
||||
])
|
||||
|
||||
def test_mount_does_not_reopen_already_mounted_volume(self):
|
||||
result, operations = self.launch("mount", unlocked=True, mounted="252:0 /")
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
self.assertEqual(operations, [["sudo", "systemctl", "start", *self.units()], ["systemctl", "start"]])
|
||||
|
||||
def test_umount_stops_bind_before_unmount_and_lock(self):
|
||||
result, operations = self.launch("umount", unlocked=True, mounted="252:0 /",
|
||||
bind="252:0 /ai-media")
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
self.assertEqual(operations, [
|
||||
["systemctl", "--user"], ["sudo", "systemctl", "stop", "ai-media-bind-restarter.service", *self.units()], ["systemctl", "stop"],
|
||||
["udisksctl", "unmount", "--block-device", "/dev/dm-0"],
|
||||
["udisksctl", "lock", "--block-device", f"/dev/disk/by-uuid/{UUID}"],
|
||||
])
|
||||
|
||||
def test_umount_refuses_running_jobs_and_containers(self):
|
||||
for condition in ("running", "container"):
|
||||
with self.subTest(condition=condition):
|
||||
result, operations = self.launch("umount", **{condition: True})
|
||||
self.assertNotEqual(result.returncode, 0)
|
||||
self.assertIn("running ai-media jobs", result.stderr)
|
||||
self.assertEqual(operations, [["systemctl", "--user"]])
|
||||
|
||||
def test_umount_does_not_lock_if_busy(self):
|
||||
result, operations = self.launch("umount", unlocked=True, mounted="252:0 /", busy=True)
|
||||
self.assertNotEqual(result.returncode, 0)
|
||||
self.assertEqual(operations[-1][:2], ["udisksctl", "unmount"])
|
||||
|
||||
def test_umount_does_not_touch_other_mounts(self):
|
||||
result, operations = self.launch("umount", unlocked=True, mounted="252:0 /",
|
||||
other_mounts=["/mnt/other"])
|
||||
self.assertNotEqual(result.returncode, 0)
|
||||
self.assertEqual(operations, [["systemctl", "--user"], ["sudo", "systemctl", "stop", "ai-media-bind-restarter.service", *self.units()], ["systemctl", "stop"]])
|
||||
|
||||
def test_rejects_foreign_mount_missing_device_and_extra_arguments(self):
|
||||
for args, state in [
|
||||
(("mount",), {"mounted": "8:2 /"}),
|
||||
(("umount",), {"bind": "8:2 /ai-media"}),
|
||||
(("mount",), {"missing": True}),
|
||||
(("umount", "/dev/sdb"), {}),
|
||||
]:
|
||||
with self.subTest(args=args, state=state):
|
||||
result, operations = self.launch(*args, **state)
|
||||
self.assertNotEqual(result.returncode, 0)
|
||||
self.assertEqual(operations, [])
|
||||
|
||||
def test_preset_refuses_local_fallback_when_bind_is_stopped(self):
|
||||
result, operations = self.launch("preset", "split", "test.mp4")
|
||||
self.assertNotEqual(result.returncode, 0)
|
||||
self.assertIn("run ai-media mount first", result.stderr)
|
||||
self.assertEqual(operations, [])
|
||||
@@ -1,134 +0,0 @@
|
||||
---
|
||||
desktop_ai_media_public_models:
|
||||
- app: facefusion
|
||||
path: .assets/models/2dfan4.hash
|
||||
url: https://github.com/facefusion/facefusion-assets/releases/download/models-3.0.0/2dfan4.hash
|
||||
sha256: e6a6ef99b10b9fdb790c790879ca201f7afbe52560e4379248922324a9d503e8
|
||||
- app: facefusion
|
||||
path: .assets/models/2dfan4.onnx
|
||||
url: https://github.com/facefusion/facefusion-assets/releases/download/models-3.0.0/2dfan4.onnx
|
||||
sha256: 678c6fa539d52335a31c980feefdf4a6e02d781d83dce00af8a894f114557285
|
||||
- app: facefusion
|
||||
path: .assets/models/arcface_w600k_r50.hash
|
||||
url: https://github.com/facefusion/facefusion-assets/releases/download/models-3.0.0/arcface_w600k_r50.hash
|
||||
sha256: e3a6d709939a81fe09e71c7d36f96d54a0deede904e31a38c191a1904e808371
|
||||
- app: facefusion
|
||||
path: .assets/models/arcface_w600k_r50.onnx
|
||||
url: https://github.com/facefusion/facefusion-assets/releases/download/models-3.0.0/arcface_w600k_r50.onnx
|
||||
sha256: f1f79dc3b0b79a69f94799af1fffebff09fbd78fd96a275fd8f0cbbea23270d1
|
||||
- app: facefusion
|
||||
path: .assets/models/bisenet_resnet_34.hash
|
||||
url: https://github.com/facefusion/facefusion-assets/releases/download/models-3.0.0/bisenet_resnet_34.hash
|
||||
sha256: bfca5e43ca55110701ab691d864cacfddccad324dc42043aea8c001a949ce1f8
|
||||
- app: facefusion
|
||||
path: .assets/models/bisenet_resnet_34.onnx
|
||||
url: https://github.com/facefusion/facefusion-assets/releases/download/models-3.0.0/bisenet_resnet_34.onnx
|
||||
sha256: 4a0b8c958a3c938913bd06a8365dbb3c8761afba6ecbf0d14b3b1f77eb230c96
|
||||
- app: facefusion
|
||||
path: .assets/models/fairface.hash
|
||||
url: https://github.com/facefusion/facefusion-assets/releases/download/models-3.0.0/fairface.hash
|
||||
sha256: e232c933114a6c9ce446195e4a96bf1c3327dd31c13165849cd00f9f19a2ea62
|
||||
- app: facefusion
|
||||
path: .assets/models/fairface.onnx
|
||||
url: https://github.com/facefusion/facefusion-assets/releases/download/models-3.0.0/fairface.onnx
|
||||
sha256: b176b1e4b0739496e7943af7ba4ff306271fecf837bca5ec5d9a48201959db37
|
||||
- app: facefusion
|
||||
path: .assets/models/fan_68_5.hash
|
||||
url: https://github.com/facefusion/facefusion-assets/releases/download/models-3.0.0/fan_68_5.hash
|
||||
sha256: 092d902410959b3ce01294d7c1ad157f1c602e3918238117e7ef87157be9534e
|
||||
- app: facefusion
|
||||
path: .assets/models/fan_68_5.onnx
|
||||
url: https://github.com/facefusion/facefusion-assets/releases/download/models-3.0.0/fan_68_5.onnx
|
||||
sha256: ea05f7d9d014ae1d9cdc6e9c72643d8f00d198b5db3fdd384148ddff499a613e
|
||||
- app: facefusion
|
||||
path: .assets/models/hyperswap_1a_256.hash
|
||||
url: https://github.com/facefusion/facefusion-assets/releases/download/models-3.3.0/hyperswap_1a_256.hash
|
||||
sha256: 70b33d0a9d6044847d9b29f9d08ce7afc140a2cada5b4b5f532bbd6440ba48c1
|
||||
- app: facefusion
|
||||
path: .assets/models/hyperswap_1a_256.onnx
|
||||
url: https://github.com/facefusion/facefusion-assets/releases/download/models-3.3.0/hyperswap_1a_256.onnx
|
||||
sha256: c0e98a8a03a238f461ed3d2570e426b49f46745ee400854a60dceeb70c246add
|
||||
- app: facefusion
|
||||
path: .assets/models/kim_vocal_2.hash
|
||||
url: https://github.com/facefusion/facefusion-assets/releases/download/models-3.0.0/kim_vocal_2.hash
|
||||
sha256: fcd81ca30adf430b697fe58d60183031173c8ab0ca82efef308d652b1afb4197
|
||||
- app: facefusion
|
||||
path: .assets/models/kim_vocal_2.onnx
|
||||
url: https://github.com/facefusion/facefusion-assets/releases/download/models-3.0.0/kim_vocal_2.onnx
|
||||
sha256: fbde1fd7d35a6b1785add2225ce03255a01ccef6c8a5fb7b2ccd4e0c1e9097f7
|
||||
- app: facefusion
|
||||
path: .assets/models/nsfw_1.hash
|
||||
url: https://github.com/facefusion/facefusion-assets/releases/download/models-3.3.0/nsfw_1.hash
|
||||
sha256: 48c61a15ffcda1ae9e6d4c790224072c8e5648d4ba2f767cf4cfe0be7e282853
|
||||
- app: facefusion
|
||||
path: .assets/models/nsfw_1.onnx
|
||||
url: https://github.com/facefusion/facefusion-assets/releases/download/models-3.3.0/nsfw_1.onnx
|
||||
sha256: 3debfd72763bc931dd308f57d1e9299ae13bb309d14ddbdc17ce8f1fd42f96af
|
||||
- app: facefusion
|
||||
path: .assets/models/nsfw_2.hash
|
||||
url: https://github.com/facefusion/facefusion-assets/releases/download/models-3.3.0/nsfw_2.hash
|
||||
sha256: 64cbc0c1a4d72e181fae364281b6d2130be3b87d5784909c5a29adf436f09a01
|
||||
- app: facefusion
|
||||
path: .assets/models/nsfw_2.onnx
|
||||
url: https://github.com/facefusion/facefusion-assets/releases/download/models-3.3.0/nsfw_2.onnx
|
||||
sha256: 5aae1806ce44e3c27fab0a7d44eed581dd25ca71a4387ff809a191c98239c1be
|
||||
- app: facefusion
|
||||
path: .assets/models/nsfw_3.hash
|
||||
url: https://github.com/facefusion/facefusion-assets/releases/download/models-3.3.0/nsfw_3.hash
|
||||
sha256: b15c591d8177511959174a0c6761827e3bf9c0aa1d63aaa79645d9fc9a4e774b
|
||||
- app: facefusion
|
||||
path: .assets/models/nsfw_3.onnx
|
||||
url: https://github.com/facefusion/facefusion-assets/releases/download/models-3.3.0/nsfw_3.onnx
|
||||
sha256: 778139fb930240ac39812a1480295bfc5dc2cec8a8e46ee6b453481d600c0fa2
|
||||
- app: facefusion
|
||||
path: .assets/models/xseg_1.hash
|
||||
url: https://github.com/facefusion/facefusion-assets/releases/download/models-3.1.0/xseg_1.hash
|
||||
sha256: da3648ccecaa79f3be5ca0e1c3713f775504dd5c5dff716c095925132c02b08e
|
||||
- app: facefusion
|
||||
path: .assets/models/xseg_1.onnx
|
||||
url: https://github.com/facefusion/facefusion-assets/releases/download/models-3.1.0/xseg_1.onnx
|
||||
sha256: c4d1498b8a03b5fe2a3a5d2ef2a0402ab03bd51edaf5b2d8d5fb764702a97dd3
|
||||
- app: facefusion
|
||||
path: .assets/models/yoloface_8n.hash
|
||||
url: https://github.com/facefusion/facefusion-assets/releases/download/models-3.0.0/yoloface_8n.hash
|
||||
sha256: 7a4bd7e1a8cd938db2234dba41d4a8b7719bedbf7496d35510927cbd4b71683f
|
||||
- app: facefusion
|
||||
path: .assets/models/yoloface_8n.onnx
|
||||
url: https://github.com/facefusion/facefusion-assets/releases/download/models-3.0.0/yoloface_8n.onnx
|
||||
sha256: 821cdbb1e65fbbabdde7dd0933f754797a343e56fd962729c61ffcefcd135929
|
||||
- app: rvc
|
||||
path: assets/hubert_base/config.json
|
||||
url: https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/e6d0c1a17da07c33557852f9dfa2bd44cc75737d/hubert_base/config.json
|
||||
sha256: 0346950779dfb7f9316fa74ed846e2b8a22a08eedfdc5387b73f327cb1a4a7cf
|
||||
- app: rvc
|
||||
path: assets/hubert_base/preprocessor_config.json
|
||||
url: https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/e6d0c1a17da07c33557852f9dfa2bd44cc75737d/hubert_base/preprocessor_config.json
|
||||
sha256: 7c1976a680fb7acc757cd36fb08eef878fa36c70b4c9d2d595df9c608bbbbf0e
|
||||
- app: rvc
|
||||
path: assets/hubert_base/pytorch_model.bin
|
||||
url: https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/e6d0c1a17da07c33557852f9dfa2bd44cc75737d/hubert_base/pytorch_model.bin
|
||||
sha256: cc8c20f4b90a520757260197a3ff2505705a7adbd20ad9eeaa4e1a9b38442ef5
|
||||
- app: rvc
|
||||
path: assets/rmvpe/rmvpe.pt
|
||||
url: https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/e6d0c1a17da07c33557852f9dfa2bd44cc75737d/rmvpe.pt
|
||||
sha256: 6d62215f4306e3ca278246188607209f09af3dc77ed4232efdd069798c4ec193
|
||||
- app: rvc
|
||||
path: assets/mute.zip
|
||||
url: https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/e6d0c1a17da07c33557852f9dfa2bd44cc75737d/mute.zip
|
||||
sha256: ee948e85213e4ed2f2ba2f8dfcee810bfd0b63131d91450e920bbe1cbd0321d0
|
||||
- app: rvc
|
||||
path: assets/pretrained_v2/f0D40k.pth
|
||||
url: https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/e6d0c1a17da07c33557852f9dfa2bd44cc75737d/pretrained_v2/f0D40k.pth
|
||||
sha256: 6b6ab091e70801b28e3f41f335f2fc5f3f35c75b39ae2628d419644ec2b0fa09
|
||||
- app: rvc
|
||||
path: assets/pretrained_v2/f0G40k.pth
|
||||
url: https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/e6d0c1a17da07c33557852f9dfa2bd44cc75737d/pretrained_v2/f0G40k.pth
|
||||
sha256: 3b2c44035e782c4b14ddc0bede9e2f4a724d025cd073f736d4f43708453adfcb
|
||||
- app: rvc
|
||||
path: assets/pymss_weights/model_bs_roformer_ep_368_sdr_12.9628.ckpt
|
||||
url: https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/e6d0c1a17da07c33557852f9dfa2bd44cc75737d/pymss_weights/model_bs_roformer_ep_368_sdr_12.9628.ckpt
|
||||
sha256: 97c9e1011924ff647d147b474638c161b80586fd5b9e83fab59cbbb70014bf62
|
||||
- app: rvc
|
||||
path: assets/pymss_weights/model_bs_roformer_ep_368_sdr_12.9628.yaml
|
||||
url: https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/e6d0c1a17da07c33557852f9dfa2bd44cc75737d/pymss_weights/model_bs_roformer_ep_368_sdr_12.9628.yaml
|
||||
sha256: 105fd8e6a1ef1b038db2aa657a9f9696283d506dbc815bd7134a57aa80ec9f10
|
||||
@@ -1,4 +0,0 @@
|
||||
---
|
||||
devcontainer_generator_go_binary: /usr/bin/go
|
||||
devcontainer_generator_install_go: true
|
||||
devcontainer_generator_build_dir: "{{ user_home }}/.cache/infra/devcontainer-generator"
|
||||
@@ -1,64 +0,0 @@
|
||||
---
|
||||
- name: Install Go compiler for the devcontainer generator
|
||||
ansible.builtin.dnf:
|
||||
name: golang
|
||||
state: present
|
||||
when: devcontainer_generator_install_go | bool
|
||||
|
||||
- name: Ensure devcontainer generator directories exist
|
||||
ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
owner: "{{ username }}"
|
||||
group: "{{ user_group }}"
|
||||
mode: "0755"
|
||||
loop:
|
||||
- "{{ user_home }}/.local/bin"
|
||||
- "{{ devcontainer_generator_build_dir }}"
|
||||
|
||||
- name: Copy devcontainer generator sources
|
||||
ansible.builtin.copy:
|
||||
src: "{{ playbook_dir }}/../cmd/devcontainer/"
|
||||
dest: "{{ devcontainer_generator_build_dir }}/src/"
|
||||
owner: "{{ username }}"
|
||||
group: "{{ user_group }}"
|
||||
mode: preserve
|
||||
|
||||
- name: Build devcontainer generator for the target host
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- "{{ devcontainer_generator_go_binary }}"
|
||||
- build
|
||||
- -trimpath
|
||||
- -buildvcs=false
|
||||
- -o
|
||||
- "{{ devcontainer_generator_build_dir }}/devcontainer"
|
||||
- .
|
||||
chdir: "{{ devcontainer_generator_build_dir }}/src"
|
||||
become_user: "{{ username }}"
|
||||
environment:
|
||||
GOCACHE: "{{ devcontainer_generator_build_dir }}/go-cache"
|
||||
GOTOOLCHAIN: local
|
||||
GOPROXY: "off"
|
||||
GOSUMDB: "off"
|
||||
CGO_ENABLED: "0"
|
||||
# Compilation refreshes a cached artifact; copy below reports installation changes.
|
||||
changed_when: false
|
||||
when: not ansible_check_mode
|
||||
|
||||
- name: Install devcontainer generator in the user PATH
|
||||
ansible.builtin.copy:
|
||||
src: "{{ devcontainer_generator_build_dir }}/devcontainer"
|
||||
remote_src: true
|
||||
dest: "{{ user_home }}/.local/bin/devcontainer"
|
||||
owner: "{{ username }}"
|
||||
group: "{{ user_group }}"
|
||||
mode: "0755"
|
||||
when: not ansible_check_mode
|
||||
|
||||
- name: Explain devcontainer generator check-mode behavior
|
||||
ansible.builtin.debug:
|
||||
msg: >-
|
||||
Check mode validates package and source deployment only. Compilation and
|
||||
installation of {{ user_home }}/.local/bin/devcontainer require a normal run.
|
||||
when: ansible_check_mode
|
||||
@@ -91,20 +91,6 @@
|
||||
loop_control:
|
||||
label: "{{ item.dest }}"
|
||||
|
||||
- name: Ensure AI coding-agent dotfile parent directories exist
|
||||
tags: [dotfiles, dotfiles:common, ai_agents]
|
||||
ansible.builtin.file:
|
||||
path: "{{ (effective_user_home ~ '/' ~ item.dest) | dirname }}"
|
||||
state: directory
|
||||
owner: "{{ effective_username }}"
|
||||
group: "{{ effective_user_group }}"
|
||||
mode: "0755"
|
||||
loop: "{{ ai_agents_dotfiles | default([]) }}"
|
||||
loop_control:
|
||||
label: "{{ item.dest }}"
|
||||
when:
|
||||
- (item.agents | intersect(ai_agents_deploy_enabled_names)) | length > 0
|
||||
|
||||
- name: Deploy AI coding-agent dotfiles
|
||||
tags: [dotfiles, dotfiles:common, ai_agents]
|
||||
ansible.builtin.copy:
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||
|
||||
mQINBGpypFUBEACi1Vvzq9pIpA6lj7chbqELuxJtVuzUzxrasa6ZU0yF4yhq7jf8
|
||||
3YkJRHwbezBKeQyzJ5lkX0EhXS8aXxUhMAm3PFpAlwcInfKzmV7atJwvaxIw6Rmd
|
||||
GYe9fBWKjTN/SmPIjtyxrTznZY97+TfD1AeGZpLaJ8fsnhrC+HkiN2TACiTocgpe
|
||||
hFiP0OWK7mWZeTWnY2scpIYXP1Ro7nQv4KacmY4JacTQ7m/HM0Qej/3olhuEv2Cw
|
||||
lMVWw57/oHhmTllfLDQOogFQyIVqaaR98y/Eu6cAabSfcsqAAZ2A8vfHYD27z28J
|
||||
vLO2PZEJd5ThlnX4Zqv0eIpZdBj//8Sl/MSqTshFZ1NDsRoqwdqw284X5MpnOJ4k
|
||||
4Sc2Se8tJxt/nCeibH3dJ504Fb1X/mnOqhCAQ6pVJz4RB5HRlFPSkxVPyag1v1m/
|
||||
7T4vie+OR4eqFQNz6mudrOoMmeVIfyL5fbe4cOr4fk/FyvEE2xMgkFatPqXn7vM9
|
||||
og+zremPCfwRAFpBPyX74VowFY7llcdaj/w8K5T8PzM14Hb3E4ZKizMluKmTvTq9
|
||||
WE1/eSQJLLQqXD5VmtmdUaC/VyE/1ZlIxcA1LWqvEQ327UXREvX/nHsrkKrl956W
|
||||
jzkiHFUTsD1NJ0dMfs+csOt8Furb5jZj+HsMmCm9jLdfz5b/4WKLPbvxIwARAQAB
|
||||
tBZDb2RleCBMaW51eCBSZXBvc2l0b3J5iQJRBBMBCgA7FiEEO/oOSui4zBai2bpo
|
||||
SjtKVmxGYOQFAmpypFUCGwMFCwkIBwICIgIGFQoJCAsCBBYCAwECHgcCF4AACgkQ
|
||||
SjtKVmxGYORlCQ/9FyikZo8HQcJBP9E/oXVPds/fQnIFB2qJR2z3DrfYEonNt/ev
|
||||
SAySkPPq4/mEOjaI0pFlDDGSaps+FTcJFgoVRTasBIF7JJivvjW9ap8iWEbhhVLe
|
||||
IrFLbMLpUcTRntUx7R4fVMJ/1/cGn+NWZmNwS9ORorzSyCH0IAgCw1Xc3ZrjuMbF
|
||||
VjdToMC1TiXXCEmlYpQakmQ3Ay1cH0FHC2BBNn1MNVkJdPhpZIZCdhaMPHfYFpyo
|
||||
pg8wFvZ5iIcvlbMgyuy8CPJVRWUcYy2dOhEOGnYJnXRPkE3E1hf8YOHNzRlduH89
|
||||
6lT9qcEK2+fpLfrVGoc4zscLZ+Ey+Ko6iQRdVE1j67+wNR3hX8ukue574v1N/xxu
|
||||
i575jumSE19lEj1sH4+P4gFHOtTbF0JhKKzLctbga0IAwTPKhnt3qzj1U5Yj/MZS
|
||||
uEVjrLhdRauOuFBXUclgyVf2w/lE85UUOdlcollsYA6Huq7xDamqf8SslZQGre3E
|
||||
I+lhpqJR1cOwDMUzzcl40uTyhrxXXd/bk4QSlhZbwHR25Pnt+ZMtWavlQWS0eDEV
|
||||
8djuXAURCmx5WOqAFB/TJe1mn5EvyWg4VFzrY/NVNOpzgY5+Xp7J28z7f637r712
|
||||
Eu9j4imVcdPigwS+jf/0f81i2o9b82Y26TN8+EtDLCY841MJ1lrjDrX/dno=
|
||||
=Y+3h
|
||||
-----END PGP PUBLIC KEY BLOCK-----
|
||||
@@ -1,92 +0,0 @@
|
||||
---
|
||||
# ChatGPT desktop is installed from OpenAI's signed RPM repository; removal
|
||||
# must clean up the package, the managed repository and its signing key.
|
||||
- name: Validate ChatGPT desktop architecture on Fedora
|
||||
tags: [packages, chatgpt]
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- ansible_facts['architecture'] in chatgpt_desktop_supported_architectures
|
||||
- ansible_facts['distribution_major_version'] in chatgpt_desktop_supported_fedora_versions
|
||||
fail_msg: >-
|
||||
ChatGPT desktop supports Fedora {{ chatgpt_desktop_supported_fedora_versions | join(' and ') }}
|
||||
on x86_64 or aarch64; detected Fedora {{ ansible_facts['distribution_major_version'] }}
|
||||
on {{ ansible_facts['architecture'] }}.
|
||||
when: chatgpt_desktop_install_enabled | default(false) | bool
|
||||
|
||||
- name: Install ChatGPT desktop RPM signing key
|
||||
tags: [packages, chatgpt]
|
||||
ansible.builtin.copy:
|
||||
src: "{{ chatgpt_desktop_rpm_gpg_key }}"
|
||||
dest: "/etc/pki/rpm-gpg/{{ chatgpt_desktop_rpm_gpg_key }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
when: chatgpt_desktop_install_enabled | default(false) | bool
|
||||
|
||||
- name: Import ChatGPT desktop RPM signing key
|
||||
tags: [packages, chatgpt]
|
||||
ansible.builtin.rpm_key:
|
||||
state: present
|
||||
key: "/etc/pki/rpm-gpg/{{ chatgpt_desktop_rpm_gpg_key }}"
|
||||
when: chatgpt_desktop_install_enabled | default(false) | bool
|
||||
|
||||
- name: Configure ChatGPT desktop RPM repository
|
||||
tags: [packages, chatgpt]
|
||||
ansible.builtin.yum_repository:
|
||||
name: openai-chatgpt
|
||||
description: ChatGPT
|
||||
baseurl: "{{ chatgpt_desktop_rpm_repository }}"
|
||||
enabled: true
|
||||
gpgcheck: true
|
||||
repo_gpgcheck: true
|
||||
gpgkey: "file:///etc/pki/rpm-gpg/{{ chatgpt_desktop_rpm_gpg_key }}"
|
||||
state: present
|
||||
when: chatgpt_desktop_install_enabled | default(false) | bool
|
||||
|
||||
- name: Install ChatGPT desktop on selected Fedora hosts
|
||||
tags: [packages, chatgpt]
|
||||
ansible.builtin.dnf:
|
||||
name: chatgpt
|
||||
state: latest
|
||||
update_cache: true
|
||||
when: chatgpt_desktop_install_enabled | default(false) | bool
|
||||
|
||||
- name: Check for the installed ChatGPT desktop signing key
|
||||
tags: [packages, chatgpt]
|
||||
ansible.builtin.stat:
|
||||
path: "/etc/pki/rpm-gpg/{{ chatgpt_desktop_rpm_gpg_key }}"
|
||||
get_checksum: false
|
||||
register: chatgpt_desktop_signing_key
|
||||
when: chatgpt_desktop_uninstall_enabled | default(false) | bool
|
||||
|
||||
- name: Remove ChatGPT desktop from selected Fedora hosts
|
||||
tags: [packages, chatgpt]
|
||||
ansible.builtin.dnf:
|
||||
name: chatgpt
|
||||
state: absent
|
||||
when: chatgpt_desktop_uninstall_enabled | default(false) | bool
|
||||
|
||||
- name: Remove ChatGPT desktop RPM repository
|
||||
tags: [packages, chatgpt]
|
||||
ansible.builtin.yum_repository:
|
||||
name: openai-chatgpt
|
||||
state: absent
|
||||
when: chatgpt_desktop_uninstall_enabled | default(false) | bool
|
||||
|
||||
# rpm_key reads the identifier from the key file, so only remove the key from
|
||||
# the RPM database while the deployed file is still present.
|
||||
- name: Remove ChatGPT desktop RPM signing key from the RPM database
|
||||
tags: [packages, chatgpt]
|
||||
ansible.builtin.rpm_key:
|
||||
state: absent
|
||||
key: "/etc/pki/rpm-gpg/{{ chatgpt_desktop_rpm_gpg_key }}"
|
||||
when:
|
||||
- chatgpt_desktop_uninstall_enabled | default(false) | bool
|
||||
- chatgpt_desktop_signing_key.stat.exists | default(false)
|
||||
|
||||
- name: Remove ChatGPT desktop RPM signing key file
|
||||
tags: [packages, chatgpt]
|
||||
ansible.builtin.file:
|
||||
path: "/etc/pki/rpm-gpg/{{ chatgpt_desktop_rpm_gpg_key }}"
|
||||
state: absent
|
||||
when: chatgpt_desktop_uninstall_enabled | default(false) | bool
|
||||
@@ -1,78 +0,0 @@
|
||||
---
|
||||
# Cline Desktop ships unsigned RPMs from its GitHub releases; only the
|
||||
# checksum-verified download makes the local installation trustworthy.
|
||||
- name: Validate Cline Desktop architecture on Fedora
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- ansible_facts['architecture'] in cline_desktop_rpm_checksums
|
||||
fail_msg: "No verified Cline Desktop RPM for {{ ansible_facts['architecture'] }}."
|
||||
when: cline_desktop_install_enabled | default(false) | bool
|
||||
|
||||
# Runs for both flows so the register below is always valid.
|
||||
- name: Check for cached Cline Desktop RPM
|
||||
ansible.builtin.stat:
|
||||
path: "{{ cline_desktop_rpm_path }}"
|
||||
get_checksum: false
|
||||
register: cline_desktop_rpm_cache
|
||||
|
||||
- name: Download verified Cline Desktop RPM
|
||||
ansible.builtin.get_url:
|
||||
url: "{{ cline_desktop_rpm_url }}"
|
||||
dest: "{{ cline_desktop_rpm_path }}"
|
||||
checksum: "{{ cline_desktop_rpm_checksums[ansible_facts['architecture']] }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
# get_url only sends HEAD in check mode and cannot populate a cold cache.
|
||||
when:
|
||||
- cline_desktop_install_enabled | default(false) | bool
|
||||
- not ansible_check_mode
|
||||
|
||||
- name: Install Cline Desktop on Fedora
|
||||
ansible.builtin.dnf:
|
||||
name: "{{ cline_desktop_rpm_path }}"
|
||||
state: present
|
||||
# Upstream ships an unsigned RPM. The download above verifies its pinned
|
||||
# SHA-256; do not disable signature checks in system repository settings.
|
||||
disable_gpg_check: true
|
||||
when:
|
||||
- cline_desktop_install_enabled | default(false) | bool
|
||||
- not ansible_check_mode
|
||||
or cline_desktop_rpm_cache.stat.exists
|
||||
|
||||
- name: Explain Cline Desktop cold-cache check-mode limitation
|
||||
ansible.builtin.debug:
|
||||
msg: >-
|
||||
A real run will download and SHA-256 verify Cline Desktop
|
||||
{{ cline_desktop_version }} before ensuring it is installed.
|
||||
The RPM is not cached, so this dry run cannot validate DNF dependencies.
|
||||
when:
|
||||
- cline_desktop_install_enabled | default(false) | bool
|
||||
- ansible_check_mode
|
||||
- not cline_desktop_rpm_cache.stat.exists
|
||||
|
||||
# The `cline` RPM package name is verified from the pinned release header;
|
||||
# removal never touches the npm-managed cline CLI or user data.
|
||||
- name: Remove Cline Desktop from Fedora
|
||||
ansible.builtin.dnf:
|
||||
name: cline
|
||||
state: absent
|
||||
when: cline_desktop_uninstall_enabled | default(false) | bool
|
||||
|
||||
# Clean every cached download so retirement also removes outdated pins.
|
||||
- name: Find cached Cline Desktop RPM downloads
|
||||
ansible.builtin.find:
|
||||
paths: /var/cache
|
||||
patterns: "cline-desktop-*.rpm"
|
||||
file_type: file
|
||||
register: cline_desktop_cached_rpms
|
||||
when: cline_desktop_uninstall_enabled | default(false) | bool
|
||||
|
||||
- name: Remove cached Cline Desktop RPM downloads
|
||||
ansible.builtin.file:
|
||||
path: "{{ item.path }}"
|
||||
state: absent
|
||||
loop: "{{ cline_desktop_cached_rpms.files | default([]) }}"
|
||||
loop_control:
|
||||
label: "{{ item.path }}"
|
||||
when: cline_desktop_uninstall_enabled | default(false) | bool
|
||||
@@ -25,45 +25,25 @@
|
||||
- "'workstation_dev_fedora' in group_names"
|
||||
- fedora_manage_docker_repo | default(false)
|
||||
|
||||
- name: Install distribution signing keys for Fedora desktop codecs
|
||||
tags: [packages, heic]
|
||||
- name: Install COPR support on Fedora WSL
|
||||
tags: [packages, mise]
|
||||
ansible.builtin.dnf:
|
||||
name: distribution-gpg-keys
|
||||
name: dnf-plugins-core
|
||||
state: present
|
||||
when: "'graphical_desktop' in group_names"
|
||||
when: "'workstation_dev_wsl' in group_names"
|
||||
|
||||
- name: Import RPM Fusion Free signing key for Fedora desktop codecs
|
||||
tags: [packages, heic]
|
||||
ansible.builtin.rpm_key:
|
||||
key: /usr/share/distribution-gpg-keys/rpmfusion/RPM-GPG-KEY-rpmfusion-free-fedora-2020
|
||||
fingerprint: E9A491A3DE247814E7E067EAE06F8ECDD651FF2E
|
||||
state: present
|
||||
when: "'graphical_desktop' in group_names"
|
||||
|
||||
- name: Enable RPM Fusion Free for Fedora desktop codecs
|
||||
tags: [packages, heic]
|
||||
ansible.builtin.dnf:
|
||||
name: "https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-{{ ansible_facts['distribution_major_version'] }}.noarch.rpm"
|
||||
state: present
|
||||
when: "'graphical_desktop' in group_names"
|
||||
- name: Configure Mise COPR repository on Fedora WSL
|
||||
tags: [packages, mise]
|
||||
community.general.copr:
|
||||
name: jdxcode/mise
|
||||
state: enabled
|
||||
when: "'workstation_dev_wsl' in group_names"
|
||||
|
||||
- name: Refresh dnf package metadata
|
||||
tags: [packages]
|
||||
ansible.builtin.dnf:
|
||||
update_cache: true
|
||||
|
||||
- name: Install HEIC decoder when RPM Fusion has a compatible build
|
||||
tags: [packages, heic]
|
||||
ansible.builtin.dnf:
|
||||
name: libheif-freeworld
|
||||
state: present
|
||||
update_cache: true
|
||||
# libheif-freeworld requires the exact libheif build. RPM Fusion can lag
|
||||
# Fedora Updates, so retry on later runs instead of blocking all desktop
|
||||
# package convergence while the matching build is unavailable.
|
||||
skip_broken: true
|
||||
when: "'graphical_desktop' in group_names"
|
||||
|
||||
- name: Install packages on Fedora
|
||||
tags: [packages]
|
||||
ansible.builtin.dnf:
|
||||
@@ -130,10 +110,6 @@
|
||||
name: "{{ item.value.npm_package }}"
|
||||
global: true
|
||||
state: latest
|
||||
register: ai_agent_npm_install
|
||||
retries: "{{ ai_agents_npm_install_retries }}"
|
||||
delay: "{{ ai_agents_npm_install_retry_delay }}"
|
||||
until: ai_agent_npm_install is succeeded
|
||||
loop: "{{ ai_agents | dict2items | selectattr('value.npm_package', 'defined') | list }}"
|
||||
when:
|
||||
- item.value.install_enabled | bool
|
||||
@@ -154,30 +130,6 @@
|
||||
loop_control:
|
||||
label: "{{ item.key }}"
|
||||
|
||||
- name: Manage ChatGPT desktop lifecycle on Fedora graphical hosts
|
||||
tags: [packages, chatgpt]
|
||||
ansible.builtin.import_tasks: chatgpt_desktop.yml
|
||||
when:
|
||||
- "'graphical_desktop' in group_names"
|
||||
- chatgpt_desktop_install_enabled | default(false) | bool
|
||||
or chatgpt_desktop_uninstall_enabled | default(false) | bool
|
||||
|
||||
- name: Manage OpenCode Desktop lifecycle on Fedora graphical hosts
|
||||
tags: [packages, opencode_desktop]
|
||||
ansible.builtin.import_tasks: opencode_desktop.yml
|
||||
when:
|
||||
- "'graphical_desktop' in group_names"
|
||||
- opencode_desktop_install_enabled | default(false) | bool
|
||||
or opencode_desktop_uninstall_enabled | default(false) | bool
|
||||
|
||||
- name: Manage Cline Desktop lifecycle on Fedora graphical hosts
|
||||
tags: [packages, cline_desktop]
|
||||
ansible.builtin.import_tasks: cline_desktop.yml
|
||||
when:
|
||||
- "'graphical_desktop' in group_names"
|
||||
- cline_desktop_install_enabled | default(false) | bool
|
||||
or cline_desktop_uninstall_enabled | default(false) | bool
|
||||
|
||||
- name: Define Fedora Flatpak applications
|
||||
tags: [packages]
|
||||
ansible.builtin.set_fact:
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
---
|
||||
# OpenCode Desktop ships unsigned RPMs from its GitHub releases; only the
|
||||
# checksum-verified download makes the local installation trustworthy.
|
||||
- name: Validate OpenCode Desktop architecture on Fedora
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- ansible_facts['architecture'] in opencode_desktop_rpm_checksums
|
||||
fail_msg: "No verified OpenCode Desktop RPM for {{ ansible_facts['architecture'] }}."
|
||||
when: opencode_desktop_install_enabled | default(false) | bool
|
||||
|
||||
# Runs for both flows so the register below is always valid.
|
||||
- name: Check for cached OpenCode Desktop RPM
|
||||
ansible.builtin.stat:
|
||||
path: "{{ opencode_desktop_rpm_path }}"
|
||||
get_checksum: false
|
||||
register: opencode_desktop_rpm_cache
|
||||
|
||||
- name: Download verified OpenCode Desktop RPM
|
||||
ansible.builtin.get_url:
|
||||
url: "{{ opencode_desktop_rpm_url }}"
|
||||
dest: "{{ opencode_desktop_rpm_path }}"
|
||||
checksum: "{{ opencode_desktop_rpm_checksums[ansible_facts['architecture']] }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
# get_url only sends HEAD in check mode and cannot populate a cold cache.
|
||||
when:
|
||||
- opencode_desktop_install_enabled | default(false) | bool
|
||||
- not ansible_check_mode
|
||||
|
||||
- name: Install OpenCode Desktop on Fedora
|
||||
ansible.builtin.dnf:
|
||||
name: "{{ opencode_desktop_rpm_path }}"
|
||||
state: present
|
||||
# Upstream ships an unsigned RPM. The download above verifies its pinned
|
||||
# SHA-256; do not disable signature checks in system repository settings.
|
||||
disable_gpg_check: true
|
||||
when:
|
||||
- opencode_desktop_install_enabled | default(false) | bool
|
||||
- not ansible_check_mode
|
||||
or opencode_desktop_rpm_cache.stat.exists
|
||||
|
||||
- name: Explain OpenCode Desktop cold-cache check-mode limitation
|
||||
ansible.builtin.debug:
|
||||
msg: >-
|
||||
A real run will download and SHA-256 verify OpenCode Desktop
|
||||
{{ opencode_desktop_version }} before ensuring it is installed.
|
||||
The RPM is not cached, so this dry run cannot validate DNF dependencies.
|
||||
when:
|
||||
- opencode_desktop_install_enabled | default(false) | bool
|
||||
- ansible_check_mode
|
||||
- not opencode_desktop_rpm_cache.stat.exists
|
||||
|
||||
# The `opencode` RPM package name is verified from the pinned release header;
|
||||
# removal never touches the npm-managed opencode-ai CLI or user data.
|
||||
- name: Remove OpenCode Desktop from Fedora
|
||||
ansible.builtin.dnf:
|
||||
name: opencode
|
||||
state: absent
|
||||
when: opencode_desktop_uninstall_enabled | default(false) | bool
|
||||
|
||||
# Clean every cached download so retirement also removes outdated pins.
|
||||
- name: Find cached OpenCode Desktop RPM downloads
|
||||
ansible.builtin.find:
|
||||
paths: /var/cache
|
||||
patterns: "opencode-desktop-*.rpm"
|
||||
file_type: file
|
||||
register: opencode_desktop_cached_rpms
|
||||
when: opencode_desktop_uninstall_enabled | default(false) | bool
|
||||
|
||||
- name: Remove cached OpenCode Desktop RPM downloads
|
||||
ansible.builtin.file:
|
||||
path: "{{ item.path }}"
|
||||
state: absent
|
||||
loop: "{{ opencode_desktop_cached_rpms.files | default([]) }}"
|
||||
loop_control:
|
||||
label: "{{ item.path }}"
|
||||
when: opencode_desktop_uninstall_enabled | default(false) | bool
|
||||
@@ -27,14 +27,6 @@
|
||||
name: epel-release
|
||||
state: present
|
||||
|
||||
- name: Import official OpenZFS EL9+ signing key
|
||||
tags: [packages, storage]
|
||||
ansible.builtin.rpm_key:
|
||||
state: present
|
||||
key: "{{ rocky_openzfs_gpg_key_url }}"
|
||||
fingerprint: "{{ rocky_openzfs_gpg_key_fingerprint }}"
|
||||
when: rocky_manage_openzfs_repo | bool
|
||||
|
||||
- name: Install official OpenZFS repository package
|
||||
tags: [packages, storage]
|
||||
ansible.builtin.dnf:
|
||||
|
||||
@@ -106,14 +106,6 @@
|
||||
state: present
|
||||
update_cache: false
|
||||
|
||||
- name: Remove excluded packages on Void Linux
|
||||
tags: [packages]
|
||||
community.general.xbps:
|
||||
name: "{{ void_removed_packages | default([]) }}"
|
||||
state: absent
|
||||
update_cache: false
|
||||
when: (void_removed_packages | default([])) | length > 0
|
||||
|
||||
- name: Check whether the selected display manager is active
|
||||
tags: [packages, display-manager]
|
||||
ansible.builtin.stat:
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
---
|
||||
aegis_hostname: aegis
|
||||
aegis_layered_packages:
|
||||
- nfs-utils
|
||||
- wireguard-tools
|
||||
aegis_network_connection_name: ""
|
||||
aegis_network_connection_uuid: ""
|
||||
aegis_host_dns_servers: []
|
||||
aegis_host_dns_search_domains: []
|
||||
aegis_adguard_image: docker.io/adguard/adguardhome:latest
|
||||
aegis_icloudpd_image: docker.io/boredazfcuk/icloudpd:latest
|
||||
aegis_icloudpd_folder_structure: '{:%Y/%m/%d}'
|
||||
aegis_icloudpd_synchronisation_interval: 86400
|
||||
aegis_icloudpd_apple_id: ""
|
||||
aegis_ikaros_mac_address: aa:bb:cc:dd:ee:ff
|
||||
aegis_wol_port: 9
|
||||
|
||||
|
||||
@@ -9,12 +9,13 @@
|
||||
name: sshd.service
|
||||
state: reloaded
|
||||
|
||||
- name: Restart Aegis AdGuard Quadlet
|
||||
- name: Restart Aegis Quadlet services
|
||||
ansible.builtin.systemd:
|
||||
name: "{{ item }}"
|
||||
state: restarted
|
||||
daemon_reload: true
|
||||
loop:
|
||||
- adguardhome.service
|
||||
- icloudpd.service
|
||||
loop_control:
|
||||
label: "{{ item }}"
|
||||
|
||||
@@ -1,99 +1,22 @@
|
||||
---
|
||||
- name: Manage Aegis layered packages
|
||||
tags: [aegis, packages, nfs, wireguard]
|
||||
community.general.rpm_ostree_pkg:
|
||||
name: "{{ aegis_layered_packages }}"
|
||||
state: present
|
||||
register: aegis_layered_packages_result
|
||||
when: aegis_layered_packages | length > 0
|
||||
|
||||
- name: Report reboot required for Aegis layered packages
|
||||
tags: [aegis, packages, nfs, wireguard]
|
||||
ansible.builtin.debug:
|
||||
msg: Reboot Aegis to activate the newly layered packages, then rerun the playbook.
|
||||
when: aegis_layered_packages_result.needs_reboot | default(false)
|
||||
- name: Require Aegis iCloudPD Apple ID
|
||||
tags: [aegis, icloudpd]
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- aegis_icloudpd_apple_id | length > 0
|
||||
fail_msg: Define vault_aegis_icloudpd_apple_id before applying the Aegis profile.
|
||||
no_log: true
|
||||
|
||||
- name: Require completed Aegis network placeholders
|
||||
tags: [aegis, dns, firewall, network, services]
|
||||
tags: [aegis, firewall, services]
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- aegis_lan_subnet != 'CHANGEME_LAN_SUBNET'
|
||||
- aegis_firewalld_zone | length > 0
|
||||
- aegis_adguard_web_port | int > 0
|
||||
- aegis_adguard_web_port | int < 65536
|
||||
- aegis_network_connection_name | length > 0
|
||||
- aegis_network_connection_uuid | length > 0
|
||||
- aegis_host_dns_servers | length > 0
|
||||
- ansible_facts["default_ipv4"]["address"] not in aegis_host_dns_servers
|
||||
- aegis_ssh_allowed_users | length > 0
|
||||
fail_msg: >-
|
||||
Define the Aegis LAN subnet, firewalld zone, AdGuard web port, independent host DNS,
|
||||
NetworkManager connection, and SSH users. Aegis must not use its own address as upstream DNS.
|
||||
|
||||
- name: Verify the declared Aegis NetworkManager connection exists
|
||||
tags: [aegis, dns, network, services]
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- nmcli
|
||||
- --get-values
|
||||
- connection.id
|
||||
- connection
|
||||
- show
|
||||
- uuid
|
||||
- "{{ aegis_network_connection_uuid }}"
|
||||
register: aegis_network_connection
|
||||
changed_when: false
|
||||
failed_when: >-
|
||||
aegis_network_connection.rc != 0
|
||||
or aegis_network_connection.stdout != aegis_network_connection_name
|
||||
|
||||
- name: Read the current Aegis host DNS configuration
|
||||
tags: [aegis, dns, network, services]
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- nmcli
|
||||
- --get-values
|
||||
- ipv4.ignore-auto-dns,ipv4.dns,ipv4.dns-search,ipv6.ignore-auto-dns
|
||||
- connection
|
||||
- show
|
||||
- uuid
|
||||
- "{{ aegis_network_connection_uuid }}"
|
||||
register: aegis_host_dns_current
|
||||
changed_when: false
|
||||
|
||||
- name: Configure independent upstream DNS for the Aegis host
|
||||
tags: [aegis, dns, network, services]
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- nmcli
|
||||
- connection
|
||||
- modify
|
||||
- uuid
|
||||
- "{{ aegis_network_connection_uuid }}"
|
||||
- ipv4.ignore-auto-dns
|
||||
- "yes"
|
||||
- ipv4.dns
|
||||
- "{{ aegis_host_dns_servers | join(',') }}"
|
||||
- ipv4.dns-search
|
||||
- "{{ aegis_host_dns_search_domains | join(',') }}"
|
||||
- ipv6.ignore-auto-dns
|
||||
- "yes"
|
||||
register: aegis_host_dns_profile
|
||||
when: >-
|
||||
aegis_host_dns_current.stdout_lines !=
|
||||
[
|
||||
'yes',
|
||||
aegis_host_dns_servers | join(','),
|
||||
aegis_host_dns_search_domains | join(','),
|
||||
'yes'
|
||||
]
|
||||
changed_when: true
|
||||
|
||||
- name: Report Aegis reboot required for host DNS changes
|
||||
tags: [aegis, dns, network, services]
|
||||
ansible.builtin.debug:
|
||||
msg: Reboot Aegis to activate its independent upstream DNS before testing another OS update.
|
||||
when: aegis_host_dns_profile.changed | default(false)
|
||||
fail_msg: Define the Aegis LAN subnet, firewalld zone, AdGuard web port, and SSH users.
|
||||
|
||||
- name: Set Aegis hostname
|
||||
tags: [aegis, services]
|
||||
@@ -111,6 +34,8 @@
|
||||
loop:
|
||||
- /var/lib/adguard/work
|
||||
- /var/lib/adguard/conf
|
||||
- /var/lib/icloudpd/data
|
||||
- /var/lib/icloudpd/config
|
||||
|
||||
- name: Create Quadlet configuration directory
|
||||
tags: [aegis, containers]
|
||||
@@ -132,9 +57,12 @@
|
||||
loop:
|
||||
- src: adguardhome.container.j2
|
||||
dest: adguardhome.container
|
||||
- src: icloudpd.container.j2
|
||||
dest: icloudpd.container
|
||||
loop_control:
|
||||
label: "{{ item.dest }}"
|
||||
notify: Restart Aegis AdGuard Quadlet
|
||||
no_log: "{{ item.dest == 'icloudpd.container' }}"
|
||||
notify: Restart Aegis Quadlet services
|
||||
|
||||
- name: Create Aegis systemd-resolved configuration directory
|
||||
tags: [aegis, adguard, dns, services]
|
||||
@@ -155,7 +83,7 @@
|
||||
mode: "0644"
|
||||
notify:
|
||||
- Restart Aegis systemd-resolved
|
||||
- Restart Aegis AdGuard Quadlet
|
||||
- Restart Aegis Quadlet services
|
||||
|
||||
- name: Point Aegis resolver at the full systemd-resolved configuration
|
||||
tags: [aegis, adguard, dns, services]
|
||||
@@ -348,7 +276,7 @@
|
||||
group: root
|
||||
mode: "0755"
|
||||
|
||||
- name: Enable Aegis AdGuard Quadlet and automatic updates
|
||||
- name: Enable Aegis Quadlet services and automatic updates
|
||||
tags: [aegis, containers, services]
|
||||
ansible.builtin.systemd:
|
||||
name: "{{ item }}"
|
||||
@@ -357,6 +285,7 @@
|
||||
daemon_reload: true
|
||||
loop:
|
||||
- adguardhome.service
|
||||
- icloudpd.service
|
||||
- podman-auto-update.timer
|
||||
loop_control:
|
||||
label: "{{ item }}"
|
||||
|
||||
20
ansible/roles/profile_aegis/templates/icloudpd.container.j2
Normal file
20
ansible/roles/profile_aegis/templates/icloudpd.container.j2
Normal file
@@ -0,0 +1,20 @@
|
||||
# Managed by Ansible. Do not edit manually.
|
||||
[Unit]
|
||||
Description=iCloud Photos Downloader
|
||||
Wants=network-online.target
|
||||
After=network-online.target
|
||||
|
||||
[Container]
|
||||
Image={{ aegis_icloudpd_image }}
|
||||
Environment=apple_id={{ aegis_icloudpd_apple_id }}
|
||||
Environment=folder_structure={{ aegis_icloudpd_folder_structure }}
|
||||
Environment=synchronisation_interval={{ aegis_icloudpd_synchronisation_interval }}
|
||||
Volume=/var/lib/icloudpd/data:/home/root/iCloud:Z
|
||||
Volume=/var/lib/icloudpd/config:/config:Z
|
||||
AutoUpdate=registry
|
||||
|
||||
[Service]
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -1,38 +1,5 @@
|
||||
---
|
||||
atlas_manage_storage: false
|
||||
atlas_manage_nextcloud: false
|
||||
atlas_nextcloud_root: "{{ atlas_app_data_mountpoint }}/nextcloud"
|
||||
atlas_nextcloud_dataset: "{{ atlas_zfs_pool }}/services/data/nextcloud"
|
||||
atlas_nextcloud_domain: ""
|
||||
atlas_onlyoffice_domain: ""
|
||||
atlas_nextcloud_http_port: 8080
|
||||
atlas_onlyoffice_http_port: 8081
|
||||
atlas_nextcloud_network_subnet: 10.90.10.0/24
|
||||
atlas_nextcloud_network_gateway: 10.90.10.1
|
||||
atlas_nextcloud_quadlet_dir: "{{ atlas_admin_home }}/.config/containers/systemd"
|
||||
atlas_nextcloud_private_dir: "{{ atlas_admin_home }}/.config/atlas-nextcloud"
|
||||
atlas_nextcloud_app_cache: "{{ atlas_admin_home }}/.cache/atlas-nextcloud-apps"
|
||||
atlas_nextcloud_image: ""
|
||||
atlas_nextcloud_postgres_image: ""
|
||||
atlas_nextcloud_redis_image: ""
|
||||
atlas_onlyoffice_image: ""
|
||||
atlas_nextcloud_backup_root: "{{ atlas_mount_root }}/backup/nextcloud"
|
||||
atlas_nextcloud_backup_keep: 2
|
||||
# A structurally complete bundle from an earlier verified run younger than
|
||||
# this many seconds is reused instead of re-preparing. Keep it below 24h so
|
||||
# the nightly Borg run, spaced 24h plus its randomized delay, always refreshes
|
||||
# the bundle; 0 disables reuse.
|
||||
atlas_nextcloud_backup_reuse_max_seconds: 72000
|
||||
atlas_nextcloud_admin: admin
|
||||
atlas_nextcloud_users: []
|
||||
atlas_nextcloud_apps: []
|
||||
# Existing Archive directories; never import into the internal data namespace.
|
||||
atlas_nextcloud_external_mounts: []
|
||||
atlas_nextcloud_services:
|
||||
- atlas-nextcloud-db.service
|
||||
- atlas-nextcloud-redis.service
|
||||
- atlas-nextcloud.service
|
||||
- atlas-onlyoffice.service
|
||||
atlas_manage_sharing: false
|
||||
# Destructive first-boot action; normally false once the pool exists.
|
||||
atlas_create_pool: false
|
||||
@@ -80,160 +47,31 @@ atlas_hardening_sysctls:
|
||||
net.ipv6.conf.all.accept_source_route: "0"
|
||||
net.ipv6.conf.default.accept_source_route: "0"
|
||||
atlas_zfs_pool: CHANGEME_ZFS_POOL
|
||||
atlas_zfs_dataset_work: work
|
||||
atlas_zfs_dataset_archive: archive
|
||||
atlas_zfs_dataset_services: services
|
||||
atlas_zfs_dataset_app_data: services/data
|
||||
atlas_zfs_dataset_navidrome: services/data/navidrome
|
||||
atlas_zfs_dataset_syncthing: services/data/syncthing
|
||||
atlas_zfs_dataset_app_data: archive/app_data
|
||||
atlas_zfs_dataset_navidrome: archive/app_data/navidrome
|
||||
atlas_zfs_dataset_syncthing: archive/app_data/syncthing
|
||||
atlas_zfs_dataset_media: media
|
||||
atlas_zfs_dataset_music: media/music
|
||||
atlas_zfs_dataset_backup: backup
|
||||
atlas_zfs_dataset_host_backups: backup/hosts
|
||||
atlas_zfs_dataset_backup_prometheus: backup/hosts/prometheus
|
||||
atlas_zfs_backup_reservation: 500G
|
||||
atlas_zfs_dataset_backup_prometheus: backup_prometheus
|
||||
atlas_zfs_dataset_photobook: media/photobook
|
||||
atlas_zfs_dataset_backups: backups
|
||||
atlas_zfs_dataset_service_backups: backups/services
|
||||
atlas_zfs_service_backups_refreservation: 500G
|
||||
atlas_mount_root: /CHANGEME_ATLAS_MOUNT_ROOT
|
||||
|
||||
atlas_manage_zfs_snapshots: false
|
||||
atlas_zfs_snapshot_prefix: atlas-auto
|
||||
atlas_zfs_snapshot_policies: []
|
||||
atlas_manage_zfs_scrub: false
|
||||
atlas_zfs_scrub_calendar: ""
|
||||
|
||||
atlas_manage_borg_backup: false
|
||||
atlas_borg_username: borg
|
||||
atlas_borg_group: borg
|
||||
atlas_borg_home: /var/lib/atlas-borg
|
||||
atlas_borg_repository_host: CHANGEME_BORG_HOST
|
||||
atlas_borg_repository_user: CHANGEME_BORG_USER
|
||||
atlas_borg_repository_port: 23
|
||||
atlas_borg_repository_path: ./borg-data
|
||||
atlas_borg_remote_path: borg-1.4
|
||||
atlas_borg_host_key: ""
|
||||
atlas_borg_ssh_private_key_path: /etc/atlas-borg/id_ed25519
|
||||
atlas_borg_known_hosts_path: /etc/atlas-borg/known_hosts
|
||||
atlas_borg_passphrase_path: /etc/atlas-borg/passphrase
|
||||
atlas_borg_ssh_wrapper_path: /usr/local/libexec/atlas-borg-ssh
|
||||
atlas_borg_passphrase: "{{ vault_atlas_borg_passphrase | default('') }}"
|
||||
atlas_borg_encryption_mode: repokey
|
||||
atlas_borg_archive_prefix: atlas
|
||||
atlas_borg_snapshot_prefix: atlas-borg
|
||||
atlas_borg_compression: auto,zstd,3
|
||||
atlas_borg_backup_calendar: ""
|
||||
atlas_borg_check_calendar: ""
|
||||
atlas_borg_randomized_delay: 30m
|
||||
atlas_borg_keep_daily: 30
|
||||
atlas_borg_keep_weekly: 8
|
||||
atlas_borg_keep_monthly: 12
|
||||
atlas_borg_config_dir: /var/lib/atlas-borg
|
||||
atlas_borg_cache_dir: /var/cache/atlas-borg
|
||||
atlas_borg_lock_path: /var/lib/atlas-borg/backup.lock
|
||||
atlas_borg_recovery_export_path: "{{ playbook_dir }}/../secrets/recovery/atlas-borg-repokey.export"
|
||||
|
||||
# Manual-only offline backup. No USB device is formatted or mounted by Ansible.
|
||||
atlas_manage_usb_backup: false
|
||||
atlas_usb_backup_luks_uuid: ""
|
||||
atlas_usb_backup_fs_uuid: ""
|
||||
atlas_usb_backup_mapper_name: atlas-usb-backup
|
||||
atlas_usb_backup_min_free_bytes: 10737418240
|
||||
atlas_usb_backup_snapshot_prefix: atlas-usb
|
||||
atlas_manage_usb_reminder: false
|
||||
atlas_usb_reminder_calendar: ""
|
||||
atlas_usb_reminder_notifier: /opt/45drives/houston/houston-notify
|
||||
|
||||
# Read-only health probes and 45Drives Alerts; disabled outside Atlas host vars.
|
||||
atlas_manage_monitoring: false
|
||||
atlas_monitor_calendar: "*:0/30"
|
||||
atlas_monitor_notifier: "{{ atlas_usb_reminder_notifier }}"
|
||||
atlas_monitor_smart_devices: []
|
||||
atlas_monitor_timers: []
|
||||
atlas_monitor_failure_units: []
|
||||
atlas_monitor_effective_timers: >-
|
||||
{{ atlas_monitor_timers
|
||||
+ ([{'name': 'atlas-prometheus-pull.timer', 'max_age_hours': 26}]
|
||||
if atlas_manage_prometheus_backup_pull | bool and atlas_prometheus_pull_start_timer | bool
|
||||
else []) }}
|
||||
atlas_monitor_effective_failure_units: >-
|
||||
{{ atlas_monitor_failure_units
|
||||
+ (['atlas-prometheus-pull.service']
|
||||
if atlas_manage_prometheus_backup_pull | bool else [])
|
||||
+ (['atlas-nextcloud-backup.service', 'atlas-nextcloud-backup-recovery.service']
|
||||
if atlas_manage_nextcloud | bool else []) }}
|
||||
atlas_monitor_remote_capacity: {}
|
||||
atlas_monitor_pool_warning_percent: 80
|
||||
atlas_monitor_pool_critical_percent: 90
|
||||
atlas_monitor_root_warning_percent: 80
|
||||
atlas_monitor_root_critical_percent: 90
|
||||
atlas_monitor_snapshot_warning_percent: 10
|
||||
atlas_monitor_snapshot_critical_percent: 20
|
||||
atlas_monitor_snapshot_growth_warning_gib_day: 100
|
||||
atlas_monitor_backup_growth_warning_gib_day: 100
|
||||
atlas_monitor_cpu_warning_c: 85
|
||||
atlas_monitor_cpu_critical_c: 95
|
||||
atlas_monitor_borg_max_runtime_days: 14
|
||||
|
||||
# Explicit post-restore relabeling only; never relabel datasets during ordinary runs.
|
||||
atlas_restorecon_paths: []
|
||||
|
||||
atlas_archive_mountpoint: "{{ atlas_mount_root }}/{{ atlas_zfs_dataset_archive }}"
|
||||
atlas_services_mountpoint: "{{ atlas_mount_root }}/{{ atlas_zfs_dataset_services }}"
|
||||
atlas_app_data_mountpoint: "{{ atlas_mount_root }}/{{ atlas_zfs_dataset_app_data }}"
|
||||
atlas_navidrome_mountpoint: "{{ atlas_mount_root }}/{{ atlas_zfs_dataset_navidrome }}"
|
||||
atlas_syncthing_mountpoint: "{{ atlas_mount_root }}/{{ atlas_zfs_dataset_syncthing }}"
|
||||
atlas_media_mountpoint: "{{ atlas_mount_root }}/{{ atlas_zfs_dataset_media }}"
|
||||
atlas_music_mountpoint: "{{ atlas_mount_root }}/{{ atlas_zfs_dataset_music }}"
|
||||
atlas_backup_mountpoint: "{{ atlas_mount_root }}/{{ atlas_zfs_dataset_backup }}"
|
||||
atlas_host_backups_mountpoint: "{{ atlas_mount_root }}/{{ atlas_zfs_dataset_host_backups }}"
|
||||
atlas_work_mountpoint: "{{ atlas_mount_root }}/{{ atlas_zfs_dataset_work }}"
|
||||
atlas_backup_prometheus_mountpoint: "{{ atlas_mount_root }}/{{ atlas_zfs_dataset_backup_prometheus }}"
|
||||
atlas_manage_prometheus_backup_pull: false
|
||||
atlas_prometheus_pull_ssh_dir: /etc/atlas-prometheus-pull
|
||||
atlas_prometheus_pull_private_key_path: "{{ atlas_prometheus_pull_ssh_dir }}/id_ed25519"
|
||||
atlas_prometheus_pull_known_hosts_path: "{{ atlas_prometheus_pull_ssh_dir }}/known_hosts"
|
||||
atlas_prometheus_ssh_host_key: ""
|
||||
atlas_prometheus_pull_source_user: prometheus-backup
|
||||
atlas_prometheus_pull_source_port: 22
|
||||
atlas_prometheus_pull_calendar: "*-*-* 03:00:00 Europe/Rome"
|
||||
atlas_prometheus_pull_start_timer: false
|
||||
atlas_prometheus_pull_keep_daily: 30
|
||||
atlas_prometheus_pull_keep_weekly: 8
|
||||
atlas_prometheus_pull_keep_monthly: 12
|
||||
atlas_prometheus_pull_max_age_hours: 24
|
||||
atlas_photobook_mountpoint: "{{ atlas_mount_root }}/{{ atlas_zfs_dataset_photobook }}"
|
||||
|
||||
# Rootless Gitea runs in admin's user manager; the image maps internal gitea to UID/GID 1000.
|
||||
atlas_manage_gitea: false
|
||||
atlas_gitea_username: "{{ atlas_admin_username }}"
|
||||
atlas_gitea_group: "{{ atlas_admin_group }}"
|
||||
atlas_gitea_uid: "{{ atlas_admin_uid }}"
|
||||
atlas_gitea_gid: "{{ atlas_admin_gid }}"
|
||||
atlas_gitea_home: "{{ atlas_admin_home }}"
|
||||
atlas_gitea_container_uid: 1000
|
||||
atlas_gitea_container_gid: 1000
|
||||
atlas_gitea_legacy_username: gitea
|
||||
atlas_gitea_dataset: "{{ atlas_zfs_pool }}/services/data/gitea"
|
||||
atlas_gitea_mountpoint: "{{ atlas_app_data_mountpoint }}/gitea"
|
||||
atlas_gitea_quadlet_dir: "{{ atlas_gitea_home }}/.config/containers/systemd"
|
||||
atlas_gitea_image: localhost/atlas-gitea:1.25.2-user-gitea-v1
|
||||
atlas_gitea_image_build_dir: "{{ atlas_gitea_home }}/.local/share/atlas-gitea-image"
|
||||
atlas_gitea_production_enabled: false
|
||||
atlas_gitea_public_domain: ""
|
||||
atlas_gitea_bind_address: "{{ ansible_host }}"
|
||||
atlas_gitea_http_port: 3000
|
||||
atlas_gitea_ssh_port: 2222
|
||||
atlas_gitea_staging_bind_address: 127.0.0.1
|
||||
atlas_gitea_staging_http_port: 3001
|
||||
atlas_gitea_staging_ssh_port: 2223
|
||||
|
||||
# Declare storage and an inactive Quadlet only. The operator supplies the
|
||||
# private configuration, handles MFA, and starts the user service manually.
|
||||
atlas_icloudpd_dataset: "{{ atlas_zfs_pool }}/services/data/icloudpd"
|
||||
atlas_icloudpd_state_dir: "{{ atlas_app_data_mountpoint }}/icloudpd"
|
||||
atlas_icloudpd_config_dir: "{{ atlas_icloudpd_state_dir }}/config"
|
||||
atlas_icloudpd_photos_dir: "{{ atlas_archive_mountpoint }}/Pictures/iCloudPD"
|
||||
atlas_icloudpd_image: >-
|
||||
docker.io/boredazfcuk/icloudpd@sha256:9966c31ddf0b5b306ac2410b4edd5d626806d96e80c92b83cbb689972dc9389f
|
||||
atlas_icloudpd_quadlet_dir: "{{ atlas_admin_home }}/.config/containers/systemd"
|
||||
atlas_icloudpd_timezone: Europe/Rome
|
||||
atlas_backups_mountpoint: "{{ atlas_mount_root }}/{{ atlas_zfs_dataset_backups }}"
|
||||
atlas_service_backups_mountpoint: "{{ atlas_mount_root }}/{{ atlas_zfs_dataset_service_backups }}"
|
||||
|
||||
atlas_45drives_repo_url: https://repo.45drives.com/repofiles/rocky/45drives-enterprise.repo
|
||||
atlas_45drives_repo_file: /etc/yum.repos.d/45drives-enterprise.repo
|
||||
@@ -302,58 +140,3 @@ atlas_media_quadlet_services:
|
||||
- atlas-immich-machine-learning.service
|
||||
- atlas-immich-server.service
|
||||
- atlas-npm.service
|
||||
|
||||
atlas_manage_qbittorrent: false
|
||||
atlas_qbittorrent_image: CHANGEME_PINNED_QBITTORRENT_IMAGE
|
||||
atlas_qbittorrent_state_dir: "{{ atlas_app_data_mountpoint }}/qbittorrent"
|
||||
atlas_qbittorrent_downloads_dir: "{{ atlas_archive_mountpoint }}/Downloads"
|
||||
atlas_qbittorrent_web_port: 8090
|
||||
|
||||
atlas_qbittorrent_reverse_proxy_enabled: false
|
||||
atlas_qbittorrent_public_domain: CHANGEME_QBITTORRENT_DOMAIN
|
||||
atlas_qbittorrent_web_settings:
|
||||
- {key: 'WebUI\ServerDomains', value: "{{ atlas_qbittorrent_public_domain }}"}
|
||||
- {key: 'WebUI\ReverseProxySupportEnabled', value: "true"}
|
||||
- {key: 'WebUI\TrustedReverseProxiesList', value: "{{ atlas_aegis_ip }}"}
|
||||
- {key: 'WebUI\HostHeaderValidation', value: "true"}
|
||||
- {key: 'WebUI\CSRFProtection', value: "true"}
|
||||
- {key: 'WebUI\LocalHostAuth', value: "true"}
|
||||
- {key: 'WebUI\AuthSubnetWhitelistEnabled', value: "false"}
|
||||
|
||||
atlas_manage_aria2: false
|
||||
atlas_aria2_gateway_enabled: false
|
||||
atlas_aria2_gateway_port: 8092
|
||||
atlas_aria2_public_domain: CHANGEME_ARIA2_DOMAIN
|
||||
atlas_aria2_state_dir: "{{ atlas_app_data_mountpoint }}/aria2"
|
||||
atlas_aria2_downloads_dir: "{{ atlas_archive_mountpoint }}/Downloads"
|
||||
atlas_aria2_rpc_port: 6800
|
||||
atlas_ariang_web_port: 8091
|
||||
atlas_aria2_image: CHANGEME_PINNED_ARIA2_IMAGE
|
||||
atlas_ariang_image: CHANGEME_PINNED_ARIANG_IMAGE
|
||||
|
||||
# Rootless Paperless-ngx document management. Secrets live only in the encrypted Vault.
|
||||
atlas_manage_paperless: false
|
||||
atlas_paperless_dataset: "{{ atlas_zfs_pool }}/services/data/paperless"
|
||||
atlas_paperless_root: "{{ atlas_app_data_mountpoint }}/paperless"
|
||||
atlas_paperless_private_dir: "{{ atlas_admin_home }}/.config/atlas-paperless"
|
||||
atlas_paperless_quadlet_dir: "{{ atlas_admin_home }}/.config/containers/systemd"
|
||||
atlas_paperless_domain: ""
|
||||
atlas_paperless_http_port: 8002
|
||||
atlas_paperless_network_subnet: 10.90.11.0/24
|
||||
atlas_paperless_network_gateway: 10.90.11.1
|
||||
atlas_paperless_ocr_language: ita+eng
|
||||
atlas_paperless_image: ""
|
||||
atlas_paperless_postgres_image: ""
|
||||
atlas_paperless_valkey_image: ""
|
||||
atlas_paperless_tika_image: ""
|
||||
atlas_paperless_gotenberg_image: ""
|
||||
atlas_paperless_ollama_image: ""
|
||||
atlas_paperless_llm_model: qwen2.5:1.5b-instruct-q4_K_M
|
||||
atlas_paperless_embedding_model: nomic-embed-text:v1.5
|
||||
atlas_paperless_services:
|
||||
- atlas-paperless-db.service
|
||||
- atlas-paperless-valkey.service
|
||||
- atlas-paperless-tika.service
|
||||
- atlas-paperless-gotenberg.service
|
||||
- atlas-paperless-ollama.service
|
||||
- atlas-paperless.service
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
FROM docker.gitea.com/gitea@sha256:f1943db2d2f1e447e857b3f0aee4ebb7b184500f86e5b80eae110fd435435906
|
||||
|
||||
# Preserve the official image's UID/GID, paths and entrypoint; change only the
|
||||
# internal Unix identity. The host-side rootless owner is Atlas admin.
|
||||
USER 0
|
||||
RUN sed -i 's/^git:x:1000:1000:/gitea:x:1000:1000:/' /etc/passwd \
|
||||
&& sed -i 's/^git:x:1000:/gitea:x:1000:/' /etc/group \
|
||||
&& grep -q '^gitea:x:1000:1000:' /etc/passwd \
|
||||
&& grep -q '^gitea:x:1000:' /etc/group
|
||||
USER 1000:1000
|
||||
@@ -1,131 +0,0 @@
|
||||
#!/usr/bin/python3
|
||||
"""Private NPM-only JSON-RPC adapter. Never serves the secret to browsers."""
|
||||
import argparse
|
||||
import copy
|
||||
import http.client
|
||||
import json
|
||||
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
||||
from pathlib import Path
|
||||
import threading
|
||||
|
||||
MAX_BODY = 2 * 1024 * 1024
|
||||
|
||||
|
||||
def inject(request, token, depth=0):
|
||||
if depth > 4 or not isinstance(request, dict):
|
||||
raise ValueError('Invalid RPC request')
|
||||
result = copy.deepcopy(request)
|
||||
method = result.get('method', result.get('methodName'))
|
||||
params = result.setdefault('params', [])
|
||||
if not isinstance(method, str) or not isinstance(params, list):
|
||||
raise ValueError('Invalid RPC method or params')
|
||||
if method == 'system.multicall':
|
||||
if len(params) != 1 or not isinstance(params[0], list) or len(params[0]) > 128:
|
||||
raise ValueError('Invalid multicall')
|
||||
result['params'] = [[inject(item, token, depth + 1) for item in params[0]]]
|
||||
elif method.startswith('aria2.'):
|
||||
if params and isinstance(params[0], str) and params[0].startswith('token:'):
|
||||
params.pop(0)
|
||||
# Keep RPC security configuration owned by Ansible, not remote callers.
|
||||
if method in ('aria2.changeGlobalOption', 'aria2.changeOption'):
|
||||
for value in params:
|
||||
if isinstance(value, dict) and any(key.startswith('rpc-') for key in value):
|
||||
raise ValueError('RPC security options are not editable')
|
||||
params.insert(0, 'token:' + token)
|
||||
elif method not in ('system.listMethods', 'system.listNotifications'):
|
||||
raise ValueError('Unsupported RPC method')
|
||||
return result
|
||||
|
||||
|
||||
def sanitize(value, token):
|
||||
if isinstance(value, dict):
|
||||
return {key: sanitize(item, token) for key, item in value.items()
|
||||
if key not in ('rpc-secret', 'rpc-passwd', 'rpc-user')}
|
||||
if isinstance(value, list):
|
||||
return [sanitize(item, token) for item in value]
|
||||
if isinstance(value, str):
|
||||
return value.replace(token, '[redacted]')
|
||||
return value
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--listen', required=True)
|
||||
parser.add_argument('--port', type=int, required=True)
|
||||
parser.add_argument('--upstream-port', type=int, required=True)
|
||||
parser.add_argument('--peer', required=True)
|
||||
parser.add_argument('--domain', required=True)
|
||||
parser.add_argument('--secret-file', required=True)
|
||||
args = parser.parse_args()
|
||||
token = Path(args.secret_file).read_text().strip()
|
||||
if len(token) != 64 or any(char not in '0123456789abcdef' for char in token):
|
||||
raise ValueError('Invalid private RPC secret')
|
||||
slots = threading.BoundedSemaphore(16)
|
||||
|
||||
class Handler(BaseHTTPRequestHandler):
|
||||
def setup(self):
|
||||
super().setup()
|
||||
self.connection.settimeout(15)
|
||||
|
||||
def log_message(self, *_):
|
||||
pass # No credentials, download URLs or request payloads in logs.
|
||||
|
||||
def reply(self, status, value):
|
||||
body = json.dumps(value).encode()
|
||||
self.send_response(status)
|
||||
self.send_header('Content-Type', 'application/json')
|
||||
self.send_header('Cache-Control', 'no-store')
|
||||
self.send_header('Content-Length', str(len(body)))
|
||||
self.end_headers()
|
||||
self.wfile.write(body)
|
||||
|
||||
def do_POST(self):
|
||||
if self.client_address[0] not in (args.peer, args.listen):
|
||||
return self.reply(403, {'error': 'Forbidden'})
|
||||
if self.path != '/jsonrpc' or self.headers.get('Host') not in (args.domain, args.domain + ':443'):
|
||||
return self.reply(403, {'error': 'Forbidden'})
|
||||
origin = self.headers.get('Origin')
|
||||
if origin and origin != 'https://' + args.domain:
|
||||
return self.reply(403, {'error': 'Forbidden origin'})
|
||||
if self.headers.get('Transfer-Encoding') or self.headers.get('Content-Type', '').split(';')[0].strip() not in ('application/json', 'application/json-rpc'):
|
||||
return self.reply(415, {'error': 'JSON POST required'})
|
||||
if not slots.acquire(blocking=False):
|
||||
return self.reply(503, {'error': 'Busy'})
|
||||
connection = None
|
||||
try:
|
||||
length = int(self.headers.get('Content-Length', '0'))
|
||||
if not 0 < length <= MAX_BODY:
|
||||
return self.reply(413, {'error': 'Invalid request size'})
|
||||
request = json.loads(self.rfile.read(length))
|
||||
if isinstance(request, list):
|
||||
if not 0 < len(request) <= 128:
|
||||
raise ValueError('Invalid batch')
|
||||
request = [inject(item, token) for item in request]
|
||||
else:
|
||||
request = inject(request, token)
|
||||
body = json.dumps(request).encode()
|
||||
if len(body) > MAX_BODY:
|
||||
return self.reply(413, {'error': 'Request too large'})
|
||||
connection = http.client.HTTPConnection(args.listen, args.upstream_port, timeout=30)
|
||||
connection.request('POST', '/jsonrpc', body, {'Content-Type': 'application/json'})
|
||||
response = connection.getresponse()
|
||||
payload = response.read(MAX_BODY + 1)
|
||||
if len(payload) > MAX_BODY:
|
||||
return self.reply(502, {'error': 'Upstream response too large'})
|
||||
self.reply(response.status, sanitize(json.loads(payload), token))
|
||||
except (ValueError, TypeError, KeyError):
|
||||
self.reply(400, {'error': 'Invalid RPC request'})
|
||||
except (OSError, http.client.HTTPException):
|
||||
self.reply(502, {'error': 'RPC upstream unavailable'})
|
||||
finally:
|
||||
if connection:
|
||||
connection.close()
|
||||
slots.release()
|
||||
|
||||
server = ThreadingHTTPServer((args.listen, args.port), Handler)
|
||||
server.daemon_threads = True
|
||||
server.serve_forever()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -1,59 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Turn Borg's JSON progress stream into bounded, readable journal entries."""
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import sys
|
||||
import time
|
||||
|
||||
|
||||
def size(value):
|
||||
if not isinstance(value, (int, float)):
|
||||
return "unknown"
|
||||
return f"{value / (1024 ** 3):.2f} GiB"
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--estimated-total-bytes", type=int, required=True)
|
||||
args = parser.parse_args()
|
||||
if args.estimated_total_bytes <= 0:
|
||||
parser.error("estimated total must be positive")
|
||||
|
||||
last_progress = 0.0
|
||||
for line in sys.stdin:
|
||||
try:
|
||||
event = json.loads(line)
|
||||
except json.JSONDecodeError:
|
||||
print(line.rstrip(), flush=True)
|
||||
continue
|
||||
|
||||
kind = event.get("type")
|
||||
if kind == "archive_progress":
|
||||
now = time.monotonic()
|
||||
if now - last_progress < 60 and not event.get("finished"):
|
||||
continue
|
||||
path = event.get("path") or ""
|
||||
parts = path.split("/")
|
||||
dataset = parts[1] if len(parts) > 1 and parts[0] == "source" else "unknown"
|
||||
original_size = event.get("original_size")
|
||||
if isinstance(original_size, (int, float)) and original_size >= 0:
|
||||
percent = original_size / args.estimated_total_bytes * 100
|
||||
estimated_progress = (
|
||||
f"{percent:.1f}%" if percent < 100 else ">=100% (ZFS estimate exceeded)"
|
||||
)
|
||||
else:
|
||||
estimated_progress = "unknown"
|
||||
print(
|
||||
"Borg create progress: "
|
||||
f"estimated={estimated_progress} dataset={dataset} "
|
||||
f"files={event.get('nfiles', 'unknown')} "
|
||||
f"original={size(original_size)} "
|
||||
f"compressed={size(event.get('compressed_size'))} "
|
||||
f"deduplicated={size(event.get('deduplicated_size'))}",
|
||||
flush=True,
|
||||
)
|
||||
last_progress = now
|
||||
elif kind == "log_message":
|
||||
print(f"Borg {event.get('levelname', 'INFO')}: {event.get('message', '')}", flush=True)
|
||||
elif kind == "progress_message" and event.get("message"):
|
||||
print(f"Borg: {event['message']}", flush=True)
|
||||
@@ -1,396 +0,0 @@
|
||||
#!/usr/bin/python3
|
||||
"""Read-only Atlas health probes with deduplicated 45Drives Alerts."""
|
||||
|
||||
import argparse
|
||||
import fcntl
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import time
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
CONFIG_PATH = Path("/etc/atlas-health-monitor.json")
|
||||
STATE_DIR = Path("/var/lib/atlas-health-monitor")
|
||||
STATE_PATH = STATE_DIR / "state.json"
|
||||
GIB = 1024**3
|
||||
|
||||
|
||||
def run(*argv, timeout=40):
|
||||
return subprocess.run(argv, capture_output=True, text=True, timeout=timeout, check=False)
|
||||
|
||||
|
||||
def issue(issues, key, severity, message):
|
||||
issues[key] = {"severity": severity, "message": message}
|
||||
|
||||
|
||||
def notify(config, event, severity, subject, message):
|
||||
now = datetime.now(timezone.utc)
|
||||
payload = {
|
||||
"timestamp": now.isoformat(timespec="seconds"),
|
||||
"unixtime": int(now.timestamp()),
|
||||
"event": event,
|
||||
"severity": severity,
|
||||
"subject": subject,
|
||||
"email_message": message,
|
||||
}
|
||||
result = run(config["notifier"], json.dumps(payload, ensure_ascii=False), timeout=30)
|
||||
if result.returncode:
|
||||
raise RuntimeError(f"45Drives notifier exited {result.returncode}: {result.stderr.strip()}")
|
||||
|
||||
|
||||
def parse_fields(text):
|
||||
return dict(line.split("=", 1) for line in text.splitlines() if "=" in line)
|
||||
|
||||
|
||||
def systemd_fields(unit, *properties):
|
||||
result = run("systemctl", "show", unit, *(f"-p{item}" for item in properties))
|
||||
if result.returncode:
|
||||
raise RuntimeError(f"systemctl show {unit} exited {result.returncode}")
|
||||
return parse_fields(result.stdout)
|
||||
|
||||
|
||||
def unix_time(text):
|
||||
if not text or text == "n/a":
|
||||
return None
|
||||
result = run("date", "-d", text, "+%s")
|
||||
if result.returncode:
|
||||
raise ValueError(f"Cannot parse systemd timestamp: {text}")
|
||||
return int(result.stdout.strip())
|
||||
|
||||
|
||||
def check_pool(config, issues, measurements):
|
||||
pool = config["pool"]
|
||||
listing = run("zpool", "list", "-H", "-p", "-o", "size,alloc,capacity,health", pool)
|
||||
if listing.returncode:
|
||||
issue(issues, "pool.probe", "critical", f"Cannot query ZFS pool {pool}")
|
||||
return
|
||||
try:
|
||||
size, alloc, capacity, health = listing.stdout.strip().split("\t")
|
||||
size, alloc, capacity = int(size), int(alloc), int(capacity)
|
||||
except (ValueError, TypeError):
|
||||
issue(issues, "pool.probe", "critical", "Invalid ZFS pool capacity response")
|
||||
return
|
||||
measurements.update(pool_size_bytes=size, pool_alloc_bytes=alloc, pool_capacity_percent=capacity)
|
||||
if health != "ONLINE":
|
||||
issue(issues, "pool.health", "critical", f"ZFS pool {pool} state is {health}")
|
||||
if capacity >= config["pool_critical_percent"]:
|
||||
issue(issues, "pool.capacity", "critical", f"ZFS pool {pool} is {capacity}% full")
|
||||
elif capacity >= config["pool_warning_percent"]:
|
||||
issue(issues, "pool.capacity", "warning", f"ZFS pool {pool} is {capacity}% full")
|
||||
|
||||
status = run("zpool", "status", "-P", pool)
|
||||
if status.returncode:
|
||||
issue(issues, "pool.status", "critical", f"Cannot query detailed ZFS status for {pool}")
|
||||
return
|
||||
bad_vdevs = []
|
||||
for line in status.stdout.splitlines():
|
||||
match = re.match(r"^\s*(\S+)\s+(ONLINE|DEGRADED|FAULTED|OFFLINE|UNAVAIL|REMOVED)\s+(\d+)\s+(\d+)\s+(\d+)", line)
|
||||
if match:
|
||||
name, state, reads, writes, checksums = match.groups()
|
||||
if state != "ONLINE" or any(int(value) for value in (reads, writes, checksums)):
|
||||
bad_vdevs.append(f"{name}: {state}, READ={reads}, WRITE={writes}, CKSUM={checksums}")
|
||||
if bad_vdevs:
|
||||
issue(issues, "pool.vdevs", "critical", "ZFS vdev errors: " + "; ".join(bad_vdevs))
|
||||
errors = re.search(r"^errors:\s*(.*)$", status.stdout, re.MULTILINE)
|
||||
if not errors or errors.group(1).strip() != "No known data errors":
|
||||
issue(issues, "pool.data_errors", "critical", "ZFS status reports data errors; inspect zpool status -v")
|
||||
if re.search(r"^\s*scan:\s*resilver in progress", status.stdout, re.MULTILINE | re.IGNORECASE):
|
||||
issue(issues, "pool.resilver", "warning", "ZFS resilver is in progress; inspect zpool status")
|
||||
scan = re.search(r"^\s*scan:\s*(.*)$", status.stdout, re.MULTILINE)
|
||||
if scan and re.search(r"\bwith [1-9][0-9]* errors\b", scan.group(1)):
|
||||
issue(issues, "pool.scan_errors", "critical", f"ZFS scan reported errors: {scan.group(1)}")
|
||||
|
||||
|
||||
def check_capacity(config, issues, measurements):
|
||||
pool = config["pool"]
|
||||
listing = run("zfs", "list", "-H", "-p", "-o", "name,usedbysnapshots", "-r", pool)
|
||||
if listing.returncode:
|
||||
issue(issues, "snapshot.probe", "warning", "Cannot query ZFS snapshot space")
|
||||
else:
|
||||
try:
|
||||
snapshots = sum(int(line.split("\t")[1]) for line in listing.stdout.splitlines())
|
||||
measurements["snapshots_bytes"] = snapshots
|
||||
size = measurements.get("pool_size_bytes")
|
||||
if size:
|
||||
percent = snapshots * 100 // size
|
||||
measurements["snapshots_percent"] = percent
|
||||
if percent >= config["snapshot_critical_percent"]:
|
||||
issue(issues, "snapshot.capacity", "critical", f"Snapshots use {percent}% of pool size")
|
||||
elif percent >= config["snapshot_warning_percent"]:
|
||||
issue(issues, "snapshot.capacity", "warning", f"Snapshots use {percent}% of pool size")
|
||||
except (ValueError, IndexError):
|
||||
issue(issues, "snapshot.probe", "warning", "Invalid ZFS snapshot-space response")
|
||||
backup = run("zfs", "list", "-H", "-p", "-o", "used", config["backup_dataset"])
|
||||
if backup.returncode:
|
||||
issue(issues, "backup.capacity_probe", "warning", "Cannot query local backup dataset space")
|
||||
else:
|
||||
try:
|
||||
measurements["backup_bytes"] = int(backup.stdout.strip())
|
||||
except ValueError:
|
||||
issue(issues, "backup.capacity_probe", "warning", "Invalid local backup space response")
|
||||
|
||||
try:
|
||||
filesystem = os.statvfs("/")
|
||||
total = filesystem.f_blocks * filesystem.f_frsize
|
||||
available = filesystem.f_bavail * filesystem.f_frsize
|
||||
used_percent = (total - available) * 100 // total
|
||||
measurements["root_capacity_percent"] = used_percent
|
||||
if used_percent >= config["root_critical_percent"]:
|
||||
issue(issues, "root.capacity", "critical", f"Atlas system filesystem is {used_percent}% full")
|
||||
elif used_percent >= config["root_warning_percent"]:
|
||||
issue(issues, "root.capacity", "warning", f"Atlas system filesystem is {used_percent}% full")
|
||||
except (OSError, ZeroDivisionError):
|
||||
issue(issues, "root.capacity_probe", "warning", "Cannot query Atlas system filesystem space")
|
||||
|
||||
|
||||
def check_remote_capacity(config, issues, measurements):
|
||||
"""Query only the Storage Box quota; do not open or inspect the Borg repository."""
|
||||
remote = config["remote_capacity"]
|
||||
try:
|
||||
result = run("runuser", "-u", remote["run_as"], "--", remote["ssh_wrapper"],
|
||||
f"{remote['user']}@{remote['host']}", "df", "-m", timeout=65)
|
||||
if result.returncode:
|
||||
raise ValueError(f"SSH df exited {result.returncode}")
|
||||
lines = result.stdout.strip().splitlines()
|
||||
if len(lines) != 2:
|
||||
raise ValueError("Unexpected Storage Box df output")
|
||||
fields = lines[1].split()
|
||||
if len(fields) < 5:
|
||||
raise ValueError("Incomplete Storage Box df output")
|
||||
total_mib, used_mib, available_mib = (int(value) for value in fields[1:4])
|
||||
percent = int(fields[4].rstrip("%"))
|
||||
if total_mib <= 0 or not 0 <= percent <= 100 or available_mib < 0:
|
||||
raise ValueError("Invalid Storage Box quota values")
|
||||
except (OSError, ValueError, subprocess.TimeoutExpired):
|
||||
issue(issues, "remote.capacity_probe", "warning", "Cannot query Hetzner Storage Box quota via pinned-key SSH")
|
||||
return
|
||||
measurements.update(remote_capacity_percent=percent, remote_bytes=used_mib * 1024**2,
|
||||
remote_available_bytes=available_mib * 1024**2)
|
||||
if percent >= remote["critical_percent"]:
|
||||
issue(issues, "remote.capacity", "critical", f"Hetzner Storage Box quota is {percent}% full")
|
||||
elif percent >= remote["warning_percent"]:
|
||||
issue(issues, "remote.capacity", "warning", f"Hetzner Storage Box quota is {percent}% full")
|
||||
|
||||
|
||||
def check_smart(config, issues, measurements):
|
||||
for device in config["smart_devices"]:
|
||||
name, path = device["name"], device["path"]
|
||||
try:
|
||||
result = run("smartctl", "-j", "-a", path, timeout=60)
|
||||
data = json.loads(result.stdout)
|
||||
status = int(data.get("smartctl", {}).get("exit_status", result.returncode))
|
||||
except (subprocess.TimeoutExpired, json.JSONDecodeError, ValueError) as exc:
|
||||
issue(issues, f"smart.{name}.probe", "critical", f"SMART probe failed for {name}: {type(exc).__name__}")
|
||||
continue
|
||||
if status:
|
||||
severity = "critical" if status & 0b00001111 else "warning"
|
||||
issue(issues, f"smart.{name}.status", severity, f"SMART reported exit status {status} for {name}")
|
||||
passed = data.get("smart_status", {}).get("passed")
|
||||
if passed is False:
|
||||
issue(issues, f"smart.{name}.health", "critical", f"SMART self-assessment failed for {name}")
|
||||
elif passed is None:
|
||||
issue(issues, f"smart.{name}.health", "warning", f"SMART self-assessment unavailable for {name}")
|
||||
temperature = data.get("temperature", {}).get("current")
|
||||
if isinstance(temperature, (int, float)):
|
||||
measurements[f"smart_{name}_c"] = temperature
|
||||
if temperature >= device["critical_c"]:
|
||||
issue(issues, f"smart.{name}.temperature", "critical", f"{name} temperature is {temperature} C")
|
||||
elif temperature >= device["warning_c"]:
|
||||
issue(issues, f"smart.{name}.temperature", "warning", f"{name} temperature is {temperature} C")
|
||||
else:
|
||||
issue(issues, f"smart.{name}.temperature", "warning", f"Temperature unavailable for {name}")
|
||||
for attribute in data.get("ata_smart_attributes", {}).get("table", []):
|
||||
attribute_id = attribute.get("id")
|
||||
if attribute_id in (5, 187, 197, 198):
|
||||
raw = attribute.get("raw", {}).get("value", 0)
|
||||
if isinstance(raw, int) and raw > 0:
|
||||
severity = "critical" if attribute_id in (197, 198) else "warning"
|
||||
issue(issues, f"smart.{name}.ata_{attribute_id}", severity,
|
||||
f"{name} SMART attribute {attribute_id} raw count is {raw}")
|
||||
nvme = data.get("nvme_smart_health_information_log", {})
|
||||
if isinstance(nvme, dict):
|
||||
if int(nvme.get("critical_warning", 0)):
|
||||
issue(issues, f"smart.{name}.nvme_warning", "critical", f"{name} NVMe critical warning is nonzero")
|
||||
if int(nvme.get("media_errors", 0)):
|
||||
issue(issues, f"smart.{name}.nvme_media", "critical", f"{name} NVMe media errors are nonzero")
|
||||
|
||||
|
||||
def check_cpu(config, issues, measurements):
|
||||
sensors = []
|
||||
for hwmon in Path("/sys/class/hwmon").glob("hwmon*"):
|
||||
try:
|
||||
if (hwmon / "name").read_text().strip() != "coretemp":
|
||||
continue
|
||||
sensors.extend(int(path.read_text().strip()) / 1000 for path in hwmon.glob("temp*_input"))
|
||||
except (OSError, ValueError):
|
||||
continue
|
||||
if not sensors:
|
||||
issue(issues, "cpu.temperature_probe", "warning", "CPU temperature sensors are unavailable")
|
||||
return
|
||||
hottest = max(sensors)
|
||||
measurements["cpu_max_c"] = hottest
|
||||
if hottest >= config["cpu_critical_c"]:
|
||||
issue(issues, "cpu.temperature", "critical", f"CPU temperature is {hottest:g} C")
|
||||
elif hottest >= config["cpu_warning_c"]:
|
||||
issue(issues, "cpu.temperature", "warning", f"CPU temperature is {hottest:g} C")
|
||||
|
||||
|
||||
def check_jobs(config, issues, measurements, now):
|
||||
for timer in config["timers"]:
|
||||
name = timer["name"]
|
||||
try:
|
||||
fields = systemd_fields(name, "ActiveState", "UnitFileState", "LastTriggerUSec", "ActiveEnterTimestamp")
|
||||
if fields.get("ActiveState") != "active" or fields.get("UnitFileState") != "enabled":
|
||||
issue(issues, f"timer.{name}", "critical", f"Timer {name} is not active and enabled")
|
||||
max_age = int(timer["max_age_hours"]) * 3600
|
||||
if max_age:
|
||||
last = unix_time(fields.get("LastTriggerUSec"))
|
||||
if last is None:
|
||||
last = unix_time(fields.get("ActiveEnterTimestamp"))
|
||||
if last is not None and now - last > max_age:
|
||||
issue(issues, f"timer.{name}.stale", "warning",
|
||||
f"Timer {name} has not fired in {int((now-last)/3600)} hours")
|
||||
except (RuntimeError, ValueError, subprocess.TimeoutExpired):
|
||||
issue(issues, f"timer.{name}.probe", "warning", f"Cannot query timer {name}")
|
||||
for unit in config["failure_units"]:
|
||||
if unit.endswith("@.service"):
|
||||
continue
|
||||
try:
|
||||
fields = systemd_fields(unit, "ActiveState", "Result", "ExecMainStartTimestamp")
|
||||
state = fields.get("ActiveState")
|
||||
if state == "failed" or (state == "inactive" and fields.get("Result") not in (None, "", "success")):
|
||||
issue(issues, f"service.{unit}", "critical", f"Service {unit} failed: {fields.get('Result')}")
|
||||
if unit == "atlas-borg-backup.service" and fields.get("ActiveState") == "activating":
|
||||
started = unix_time(fields.get("ExecMainStartTimestamp"))
|
||||
if started is not None and now - started > config["borg_max_runtime_days"] * 86400:
|
||||
issue(issues, "backup.borg_long_running", "warning",
|
||||
"Borg has run longer than its configured limit")
|
||||
except (RuntimeError, ValueError, subprocess.TimeoutExpired):
|
||||
issue(issues, f"service.{unit}.probe", "warning", f"Cannot query service {unit}")
|
||||
|
||||
|
||||
def check_growth(config, issues, measurements, samples, now):
|
||||
previous = [sample for sample in samples if 20 * 3600 <= now - sample.get("time", now) <= 48 * 3600]
|
||||
if previous:
|
||||
baseline = min(previous, key=lambda sample: abs(now - sample["time"] - 86400))
|
||||
days = (now - baseline["time"]) / 86400
|
||||
for name, threshold in (("snapshots", config["snapshot_growth_warning_gib_day"]),
|
||||
("backup", config["backup_growth_warning_gib_day"]),
|
||||
("remote", config["remote_capacity"]["growth_warning_gib_day"])):
|
||||
current, old = measurements.get(f"{name}_bytes"), baseline.get(f"{name}_bytes")
|
||||
if isinstance(current, int) and isinstance(old, int) and days > 0:
|
||||
growth_gib_day = (current - old) / GIB / days
|
||||
measurements[f"{name}_growth_gib_day"] = round(growth_gib_day, 1)
|
||||
if growth_gib_day >= threshold:
|
||||
issue(issues, f"{name}.growth", "warning",
|
||||
f"Local {name} usage grew {growth_gib_day:.1f} GiB/day over {days:.1f} days")
|
||||
|
||||
|
||||
def allowed_failure_unit(config, unit):
|
||||
for allowed in config["failure_units"]:
|
||||
if allowed == unit:
|
||||
return True
|
||||
if allowed.endswith("@.service") and unit.startswith(allowed[:-9] + "@") and unit.endswith(".service"):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def load_state():
|
||||
if not STATE_PATH.exists():
|
||||
return {"active": {}, "samples": []}
|
||||
with STATE_PATH.open(encoding="utf-8") as stream:
|
||||
state = json.load(stream)
|
||||
if not isinstance(state.get("active"), dict) or not isinstance(state.get("samples"), list):
|
||||
raise ValueError("Invalid Atlas monitor state; refusing to overwrite it")
|
||||
return state
|
||||
|
||||
|
||||
def save_state(state):
|
||||
with tempfile.NamedTemporaryFile("w", dir=STATE_DIR, prefix=".state-", delete=False,
|
||||
encoding="utf-8") as stream:
|
||||
path = Path(stream.name)
|
||||
os.chmod(path, 0o600)
|
||||
json.dump(state, stream, sort_keys=True)
|
||||
stream.write("\n")
|
||||
stream.flush()
|
||||
os.fsync(stream.fileno())
|
||||
os.replace(path, STATE_PATH)
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--dry-run", action="store_true", help="probe without notifications or state changes")
|
||||
parser.add_argument("--test-notification", action="store_true", help="submit a labelled test alert")
|
||||
parser.add_argument("--job-failed", metavar="UNIT", help="notify about a failed configured service")
|
||||
args = parser.parse_args()
|
||||
with CONFIG_PATH.open(encoding="utf-8") as stream:
|
||||
config = json.load(stream)
|
||||
if args.test_notification:
|
||||
notify(config, "atlas_monitor_test", "warning", "Test monitoraggio Atlas",
|
||||
"Notifica di prova: il monitoraggio Atlas raggiunge 45Drives Alerts. Non conferma l'invio email.")
|
||||
print("Atlas monitor test submitted to 45Drives Alerts; email delivery is not verified.")
|
||||
return 0
|
||||
if args.job_failed:
|
||||
if not allowed_failure_unit(config, args.job_failed):
|
||||
raise ValueError("Unconfigured Atlas failure unit")
|
||||
notify(config, "atlas_job_failed", "critical", f"Job Atlas fallito: {args.job_failed}",
|
||||
f"Il servizio {args.job_failed} e' fallito. Controlla: "
|
||||
f"sudo journalctl -u {args.job_failed} -n 100 --no-pager")
|
||||
print(f"Atlas job failure submitted to 45Drives Alerts: {args.job_failed}")
|
||||
return 0
|
||||
|
||||
now = int(time.time())
|
||||
issues, measurements = {}, {}
|
||||
check_pool(config, issues, measurements)
|
||||
check_capacity(config, issues, measurements)
|
||||
check_remote_capacity(config, issues, measurements)
|
||||
check_smart(config, issues, measurements)
|
||||
check_cpu(config, issues, measurements)
|
||||
check_jobs(config, issues, measurements, now)
|
||||
if args.dry_run:
|
||||
print(json.dumps({"issues": issues, "measurements": measurements}, sort_keys=True))
|
||||
return 0
|
||||
|
||||
STATE_DIR.mkdir(mode=0o700, exist_ok=True)
|
||||
with (STATE_DIR / "monitor.lock").open("w") as lock:
|
||||
fcntl.flock(lock, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||
state = load_state()
|
||||
check_growth(config, issues, measurements, state["samples"], now)
|
||||
active, failed_notifications = state["active"], []
|
||||
for key, details in issues.items():
|
||||
old = active.get(key)
|
||||
if old is None or old.get("severity") != details["severity"]:
|
||||
try:
|
||||
notify(config, "atlas_health_issue", details["severity"],
|
||||
f"Atlas: {key}", details["message"])
|
||||
active[key] = details
|
||||
print(f"ALERT {details['severity']} {key}: {details['message']}", flush=True)
|
||||
except (RuntimeError, subprocess.TimeoutExpired) as exc:
|
||||
failed_notifications.append(key)
|
||||
print(f"NOTIFICATION FAILED {key}: {exc}", file=sys.stderr, flush=True)
|
||||
for key in set(active) - set(issues):
|
||||
print(f"RECOVERED {key}", flush=True)
|
||||
del active[key]
|
||||
state["samples"] = [sample for sample in state["samples"] if now - sample.get("time", 0) < 48 * 3600]
|
||||
state["samples"].append({"time": now, **{key: value for key, value in measurements.items()
|
||||
if key in ("snapshots_bytes", "backup_bytes", "remote_bytes")}})
|
||||
save_state(state)
|
||||
print(f"Atlas health: issues={len(issues)} notifications_failed={len(failed_notifications)} "
|
||||
f"pool={measurements.get('pool_capacity_percent', 'unknown')}% "
|
||||
f"remote={measurements.get('remote_capacity_percent', 'unknown')}% "
|
||||
f"snapshots={measurements.get('snapshots_bytes', 'unknown')} bytes "
|
||||
f"backup={measurements.get('backup_bytes', 'unknown')} bytes", flush=True)
|
||||
return 1 if failed_notifications else 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
sys.exit(main())
|
||||
except (OSError, RuntimeError, ValueError, subprocess.TimeoutExpired) as error:
|
||||
print(f"Atlas health monitor failed: {error}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
@@ -1,56 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Prune only verified, named Prometheus backup versions after publication."""
|
||||
|
||||
import datetime as dt
|
||||
import pathlib
|
||||
import re
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
|
||||
def main() -> None:
|
||||
if len(sys.argv) != 5:
|
||||
raise SystemExit("Usage: atlas-prometheus-prune SNAPSHOTS DAILY WEEKLY MONTHLY")
|
||||
root = pathlib.Path(sys.argv[1])
|
||||
counts = [int(value) for value in sys.argv[2:]]
|
||||
if not root.is_dir() or root.is_symlink() or min(counts) < 1:
|
||||
raise SystemExit("Invalid backup directory or retention counts")
|
||||
versions = []
|
||||
for entry in root.iterdir():
|
||||
if not entry.is_dir() or entry.is_symlink():
|
||||
continue
|
||||
if not re.fullmatch(r"[0-9]{8}T[0-9]{6}Z", entry.name):
|
||||
continue
|
||||
try:
|
||||
when = dt.datetime.strptime(entry.name, "%Y%m%dT%H%M%SZ")
|
||||
except ValueError:
|
||||
continue
|
||||
if not all((entry / name).is_file() for name in ("payload.tar", "payload.sha256", "metadata.json")):
|
||||
continue
|
||||
versions.append((when, entry))
|
||||
versions.sort(reverse=True)
|
||||
if not versions:
|
||||
raise SystemExit("No published backup versions found; refusing to prune")
|
||||
|
||||
keep = {entry for _, entry in versions[: counts[0]]}
|
||||
for count, key in (
|
||||
(counts[1], lambda when: when.isocalendar()[:2]),
|
||||
(counts[2], lambda when: (when.year, when.month)),
|
||||
):
|
||||
periods = set()
|
||||
for when, entry in versions:
|
||||
period = key(when)
|
||||
if period in periods:
|
||||
continue
|
||||
periods.add(period)
|
||||
keep.add(entry)
|
||||
if len(periods) >= count:
|
||||
break
|
||||
|
||||
for _, entry in versions:
|
||||
if entry not in keep:
|
||||
shutil.rmtree(entry)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1,14 +1,4 @@
|
||||
---
|
||||
- name: Reload Atlas admin user manager
|
||||
become_user: "{{ atlas_admin_username }}"
|
||||
ansible.builtin.systemd:
|
||||
scope: user
|
||||
daemon_reload: true
|
||||
environment:
|
||||
XDG_RUNTIME_DIR: "/run/user/{{ atlas_admin_uid }}"
|
||||
DBUS_SESSION_BUS_ADDRESS: "unix:path=/run/user/{{ atlas_admin_uid }}/bus"
|
||||
when: not ansible_check_mode
|
||||
|
||||
- name: Reload SSH service
|
||||
ansible.builtin.systemd:
|
||||
name: sshd
|
||||
@@ -38,18 +28,6 @@
|
||||
name: smb
|
||||
state: restarted
|
||||
|
||||
- name: Restart Atlas Borg timers
|
||||
ansible.builtin.systemd:
|
||||
name: "{{ item }}"
|
||||
state: restarted
|
||||
daemon_reload: true
|
||||
loop:
|
||||
- atlas-borg-backup.timer
|
||||
- atlas-borg-check.timer
|
||||
when:
|
||||
- atlas_manage_borg_backup | bool
|
||||
- not ansible_check_mode
|
||||
|
||||
- name: Restart Atlas media Quadlets
|
||||
ansible.builtin.systemd:
|
||||
name: "{{ item }}"
|
||||
|
||||
@@ -1,205 +0,0 @@
|
||||
---
|
||||
- name: Manage Atlas LAN HTTP downloader
|
||||
tags: [atlas, aria2]
|
||||
when: atlas_manage_aria2 | bool
|
||||
block:
|
||||
- name: Require isolated state, shared Downloads and pinned images
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- atlas_manage_storage | bool
|
||||
- atlas_aria2_state_dir == atlas_app_data_mountpoint ~ '/aria2'
|
||||
- atlas_aria2_downloads_dir == atlas_archive_mountpoint ~ '/Downloads'
|
||||
- atlas_aria2_image is search('@sha256:[0-9a-f]{64}$')
|
||||
- atlas_ariang_image is search('@sha256:[0-9a-f]{64}$')
|
||||
- atlas_aria2_rpc_port != atlas_ariang_web_port
|
||||
|
||||
- name: Inspect the existing downloader parent datasets
|
||||
community.general.zfs_facts:
|
||||
name: "{{ item.dataset }}"
|
||||
properties: name,mounted,mountpoint
|
||||
loop:
|
||||
- dataset: "{{ atlas_zfs_pool }}/{{ atlas_zfs_dataset_archive }}"
|
||||
mountpoint: "{{ atlas_archive_mountpoint }}"
|
||||
- dataset: "{{ atlas_zfs_pool }}/{{ atlas_zfs_dataset_app_data }}"
|
||||
mountpoint: "{{ atlas_app_data_mountpoint }}"
|
||||
register: atlas_aria2_parents
|
||||
|
||||
- name: Require mounted downloader parent datasets
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- item.ansible_facts.ansible_zfs_datasets | length == 1
|
||||
- item.ansible_facts.ansible_zfs_datasets[0].mounted == 'yes'
|
||||
- item.ansible_facts.ansible_zfs_datasets[0].mountpoint == item.item.mountpoint
|
||||
loop: "{{ atlas_aria2_parents.results }}"
|
||||
loop_control:
|
||||
label: "{{ item.item.dataset }}"
|
||||
|
||||
- name: Inspect shared Downloads without following links
|
||||
ansible.builtin.stat:
|
||||
path: "{{ atlas_aria2_downloads_dir }}"
|
||||
follow: false
|
||||
register: atlas_aria2_downloads
|
||||
|
||||
- name: Refuse unrelated or symlinked Downloads
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- >-
|
||||
not atlas_aria2_downloads.stat.exists or
|
||||
(atlas_aria2_downloads.stat.isdir | default(false) and
|
||||
atlas_aria2_downloads.stat.uid | int == atlas_admin_uid | int)
|
||||
|
||||
- name: Create the private aria2 dataset
|
||||
community.general.zfs:
|
||||
name: "{{ atlas_zfs_pool }}/services/data/aria2"
|
||||
state: present
|
||||
extra_zfs_properties:
|
||||
compression: zstd
|
||||
mountpoint: "{{ atlas_aria2_state_dir }}"
|
||||
|
||||
- name: Prepare state, downloads and Quadlet directories
|
||||
ansible.builtin.file:
|
||||
path: "{{ item.path }}"
|
||||
state: directory
|
||||
owner: "{{ atlas_admin_username }}"
|
||||
group: "{{ atlas_admin_group }}"
|
||||
mode: "{{ item.mode }}"
|
||||
loop:
|
||||
- {path: "{{ atlas_aria2_state_dir }}", mode: "0700"}
|
||||
- {path: "{{ atlas_aria2_downloads_dir }}", mode: "0770"}
|
||||
- {path: "{{ atlas_admin_home }}/.config/containers/systemd", mode: "0700"}
|
||||
|
||||
- name: Generate a private persistent RPC secret on Atlas only
|
||||
become_user: "{{ atlas_admin_username }}"
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- python3
|
||||
- -c
|
||||
- >-
|
||||
import os, secrets;
|
||||
fd = os.open('{{ atlas_aria2_state_dir }}/rpc-secret',
|
||||
os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0o600);
|
||||
os.write(fd, (secrets.token_hex(32) + '\n').encode()); os.close(fd)
|
||||
creates: "{{ atlas_aria2_state_dir }}/rpc-secret"
|
||||
no_log: true
|
||||
|
||||
- name: Read the existing private RPC secret without displaying it
|
||||
ansible.builtin.slurp:
|
||||
src: "{{ atlas_aria2_state_dir }}/rpc-secret"
|
||||
register: atlas_aria2_rpc_secret
|
||||
no_log: true
|
||||
when: not ansible_check_mode
|
||||
|
||||
- name: Require a strong RPC secret
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- atlas_aria2_rpc_secret.content | b64decode | trim is match('^[a-f0-9]{64}$')
|
||||
no_log: true
|
||||
when: not ansible_check_mode
|
||||
|
||||
- name: Initialize the session file without replacing saved downloads
|
||||
ansible.builtin.copy:
|
||||
content: ""
|
||||
dest: "{{ atlas_aria2_state_dir }}/session"
|
||||
owner: "{{ atlas_admin_username }}"
|
||||
group: "{{ atlas_admin_group }}"
|
||||
mode: "0600"
|
||||
force: false
|
||||
diff: false
|
||||
no_log: true
|
||||
|
||||
- name: Render private aria2 configuration
|
||||
ansible.builtin.template:
|
||||
src: atlas-aria2.conf.j2
|
||||
dest: "{{ atlas_aria2_state_dir }}/aria2.conf"
|
||||
owner: "{{ atlas_admin_username }}"
|
||||
group: "{{ atlas_admin_group }}"
|
||||
mode: "0600"
|
||||
register: atlas_aria2_config
|
||||
no_log: true
|
||||
diff: false
|
||||
when: not ansible_check_mode
|
||||
|
||||
- name: Allow only the LAN to reach AriaNg and the token-protected API
|
||||
ansible.posix.firewalld:
|
||||
zone: "{{ atlas_firewalld_zone }}"
|
||||
rich_rule: >-
|
||||
rule family="ipv4" source address="{{ atlas_lan_subnet }}"
|
||||
port port="{{ item }}" protocol="tcp" accept
|
||||
permanent: true
|
||||
immediate: true
|
||||
state: enabled
|
||||
loop:
|
||||
- "{{ atlas_aria2_rpc_port }}"
|
||||
- "{{ atlas_ariang_web_port }}"
|
||||
|
||||
- name: Keep the downloader user manager available at boot
|
||||
ansible.builtin.command: "loginctl enable-linger {{ atlas_admin_username }}"
|
||||
args:
|
||||
creates: "/var/lib/systemd/linger/{{ atlas_admin_username }}"
|
||||
|
||||
- name: Render the downloader and static Web UI Quadlets
|
||||
ansible.builtin.template:
|
||||
src: "atlas-{{ item }}.container.j2"
|
||||
dest: "{{ atlas_admin_home }}/.config/containers/systemd/atlas-{{ item }}.container"
|
||||
owner: "{{ atlas_admin_username }}"
|
||||
group: "{{ atlas_admin_group }}"
|
||||
mode: "0644"
|
||||
loop: [aria2, ariang]
|
||||
register: atlas_aria2_quadlets
|
||||
|
||||
- name: Reload the user manager after downloader Quadlet changes
|
||||
become_user: "{{ atlas_admin_username }}"
|
||||
ansible.builtin.systemd:
|
||||
scope: user
|
||||
daemon_reload: true
|
||||
environment:
|
||||
XDG_RUNTIME_DIR: "/run/user/{{ atlas_admin_uid }}"
|
||||
DBUS_SESSION_BUS_ADDRESS: "unix:path=/run/user/{{ atlas_admin_uid }}/bus"
|
||||
when:
|
||||
- atlas_aria2_quadlets.changed
|
||||
- not ansible_check_mode
|
||||
|
||||
- name: Start or update only the changed downloader service
|
||||
become_user: "{{ atlas_admin_username }}"
|
||||
ansible.builtin.systemd:
|
||||
scope: user
|
||||
name: "atlas-{{ item.item }}.service"
|
||||
state: >-
|
||||
{{ 'restarted' if item.changed or
|
||||
(item.item == 'aria2' and atlas_aria2_config.changed | default(false))
|
||||
else 'started' }}
|
||||
loop: "{{ atlas_aria2_quadlets.results }}"
|
||||
loop_control:
|
||||
label: "atlas-{{ item.item }}.service"
|
||||
environment:
|
||||
XDG_RUNTIME_DIR: "/run/user/{{ atlas_admin_uid }}"
|
||||
DBUS_SESSION_BUS_ADDRESS: "unix:path=/run/user/{{ atlas_admin_uid }}/bus"
|
||||
when: not ansible_check_mode
|
||||
|
||||
- name: Verify the LAN Web UI responds
|
||||
ansible.builtin.uri:
|
||||
url: "http://{{ ansible_host }}:{{ atlas_ariang_web_port }}/"
|
||||
status_code: 200
|
||||
register: atlas_ariang_http
|
||||
retries: 15
|
||||
delay: 2
|
||||
until: atlas_ariang_http is succeeded
|
||||
when: not ansible_check_mode
|
||||
|
||||
- name: Verify the authenticated RPC API
|
||||
ansible.builtin.uri:
|
||||
url: "http://{{ ansible_host }}:{{ atlas_aria2_rpc_port }}/jsonrpc"
|
||||
method: POST
|
||||
body_format: json
|
||||
body:
|
||||
jsonrpc: "2.0"
|
||||
id: ansible
|
||||
method: aria2.getVersion
|
||||
params: ["token:{{ atlas_aria2_rpc_secret.content | b64decode | trim }}"]
|
||||
return_content: true
|
||||
register: atlas_aria2_rpc_probe
|
||||
retries: 15
|
||||
delay: 2
|
||||
until: (atlas_aria2_rpc_probe.content | default('{}') | from_json).result.version is defined
|
||||
no_log: true
|
||||
when: not ansible_check_mode
|
||||
@@ -1,81 +0,0 @@
|
||||
---
|
||||
- name: Manage the private NPM aria2 adapter
|
||||
tags: [atlas, aria2_gateway]
|
||||
when:
|
||||
- atlas_manage_aria2 | bool
|
||||
- atlas_aria2_gateway_enabled | bool
|
||||
block:
|
||||
- name: Require a dedicated gateway and explicit public domain
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- atlas_aria2_gateway_port not in [atlas_aria2_rpc_port, atlas_ariang_web_port]
|
||||
- atlas_aria2_public_domain is match('^[a-z0-9][a-z0-9.-]+[.][a-z]{2,}$')
|
||||
- not atlas_aria2_public_domain.startswith('CHANGEME')
|
||||
|
||||
- name: Install the private JSON-RPC adapter
|
||||
ansible.builtin.copy:
|
||||
src: atlas-aria2-rpc-gateway.py
|
||||
dest: "{{ atlas_aria2_state_dir }}/rpc-gateway.py"
|
||||
owner: "{{ atlas_admin_username }}"
|
||||
group: "{{ atlas_admin_group }}"
|
||||
mode: "0600"
|
||||
register: atlas_aria2_gateway_script
|
||||
|
||||
- name: Prepare the user unit directory
|
||||
ansible.builtin.file:
|
||||
path: "{{ atlas_admin_home }}/.config/systemd/user"
|
||||
state: directory
|
||||
owner: "{{ atlas_admin_username }}"
|
||||
group: "{{ atlas_admin_group }}"
|
||||
mode: "0700"
|
||||
|
||||
- name: Install the user gateway unit
|
||||
ansible.builtin.template:
|
||||
src: atlas-aria2-gateway.service.j2
|
||||
dest: "{{ atlas_admin_home }}/.config/systemd/user/atlas-aria2-gateway.service"
|
||||
owner: "{{ atlas_admin_username }}"
|
||||
group: "{{ atlas_admin_group }}"
|
||||
mode: "0644"
|
||||
register: atlas_aria2_gateway_unit
|
||||
|
||||
- name: Allow only Aegis to reach the credential-injecting adapter
|
||||
ansible.posix.firewalld:
|
||||
zone: "{{ atlas_firewalld_zone }}"
|
||||
rich_rule: >-
|
||||
rule family="ipv4" source address="{{ atlas_aegis_ip }}"
|
||||
port port="{{ atlas_aria2_gateway_port }}" protocol="tcp" accept
|
||||
permanent: true
|
||||
immediate: true
|
||||
state: enabled
|
||||
|
||||
- name: Enable and start the private gateway
|
||||
become_user: "{{ atlas_admin_username }}"
|
||||
ansible.builtin.systemd_service:
|
||||
scope: user
|
||||
name: atlas-aria2-gateway.service
|
||||
daemon_reload: "{{ atlas_aria2_gateway_unit.changed }}"
|
||||
enabled: true
|
||||
state: "{{ 'restarted' if atlas_aria2_gateway_script.changed or atlas_aria2_gateway_unit.changed else 'started' }}"
|
||||
environment:
|
||||
XDG_RUNTIME_DIR: "/run/user/{{ atlas_admin_uid }}"
|
||||
DBUS_SESSION_BUS_ADDRESS: "unix:path=/run/user/{{ atlas_admin_uid }}/bus"
|
||||
when: not ansible_check_mode
|
||||
|
||||
- name: Verify token-free requests through the private adapter
|
||||
ansible.builtin.uri:
|
||||
url: "http://{{ ansible_host }}:{{ atlas_aria2_gateway_port }}/jsonrpc"
|
||||
headers:
|
||||
Host: "{{ atlas_aria2_public_domain }}"
|
||||
method: POST
|
||||
body_format: json
|
||||
body:
|
||||
jsonrpc: "2.0"
|
||||
id: ansible-gateway
|
||||
method: aria2.getVersion
|
||||
params: []
|
||||
return_content: true
|
||||
register: atlas_aria2_gateway_probe
|
||||
retries: 10
|
||||
delay: 2
|
||||
until: atlas_aria2_gateway_probe.json.result.version is defined
|
||||
when: not ansible_check_mode
|
||||
@@ -1,538 +0,0 @@
|
||||
---
|
||||
- name: Validate Atlas Borg backup configuration
|
||||
tags: [atlas, storage, backup, borg, borg_key]
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- atlas_manage_storage | bool
|
||||
- atlas_zfs_pool != 'CHANGEME_ZFS_POOL'
|
||||
- atlas_mount_root.startswith('/')
|
||||
- atlas_borg_username is match('^[a-z_][a-z0-9_-]*$')
|
||||
- atlas_borg_group is match('^[a-z_][a-z0-9_-]*$')
|
||||
- atlas_borg_username not in ['root', atlas_admin_username]
|
||||
- atlas_borg_group != 'wheel'
|
||||
- atlas_borg_home.startswith('/var/lib/')
|
||||
- atlas_borg_repository_host is match('^[A-Za-z0-9.-]+$')
|
||||
- atlas_borg_repository_user is match('^[A-Za-z0-9_-]+$')
|
||||
- atlas_borg_repository_port | int > 0
|
||||
- atlas_borg_repository_port | int < 65536
|
||||
- atlas_borg_repository_path is match('^\./[A-Za-z0-9][A-Za-z0-9._/-]*$')
|
||||
- "'/../' not in ('/' ~ atlas_borg_repository_path ~ '/')"
|
||||
- atlas_borg_remote_path is match('^borg-[0-9]+\.[0-9]+$')
|
||||
- atlas_borg_host_key.startswith(
|
||||
'[' ~ atlas_borg_repository_host ~ ']:' ~ (atlas_borg_repository_port | string) ~ ' ssh-ed25519 '
|
||||
)
|
||||
- atlas_borg_ssh_private_key_path.startswith('/etc/atlas-borg/')
|
||||
- atlas_borg_known_hosts_path.startswith('/etc/atlas-borg/')
|
||||
- atlas_borg_passphrase_path.startswith('/etc/atlas-borg/')
|
||||
- atlas_borg_ssh_wrapper_path.startswith('/usr/local/libexec/')
|
||||
- atlas_borg_encryption_mode == 'repokey'
|
||||
- atlas_borg_archive_prefix is match('^[a-z0-9][a-z0-9_-]*$')
|
||||
- atlas_borg_snapshot_prefix is match('^[a-z0-9][a-z0-9_-]*$')
|
||||
- atlas_borg_keep_daily | int > 0
|
||||
- atlas_borg_keep_weekly | int > 0
|
||||
- atlas_borg_keep_monthly | int > 0
|
||||
fail_msg: >-
|
||||
Atlas Borg needs a safe relative repository path, a pinned ED25519 host
|
||||
key, positive retention counts, and valid dedicated SSH settings.
|
||||
when: atlas_manage_borg_backup | bool
|
||||
|
||||
- name: Create the Atlas Borg system group
|
||||
tags: [atlas, storage, backup, borg, borg_key]
|
||||
ansible.builtin.group:
|
||||
name: "{{ atlas_borg_group }}"
|
||||
system: true
|
||||
state: present
|
||||
when: atlas_manage_borg_backup | bool
|
||||
|
||||
- name: Create the least-privilege Atlas Borg account
|
||||
tags: [atlas, storage, backup, borg, borg_key]
|
||||
ansible.builtin.user:
|
||||
name: "{{ atlas_borg_username }}"
|
||||
group: "{{ atlas_borg_group }}"
|
||||
groups: []
|
||||
append: false
|
||||
comment: Atlas Borg backup service
|
||||
home: "{{ atlas_borg_home }}"
|
||||
create_home: false
|
||||
shell: /sbin/nologin
|
||||
password_lock: true
|
||||
system: true
|
||||
state: present
|
||||
when: atlas_manage_borg_backup | bool
|
||||
|
||||
- name: Read Atlas Borg account group membership
|
||||
tags: [atlas, storage, backup, borg, borg_key]
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- id
|
||||
- -nG
|
||||
- "{{ atlas_borg_username }}"
|
||||
register: atlas_borg_account_groups
|
||||
changed_when: false
|
||||
check_mode: false
|
||||
when:
|
||||
- atlas_manage_borg_backup | bool
|
||||
- not ansible_check_mode
|
||||
|
||||
- name: Require the Atlas Borg account to have no supplementary groups
|
||||
tags: [atlas, storage, backup, borg, borg_key]
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- atlas_borg_account_groups.stdout.split() == [atlas_borg_group]
|
||||
fail_msg: >-
|
||||
The Atlas Borg service account must belong only to its private primary
|
||||
group and must never receive wheel or other supplementary membership.
|
||||
when:
|
||||
- atlas_manage_borg_backup | bool
|
||||
- not ansible_check_mode
|
||||
|
||||
- name: Validate Atlas Borg systemd calendars
|
||||
tags: [atlas, storage, backup, borg]
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- systemd-analyze
|
||||
- calendar
|
||||
- "{{ item }}"
|
||||
loop:
|
||||
- "{{ atlas_borg_backup_calendar }}"
|
||||
- "{{ atlas_borg_check_calendar }}"
|
||||
changed_when: false
|
||||
check_mode: false
|
||||
when: atlas_manage_borg_backup | bool
|
||||
|
||||
- name: Create Atlas Borg configuration directory
|
||||
tags: [atlas, storage, backup, borg, borg_key]
|
||||
ansible.builtin.file:
|
||||
path: /etc/atlas-borg
|
||||
state: directory
|
||||
owner: root
|
||||
group: "{{ atlas_borg_group }}"
|
||||
mode: "0750"
|
||||
when: atlas_manage_borg_backup | bool
|
||||
|
||||
- name: Generate the dedicated Atlas Borg SSH identity
|
||||
tags: [atlas, storage, backup, borg, borg_key]
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- ssh-keygen
|
||||
- -q
|
||||
- -t
|
||||
- ed25519
|
||||
- -N
|
||||
- ""
|
||||
- -C
|
||||
- atlas-borg@atlas
|
||||
- -f
|
||||
- "{{ atlas_borg_ssh_private_key_path }}"
|
||||
creates: "{{ atlas_borg_ssh_private_key_path }}"
|
||||
when: atlas_manage_borg_backup | bool
|
||||
|
||||
- name: Protect the Atlas Borg private SSH identity
|
||||
tags: [atlas, storage, backup, borg, borg_key]
|
||||
ansible.builtin.file:
|
||||
path: "{{ atlas_borg_ssh_private_key_path }}"
|
||||
owner: "{{ atlas_borg_username }}"
|
||||
group: "{{ atlas_borg_group }}"
|
||||
mode: "0600"
|
||||
when:
|
||||
- atlas_manage_borg_backup | bool
|
||||
- not ansible_check_mode
|
||||
|
||||
- name: Set permissions on the Atlas Borg public SSH identity
|
||||
tags: [atlas, storage, backup, borg, borg_key]
|
||||
ansible.builtin.file:
|
||||
path: "{{ atlas_borg_ssh_private_key_path }}.pub"
|
||||
owner: "{{ atlas_borg_username }}"
|
||||
group: "{{ atlas_borg_group }}"
|
||||
mode: "0644"
|
||||
when:
|
||||
- atlas_manage_borg_backup | bool
|
||||
- not ansible_check_mode
|
||||
|
||||
- name: Read the dedicated Atlas Borg public SSH identity
|
||||
tags: [atlas, storage, backup, borg, borg_key]
|
||||
ansible.builtin.slurp:
|
||||
src: "{{ atlas_borg_ssh_private_key_path }}.pub"
|
||||
register: atlas_borg_public_key
|
||||
when:
|
||||
- atlas_manage_borg_backup | bool
|
||||
- not ansible_check_mode
|
||||
|
||||
- name: Report the public SSH identity to install in the Hetzner sub-account
|
||||
tags: [atlas, storage, backup, borg, borg_key]
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ atlas_borg_public_key.content | b64decode | trim }}"
|
||||
when:
|
||||
- atlas_manage_borg_backup | bool
|
||||
- not ansible_check_mode
|
||||
|
||||
- name: Pin the Hetzner Storage Box SSH host key
|
||||
tags: [atlas, storage, backup, borg]
|
||||
ansible.builtin.copy:
|
||||
content: "{{ atlas_borg_host_key }}\n"
|
||||
dest: "{{ atlas_borg_known_hosts_path }}"
|
||||
owner: "{{ atlas_borg_username }}"
|
||||
group: "{{ atlas_borg_group }}"
|
||||
mode: "0600"
|
||||
when: atlas_manage_borg_backup | bool
|
||||
|
||||
- name: Create Atlas Borg state directories
|
||||
tags: [atlas, storage, backup, borg]
|
||||
ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
owner: "{{ atlas_borg_username }}"
|
||||
group: "{{ atlas_borg_group }}"
|
||||
mode: "0700"
|
||||
loop:
|
||||
- "{{ atlas_borg_config_dir }}"
|
||||
- "{{ atlas_borg_cache_dir }}"
|
||||
when: atlas_manage_borg_backup | bool
|
||||
|
||||
- name: Create the shared Atlas Borg operation lock
|
||||
tags: [atlas, storage, backup, borg]
|
||||
ansible.builtin.copy:
|
||||
content: ""
|
||||
dest: "{{ atlas_borg_lock_path }}"
|
||||
owner: "{{ atlas_borg_username }}"
|
||||
group: "{{ atlas_borg_group }}"
|
||||
mode: "0600"
|
||||
force: false
|
||||
when: atlas_manage_borg_backup | bool
|
||||
|
||||
- name: Require the Atlas Borg encryption passphrase from Vault
|
||||
tags: [atlas, storage, backup, borg]
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- atlas_borg_passphrase | length >= 20
|
||||
fail_msg: >-
|
||||
Define vault_atlas_borg_passphrase with a strong unique value in the
|
||||
encrypted Vault before activating the Borg repository.
|
||||
no_log: true
|
||||
when: atlas_manage_borg_backup | bool
|
||||
|
||||
- name: Install the Atlas Borg passphrase
|
||||
tags: [atlas, storage, backup, borg]
|
||||
ansible.builtin.copy:
|
||||
content: "{{ atlas_borg_passphrase }}\n"
|
||||
dest: "{{ atlas_borg_passphrase_path }}"
|
||||
owner: "{{ atlas_borg_username }}"
|
||||
group: "{{ atlas_borg_group }}"
|
||||
mode: "0600"
|
||||
diff: false
|
||||
no_log: true
|
||||
when: atlas_manage_borg_backup | bool
|
||||
|
||||
- name: Install the Atlas Borg backup helper
|
||||
tags: [atlas, storage, backup, borg, borg_logging]
|
||||
ansible.builtin.template:
|
||||
src: atlas-borg-backup.sh.j2
|
||||
dest: /usr/local/sbin/atlas-borg-backup
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0750"
|
||||
when: atlas_manage_borg_backup | bool
|
||||
|
||||
- name: Install the Atlas Borg snapshot cleanup helper
|
||||
tags: [atlas, storage, backup, borg, borg_logging]
|
||||
ansible.builtin.template:
|
||||
src: atlas-borg-snapshot-cleanup.sh.j2
|
||||
dest: /usr/local/sbin/atlas-borg-snapshot-cleanup
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0750"
|
||||
when: atlas_manage_borg_backup | bool
|
||||
|
||||
- name: Install the Atlas Borg check helper
|
||||
tags: [atlas, storage, backup, borg]
|
||||
ansible.builtin.template:
|
||||
src: atlas-borg-check.sh.j2
|
||||
dest: /usr/local/sbin/atlas-borg-check
|
||||
owner: root
|
||||
group: "{{ atlas_borg_group }}"
|
||||
mode: "0750"
|
||||
when: atlas_manage_borg_backup | bool
|
||||
|
||||
- name: Create the local libexec directory for the Atlas Borg SSH wrapper
|
||||
tags: [atlas, storage, backup, borg, borg_logging]
|
||||
ansible.builtin.file:
|
||||
path: "{{ atlas_borg_ssh_wrapper_path | dirname }}"
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0755"
|
||||
when: atlas_manage_borg_backup | bool
|
||||
|
||||
- name: Install the Atlas Borg progress formatter
|
||||
tags: [atlas, storage, backup, borg, borg_logging]
|
||||
ansible.builtin.copy:
|
||||
src: atlas-borg-progress.py
|
||||
dest: /usr/local/libexec/atlas-borg-progress
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0755"
|
||||
when: atlas_manage_borg_backup | bool
|
||||
|
||||
- name: Install the capability-dropping Atlas Borg SSH wrapper
|
||||
tags: [atlas, storage, backup, borg]
|
||||
ansible.builtin.template:
|
||||
src: atlas-borg-ssh.sh.j2
|
||||
dest: "{{ atlas_borg_ssh_wrapper_path }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0755"
|
||||
when: atlas_manage_borg_backup | bool
|
||||
|
||||
- name: Install Atlas Borg systemd units
|
||||
tags: [atlas, storage, backup, borg, borg_logging]
|
||||
ansible.builtin.template:
|
||||
src: "{{ item }}.j2"
|
||||
dest: "/etc/systemd/system/{{ item }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
loop:
|
||||
- atlas-borg-backup.service
|
||||
- atlas-borg-backup.timer
|
||||
- atlas-borg-check.service
|
||||
- atlas-borg-check.timer
|
||||
notify: Restart Atlas Borg timers
|
||||
when: atlas_manage_borg_backup | bool
|
||||
|
||||
- name: Verify dedicated SSH access to the Hetzner Storage Box
|
||||
tags: [atlas, storage, backup, borg]
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- ssh
|
||||
- -T
|
||||
- -i
|
||||
- "{{ atlas_borg_ssh_private_key_path }}"
|
||||
- -p
|
||||
- "{{ atlas_borg_repository_port | string }}"
|
||||
- -o
|
||||
- BatchMode=yes
|
||||
- -o
|
||||
- IdentitiesOnly=yes
|
||||
- -o
|
||||
- StrictHostKeyChecking=yes
|
||||
- -o
|
||||
- "UserKnownHostsFile={{ atlas_borg_known_hosts_path }}"
|
||||
- "{{ atlas_borg_repository_user }}@{{ atlas_borg_repository_host }}"
|
||||
- pwd
|
||||
register: atlas_borg_ssh_probe
|
||||
become: true
|
||||
become_user: "{{ atlas_borg_username }}"
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
when:
|
||||
- atlas_manage_borg_backup | bool
|
||||
- not ansible_check_mode
|
||||
|
||||
- name: Require the dedicated public key on the Hetzner sub-account
|
||||
tags: [atlas, storage, backup, borg]
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- atlas_borg_ssh_probe.rc == 0
|
||||
fail_msg: >-
|
||||
Install the reported Atlas Borg public key in the Hetzner sub-account
|
||||
before rerunning the Borg tasks. Password authentication is never used.
|
||||
when:
|
||||
- atlas_manage_borg_backup | bool
|
||||
- not ansible_check_mode
|
||||
|
||||
- name: Probe the remote Atlas Borg repository path
|
||||
tags: [atlas, storage, backup, borg]
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- ssh
|
||||
- -T
|
||||
- -i
|
||||
- "{{ atlas_borg_ssh_private_key_path }}"
|
||||
- -p
|
||||
- "{{ atlas_borg_repository_port | string }}"
|
||||
- -o
|
||||
- BatchMode=yes
|
||||
- -o
|
||||
- IdentitiesOnly=yes
|
||||
- -o
|
||||
- StrictHostKeyChecking=yes
|
||||
- -o
|
||||
- "UserKnownHostsFile={{ atlas_borg_known_hosts_path }}"
|
||||
- "{{ atlas_borg_repository_user }}@{{ atlas_borg_repository_host }}"
|
||||
- stat
|
||||
- "{{ atlas_borg_repository_path }}"
|
||||
register: atlas_borg_repository_path_probe
|
||||
become: true
|
||||
become_user: "{{ atlas_borg_username }}"
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
when:
|
||||
- atlas_manage_borg_backup | bool
|
||||
- not ansible_check_mode
|
||||
|
||||
- name: Probe the Atlas Borg repository
|
||||
tags: [atlas, storage, backup, borg]
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- /usr/bin/borg
|
||||
- --remote-path
|
||||
- "{{ atlas_borg_remote_path }}"
|
||||
- info
|
||||
- >-
|
||||
ssh://{{ atlas_borg_repository_user }}@{{ atlas_borg_repository_host }}:
|
||||
{{- atlas_borg_repository_port }}/{{ atlas_borg_repository_path }}
|
||||
environment:
|
||||
BORG_CACHE_DIR: "{{ atlas_borg_cache_dir }}"
|
||||
BORG_CONFIG_DIR: "{{ atlas_borg_config_dir }}"
|
||||
BORG_PASSCOMMAND: "cat {{ atlas_borg_passphrase_path }}"
|
||||
BORG_RSH: "{{ atlas_borg_ssh_wrapper_path }}"
|
||||
register: atlas_borg_repository_probe
|
||||
become: true
|
||||
become_user: "{{ atlas_borg_username }}"
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
when:
|
||||
- atlas_manage_borg_backup | bool
|
||||
- not ansible_check_mode
|
||||
- atlas_borg_repository_path_probe.rc == 0
|
||||
|
||||
- name: Reject an existing path that is not the configured Borg repository
|
||||
tags: [atlas, storage, backup, borg]
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- atlas_borg_repository_probe.rc == 0
|
||||
fail_msg: >-
|
||||
The remote repository path already exists but Borg could not open it.
|
||||
Refusing to initialize over existing data; verify the path, passphrase,
|
||||
and repository state manually.
|
||||
when:
|
||||
- atlas_manage_borg_backup | bool
|
||||
- not ansible_check_mode
|
||||
- atlas_borg_repository_path_probe.rc == 0
|
||||
|
||||
- name: Initialize the encrypted Atlas Borg repository
|
||||
tags: [atlas, storage, backup, borg]
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- /usr/bin/borg
|
||||
- --remote-path
|
||||
- "{{ atlas_borg_remote_path }}"
|
||||
- init
|
||||
- --encryption
|
||||
- "{{ atlas_borg_encryption_mode }}"
|
||||
- >-
|
||||
ssh://{{ atlas_borg_repository_user }}@{{ atlas_borg_repository_host }}:
|
||||
{{- atlas_borg_repository_port }}/{{ atlas_borg_repository_path }}
|
||||
environment:
|
||||
BORG_CACHE_DIR: "{{ atlas_borg_cache_dir }}"
|
||||
BORG_CONFIG_DIR: "{{ atlas_borg_config_dir }}"
|
||||
BORG_PASSCOMMAND: "cat {{ atlas_borg_passphrase_path }}"
|
||||
BORG_RSH: "{{ atlas_borg_ssh_wrapper_path }}"
|
||||
become: true
|
||||
become_user: "{{ atlas_borg_username }}"
|
||||
when:
|
||||
- atlas_manage_borg_backup | bool
|
||||
- not ansible_check_mode
|
||||
- atlas_borg_repository_path_probe.rc != 0
|
||||
|
||||
- name: Verify the encrypted Atlas Borg repository
|
||||
tags: [atlas, storage, backup, borg]
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- /usr/bin/borg
|
||||
- --remote-path
|
||||
- "{{ atlas_borg_remote_path }}"
|
||||
- info
|
||||
- >-
|
||||
ssh://{{ atlas_borg_repository_user }}@{{ atlas_borg_repository_host }}:
|
||||
{{- atlas_borg_repository_port }}/{{ atlas_borg_repository_path }}
|
||||
environment:
|
||||
BORG_CACHE_DIR: "{{ atlas_borg_cache_dir }}"
|
||||
BORG_CONFIG_DIR: "{{ atlas_borg_config_dir }}"
|
||||
BORG_PASSCOMMAND: "cat {{ atlas_borg_passphrase_path }}"
|
||||
BORG_RSH: "{{ atlas_borg_ssh_wrapper_path }}"
|
||||
become: true
|
||||
become_user: "{{ atlas_borg_username }}"
|
||||
changed_when: false
|
||||
when:
|
||||
- atlas_manage_borg_backup | bool
|
||||
- not ansible_check_mode
|
||||
|
||||
- name: Check for the local Atlas Borg recovery-key export
|
||||
tags: [atlas, storage, backup, borg]
|
||||
ansible.builtin.stat:
|
||||
path: "{{ atlas_borg_recovery_export_path }}"
|
||||
register: atlas_borg_recovery_export
|
||||
delegate_to: localhost
|
||||
become: false
|
||||
when:
|
||||
- atlas_manage_borg_backup | bool
|
||||
- not ansible_check_mode
|
||||
|
||||
- name: Export the Atlas Borg recovery key for offline preservation
|
||||
tags: [atlas, storage, backup, borg]
|
||||
when:
|
||||
- atlas_manage_borg_backup | bool
|
||||
- not ansible_check_mode
|
||||
- not atlas_borg_recovery_export.stat.exists
|
||||
no_log: true
|
||||
block:
|
||||
- name: Create the local recovery-material directory
|
||||
ansible.builtin.file:
|
||||
path: "{{ atlas_borg_recovery_export_path | dirname }}"
|
||||
state: directory
|
||||
mode: "0700"
|
||||
delegate_to: localhost
|
||||
become: false
|
||||
|
||||
- name: Export the encrypted Borg repository key on Atlas
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- /usr/bin/borg
|
||||
- --remote-path
|
||||
- "{{ atlas_borg_remote_path }}"
|
||||
- key
|
||||
- export
|
||||
- >-
|
||||
ssh://{{ atlas_borg_repository_user }}@{{ atlas_borg_repository_host }}:
|
||||
{{- atlas_borg_repository_port }}/{{ atlas_borg_repository_path }}
|
||||
- "{{ atlas_borg_config_dir }}/atlas-borg-repokey.export"
|
||||
environment:
|
||||
BORG_CACHE_DIR: "{{ atlas_borg_cache_dir }}"
|
||||
BORG_CONFIG_DIR: "{{ atlas_borg_config_dir }}"
|
||||
BORG_PASSCOMMAND: "cat {{ atlas_borg_passphrase_path }}"
|
||||
BORG_RSH: "{{ atlas_borg_ssh_wrapper_path }}"
|
||||
become: true
|
||||
become_user: "{{ atlas_borg_username }}"
|
||||
|
||||
- name: Fetch the encrypted Borg recovery key from Atlas
|
||||
ansible.builtin.fetch:
|
||||
src: "{{ atlas_borg_config_dir }}/atlas-borg-repokey.export"
|
||||
dest: "{{ atlas_borg_recovery_export_path }}"
|
||||
flat: true
|
||||
|
||||
- name: Protect the local Borg recovery-key export
|
||||
ansible.builtin.file:
|
||||
path: "{{ atlas_borg_recovery_export_path }}"
|
||||
mode: "0600"
|
||||
delegate_to: localhost
|
||||
become: false
|
||||
always:
|
||||
- name: Remove the temporary recovery-key export from Atlas
|
||||
ansible.builtin.file:
|
||||
path: "{{ atlas_borg_config_dir }}/atlas-borg-repokey.export"
|
||||
state: absent
|
||||
|
||||
- name: Enable Atlas Borg backup and check timers
|
||||
tags: [atlas, storage, backup, borg]
|
||||
ansible.builtin.systemd:
|
||||
name: "{{ item }}"
|
||||
enabled: true
|
||||
state: started
|
||||
daemon_reload: true
|
||||
loop:
|
||||
- atlas-borg-backup.timer
|
||||
- atlas-borg-check.timer
|
||||
when:
|
||||
- atlas_manage_borg_backup | bool
|
||||
- not ansible_check_mode
|
||||
@@ -1,159 +0,0 @@
|
||||
---
|
||||
- name: Prepare the isolated rootless Atlas Gitea target
|
||||
tags: [atlas, gitea]
|
||||
when: atlas_manage_gitea | bool
|
||||
block:
|
||||
- name: Require the existing Atlas application-data dataset
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- atlas_manage_storage | bool
|
||||
- atlas_gitea_dataset == atlas_zfs_pool ~ '/services/data/gitea'
|
||||
- atlas_gitea_mountpoint == atlas_app_data_mountpoint ~ '/gitea'
|
||||
- atlas_gitea_username == atlas_admin_username
|
||||
- atlas_gitea_group == atlas_admin_group
|
||||
- atlas_gitea_uid | int == atlas_admin_uid | int
|
||||
- atlas_gitea_gid | int == atlas_admin_gid | int
|
||||
- atlas_gitea_container_uid | int == 1000
|
||||
- atlas_gitea_container_gid | int == 1000
|
||||
- atlas_gitea_staging_bind_address == '127.0.0.1'
|
||||
- not (atlas_gitea_production_enabled | bool) or atlas_manage_firewall | bool
|
||||
- not (atlas_gitea_production_enabled | bool) or atlas_gitea_bind_address == ansible_host
|
||||
fail_msg: >-
|
||||
Rootless Gitea requires Atlas storage, the admin user manager, the
|
||||
dedicated dataset, and loopback-only staging ports.
|
||||
|
||||
- name: Inspect the final-restore marker before production activation
|
||||
ansible.builtin.stat:
|
||||
path: "{{ atlas_gitea_mountpoint }}/.final-sha256"
|
||||
register: atlas_gitea_final_marker
|
||||
when: atlas_gitea_production_enabled | bool
|
||||
|
||||
- name: Refuse production activation without the final consistent restore
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- atlas_gitea_final_marker.stat.isreg | default(false)
|
||||
fail_msg: Restore the final stopped-source Gitea export before enabling production.
|
||||
when: atlas_gitea_production_enabled | bool
|
||||
|
||||
- name: Verify the production Gitea dataset belongs to admin
|
||||
ansible.builtin.stat:
|
||||
path: "{{ atlas_gitea_mountpoint }}"
|
||||
register: atlas_gitea_dataset_owner
|
||||
when: atlas_gitea_production_enabled | bool
|
||||
|
||||
- name: Refuse to overlap the legacy host-account service
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- atlas_gitea_dataset_owner.stat.uid | int == atlas_admin_uid | int
|
||||
- atlas_gitea_dataset_owner.stat.gid | int == atlas_admin_gid | int
|
||||
fail_msg: >-
|
||||
The production dataset must already belong to admin before enabling
|
||||
the Quadlet; normal provisioning must not chown an active legacy service.
|
||||
when: atlas_gitea_production_enabled | bool
|
||||
|
||||
- name: Remove the retired account's parent-dataset traverse ACL
|
||||
ansible.posix.acl:
|
||||
path: "{{ item }}"
|
||||
etype: user
|
||||
entity: "{{ atlas_gitea_legacy_username }}"
|
||||
state: absent
|
||||
loop:
|
||||
- "{{ atlas_services_mountpoint }}"
|
||||
- "{{ atlas_app_data_mountpoint }}"
|
||||
when: atlas_gitea_production_enabled | bool
|
||||
|
||||
- name: Enable POSIX ACLs only on the service-namespace parents
|
||||
community.general.zfs:
|
||||
name: "{{ item }}"
|
||||
state: present
|
||||
extra_zfs_properties:
|
||||
acltype: posix
|
||||
loop:
|
||||
- "{{ atlas_zfs_pool }}/{{ atlas_zfs_dataset_services }}"
|
||||
- "{{ atlas_zfs_pool }}/{{ atlas_zfs_dataset_app_data }}"
|
||||
|
||||
- name: Create the dedicated Gitea ZFS dataset
|
||||
community.general.zfs:
|
||||
name: "{{ atlas_gitea_dataset }}"
|
||||
state: present
|
||||
extra_zfs_properties:
|
||||
compression: zstd
|
||||
mountpoint: "{{ atlas_gitea_mountpoint }}"
|
||||
|
||||
- name: Restrict the Gitea dataset and create rootless volume paths
|
||||
ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
owner: "{{ atlas_gitea_username }}"
|
||||
group: "{{ atlas_gitea_group }}"
|
||||
mode: "0700"
|
||||
loop:
|
||||
- "{{ atlas_gitea_mountpoint }}"
|
||||
- "{{ atlas_gitea_mountpoint }}/data"
|
||||
- "{{ atlas_gitea_mountpoint }}/config"
|
||||
- "{{ atlas_gitea_home }}/.config"
|
||||
- "{{ atlas_gitea_home }}/.config/containers"
|
||||
- "{{ atlas_gitea_quadlet_dir }}"
|
||||
|
||||
- name: Ensure lingering for the admin rootless account
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- loginctl
|
||||
- enable-linger
|
||||
- "{{ atlas_gitea_username }}"
|
||||
creates: "/var/lib/systemd/linger/{{ atlas_gitea_username }}"
|
||||
|
||||
- name: Start the admin rootless user manager
|
||||
ansible.builtin.systemd:
|
||||
name: "user@{{ atlas_gitea_uid }}.service"
|
||||
state: started
|
||||
when: not ansible_check_mode
|
||||
|
||||
- name: Prepare the admin-owned Gitea image
|
||||
ansible.builtin.import_tasks: gitea_image.yml
|
||||
|
||||
- name: Render the rootless Gitea Quadlet
|
||||
ansible.builtin.template:
|
||||
src: atlas-gitea.container.j2
|
||||
dest: "{{ atlas_gitea_quadlet_dir }}/atlas-gitea.container"
|
||||
owner: "{{ atlas_gitea_username }}"
|
||||
group: "{{ atlas_gitea_group }}"
|
||||
mode: "0644"
|
||||
|
||||
- name: Permit only Aegis to reach production Gitea HTTP and SSH
|
||||
ansible.posix.firewalld:
|
||||
rich_rule: >-
|
||||
rule family="ipv4" source address="{{ atlas_aegis_ip }}"
|
||||
port port="{{ item }}" protocol="tcp" accept
|
||||
zone: "{{ atlas_firewalld_zone }}"
|
||||
state: "{{ 'enabled' if atlas_gitea_production_enabled | bool else 'disabled' }}"
|
||||
permanent: true
|
||||
immediate: true
|
||||
loop:
|
||||
- "{{ atlas_gitea_http_port }}"
|
||||
- "{{ atlas_gitea_ssh_port }}"
|
||||
when: atlas_manage_firewall | bool
|
||||
|
||||
- name: Reload the rootless Gitea user manager without starting Gitea
|
||||
become_user: "{{ atlas_gitea_username }}"
|
||||
ansible.builtin.systemd:
|
||||
scope: user
|
||||
daemon_reload: true
|
||||
environment:
|
||||
XDG_RUNTIME_DIR: "/run/user/{{ atlas_gitea_uid }}"
|
||||
DBUS_SESSION_BUS_ADDRESS: "unix:path=/run/user/{{ atlas_gitea_uid }}/bus"
|
||||
when: not ansible_check_mode
|
||||
|
||||
- name: Start and enable the rootless Gitea user Quadlet after final restore
|
||||
become_user: "{{ atlas_gitea_username }}"
|
||||
ansible.builtin.systemd:
|
||||
name: atlas-gitea.service
|
||||
scope: user
|
||||
state: started
|
||||
enabled: true
|
||||
environment:
|
||||
XDG_RUNTIME_DIR: "/run/user/{{ atlas_gitea_uid }}"
|
||||
DBUS_SESSION_BUS_ADDRESS: "unix:path=/run/user/{{ atlas_gitea_uid }}/bus"
|
||||
when:
|
||||
- atlas_gitea_production_enabled | bool
|
||||
- not ansible_check_mode
|
||||
@@ -1,51 +0,0 @@
|
||||
---
|
||||
- name: Create the admin-owned Gitea image build directory
|
||||
ansible.builtin.file:
|
||||
path: "{{ atlas_gitea_image_build_dir }}"
|
||||
state: directory
|
||||
owner: "{{ atlas_admin_username }}"
|
||||
group: "{{ atlas_admin_group }}"
|
||||
mode: "0700"
|
||||
|
||||
- name: Install the pinned rootless Gitea Containerfile
|
||||
ansible.builtin.copy:
|
||||
src: Containerfile.gitea-rootless
|
||||
dest: "{{ atlas_gitea_image_build_dir }}/Containerfile"
|
||||
owner: "{{ atlas_admin_username }}"
|
||||
group: "{{ atlas_admin_group }}"
|
||||
mode: "0644"
|
||||
|
||||
- name: Check the admin-owned Gitea image
|
||||
become_user: "{{ atlas_admin_username }}"
|
||||
ansible.builtin.command:
|
||||
argv: [podman, image, exists, "{{ atlas_gitea_image }}"]
|
||||
args:
|
||||
chdir: "{{ atlas_gitea_image_build_dir }}"
|
||||
environment:
|
||||
HOME: "{{ atlas_admin_home }}"
|
||||
XDG_RUNTIME_DIR: "/run/user/{{ atlas_admin_uid }}"
|
||||
register: atlas_gitea_image_present
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
check_mode: false
|
||||
|
||||
- name: Build the pinned Gitea image with the internal gitea identity
|
||||
become_user: "{{ atlas_admin_username }}"
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- podman
|
||||
- build
|
||||
- --pull=always
|
||||
- --tag
|
||||
- "{{ atlas_gitea_image }}"
|
||||
- --file
|
||||
- Containerfile
|
||||
- .
|
||||
args:
|
||||
chdir: "{{ atlas_gitea_image_build_dir }}"
|
||||
environment:
|
||||
HOME: "{{ atlas_admin_home }}"
|
||||
XDG_RUNTIME_DIR: "/run/user/{{ atlas_admin_uid }}"
|
||||
when:
|
||||
- atlas_gitea_image_present.rc != 0
|
||||
- not ansible_check_mode
|
||||
@@ -1,58 +0,0 @@
|
||||
---
|
||||
- name: Manage the public domain of the restored production Gitea
|
||||
tags: [atlas, gitea, gitea_public_domain]
|
||||
when:
|
||||
- atlas_manage_gitea | bool
|
||||
- atlas_gitea_production_enabled | bool
|
||||
- atlas_gitea_public_domain | length > 0
|
||||
block:
|
||||
- name: Require an explicit public Gitea hostname
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- atlas_gitea_public_domain is match('^[a-zA-Z0-9][a-zA-Z0-9.-]*\.[a-zA-Z]{2,}$')
|
||||
|
||||
- name: Inspect the restored private Gitea configuration
|
||||
ansible.builtin.stat:
|
||||
path: "{{ atlas_gitea_mountpoint }}/config/app.ini"
|
||||
follow: false
|
||||
register: atlas_gitea_public_config
|
||||
|
||||
- name: Refuse to create or replace an unprepared Gitea configuration
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- atlas_gitea_public_config.stat.isreg | default(false)
|
||||
- atlas_gitea_public_config.stat.uid | int == atlas_gitea_uid | int
|
||||
- atlas_gitea_public_config.stat.mode == '0600'
|
||||
|
||||
# app.ini contains secrets: preserve all unrelated settings and suppress diffs.
|
||||
- name: Set only the declared public Gitea server fields
|
||||
community.general.ini_file:
|
||||
path: "{{ atlas_gitea_mountpoint }}/config/app.ini"
|
||||
section: server
|
||||
option: "{{ item.option }}"
|
||||
value: "{{ item.value }}"
|
||||
create: false
|
||||
backup: true
|
||||
owner: "{{ atlas_gitea_username }}"
|
||||
group: "{{ atlas_gitea_group }}"
|
||||
mode: "0600"
|
||||
loop:
|
||||
- { option: DOMAIN, value: "{{ atlas_gitea_public_domain }}" }
|
||||
- { option: ROOT_URL, value: "https://{{ atlas_gitea_public_domain }}/" }
|
||||
- { option: SSH_DOMAIN, value: "{{ atlas_gitea_public_domain }}" }
|
||||
register: atlas_gitea_public_domain_update
|
||||
no_log: true
|
||||
diff: false
|
||||
|
||||
- name: Restart only Gitea when its public configuration changes
|
||||
become_user: "{{ atlas_gitea_username }}"
|
||||
ansible.builtin.systemd:
|
||||
name: atlas-gitea.service
|
||||
scope: user
|
||||
state: restarted
|
||||
environment:
|
||||
XDG_RUNTIME_DIR: "/run/user/{{ atlas_gitea_uid }}"
|
||||
DBUS_SESSION_BUS_ADDRESS: "unix:path=/run/user/{{ atlas_gitea_uid }}/bus"
|
||||
when:
|
||||
- atlas_gitea_public_domain_update is changed
|
||||
- not ansible_check_mode
|
||||
@@ -1,188 +0,0 @@
|
||||
---
|
||||
- name: Require exact Atlas iCloudPD paths and rootless identity
|
||||
tags: [atlas, icloudpd]
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- atlas_manage_storage | bool
|
||||
- atlas_icloudpd_dataset == atlas_zfs_pool ~ '/services/data/icloudpd'
|
||||
- atlas_icloudpd_state_dir == atlas_app_data_mountpoint ~ '/icloudpd'
|
||||
- atlas_icloudpd_config_dir == atlas_icloudpd_state_dir ~ '/config'
|
||||
- atlas_icloudpd_photos_dir == atlas_archive_mountpoint ~ '/Pictures/iCloudPD'
|
||||
- atlas_admin_uid | int == 1000
|
||||
- atlas_admin_gid | int == 1000
|
||||
- atlas_icloudpd_image is search('@sha256:[0-9a-f]{64}$')
|
||||
fail_msg: Verify the fixed, separate Atlas iCloudPD photo and state paths.
|
||||
|
||||
- name: Declare rootless Atlas iCloudPD storage and boot-started Quadlet
|
||||
tags: [atlas, icloudpd]
|
||||
block:
|
||||
- name: Inspect the existing Archive and application-data datasets
|
||||
community.general.zfs_facts:
|
||||
name: "{{ item.dataset }}"
|
||||
properties: name,mounted,mountpoint
|
||||
loop:
|
||||
- dataset: "{{ atlas_zfs_pool }}/{{ atlas_zfs_dataset_archive }}"
|
||||
mountpoint: "{{ atlas_archive_mountpoint }}"
|
||||
- dataset: "{{ atlas_zfs_pool }}/{{ atlas_zfs_dataset_app_data }}"
|
||||
mountpoint: "{{ atlas_app_data_mountpoint }}"
|
||||
loop_control:
|
||||
label: "{{ item.dataset }}"
|
||||
register: atlas_icloudpd_parent_datasets
|
||||
|
||||
- name: Refuse missing or unmounted iCloudPD parent datasets
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- item.ansible_facts.ansible_zfs_datasets | length == 1
|
||||
- item.ansible_facts.ansible_zfs_datasets[0].mounted == 'yes'
|
||||
- item.ansible_facts.ansible_zfs_datasets[0].mountpoint == item.item.mountpoint
|
||||
loop: "{{ atlas_icloudpd_parent_datasets.results }}"
|
||||
loop_control:
|
||||
label: "{{ item.item.dataset }}"
|
||||
|
||||
- name: Inspect the existing Pictures namespace and proposed target
|
||||
ansible.builtin.stat:
|
||||
path: "{{ item }}"
|
||||
follow: false
|
||||
loop:
|
||||
- "{{ atlas_archive_mountpoint }}/Pictures"
|
||||
- "{{ atlas_icloudpd_photos_dir }}"
|
||||
- "{{ atlas_icloudpd_photos_dir }}/.atlas-icloudpd-managed"
|
||||
register: atlas_icloudpd_photo_paths
|
||||
|
||||
- name: Refuse to adopt unrelated Pictures data or a symlink
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- atlas_icloudpd_photo_paths.results[0].stat.isdir | default(false)
|
||||
- atlas_icloudpd_photo_paths.results[0].stat.uid | int == atlas_admin_uid | int
|
||||
- >-
|
||||
not atlas_icloudpd_photo_paths.results[1].stat.exists or
|
||||
(atlas_icloudpd_photo_paths.results[1].stat.isdir | default(false) and
|
||||
atlas_icloudpd_photo_paths.results[2].stat.isreg | default(false))
|
||||
fail_msg: >-
|
||||
Pictures must exist and be admin-owned; an existing iCloudPD target
|
||||
must carry its managed marker. Never adopt or replace unrelated data.
|
||||
|
||||
- name: Create a dedicated ZFS dataset for iCloudPD configuration and MFA
|
||||
community.general.zfs:
|
||||
name: "{{ atlas_icloudpd_dataset }}"
|
||||
state: present
|
||||
extra_zfs_properties:
|
||||
compression: zstd
|
||||
mountpoint: "{{ atlas_icloudpd_state_dir }}"
|
||||
|
||||
- name: Restrict iCloudPD state and the new photo subtree
|
||||
ansible.builtin.file:
|
||||
path: "{{ item.path }}"
|
||||
state: directory
|
||||
owner: "{{ atlas_admin_username }}"
|
||||
group: "{{ atlas_admin_group }}"
|
||||
mode: "{{ item.mode }}"
|
||||
loop:
|
||||
- path: "{{ atlas_icloudpd_state_dir }}"
|
||||
mode: "0700"
|
||||
- path: "{{ atlas_icloudpd_config_dir }}"
|
||||
mode: "0700"
|
||||
- path: "{{ atlas_icloudpd_photos_dir }}"
|
||||
mode: "0750"
|
||||
- path: "{{ atlas_icloudpd_quadlet_dir }}"
|
||||
mode: "0700"
|
||||
loop_control:
|
||||
label: "{{ item.path }}"
|
||||
|
||||
- name: Mark only the newly managed iCloudPD photo subtree
|
||||
ansible.builtin.copy:
|
||||
content: "Atlas iCloudPD photo subtree; do not remove source photos.\n"
|
||||
dest: "{{ atlas_icloudpd_photos_dir }}/.atlas-icloudpd-managed"
|
||||
owner: "{{ atlas_admin_username }}"
|
||||
group: "{{ atlas_admin_group }}"
|
||||
mode: "0600"
|
||||
force: false
|
||||
|
||||
- name: Install the image's required mounted-filesystem failsafe
|
||||
ansible.builtin.copy:
|
||||
content: ""
|
||||
dest: "{{ atlas_icloudpd_photos_dir }}/.mounted"
|
||||
owner: "{{ atlas_admin_username }}"
|
||||
group: "{{ atlas_admin_group }}"
|
||||
mode: "0644"
|
||||
force: false
|
||||
|
||||
- name: Require the Vault-backed iCloudPD Apple ID
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- vault_atlas_icloudpd_apple_id is defined
|
||||
- vault_atlas_icloudpd_apple_id | length > 0
|
||||
- vault_atlas_icloudpd_apple_id != 'REPLACE_ME'
|
||||
- vault_atlas_icloudpd_apple_id.splitlines() | length == 1
|
||||
fail_msg: Configure the existing iCloudPD Apple ID in Vault.
|
||||
no_log: true
|
||||
|
||||
- name: Seed private Atlas iCloudPD configuration when absent
|
||||
ansible.builtin.template:
|
||||
src: atlas-icloudpd.conf.j2
|
||||
dest: "{{ atlas_icloudpd_config_dir }}/icloudpd.conf"
|
||||
owner: "{{ atlas_admin_username }}"
|
||||
group: "{{ atlas_admin_group }}"
|
||||
mode: "0600"
|
||||
force: false
|
||||
no_log: true
|
||||
diff: false
|
||||
|
||||
- name: Keep declared iCloudPD options in the image-managed configuration
|
||||
ansible.builtin.lineinfile:
|
||||
path: "{{ atlas_icloudpd_config_dir }}/icloudpd.conf"
|
||||
regexp: "^{{ item.key }}="
|
||||
line: "{{ item.key }}={{ item.value }}"
|
||||
owner: "{{ atlas_admin_username }}"
|
||||
group: "{{ atlas_admin_group }}"
|
||||
mode: "0600"
|
||||
loop:
|
||||
- {key: apple_id, value: "{{ vault_atlas_icloudpd_apple_id }}"}
|
||||
- {key: authentication_type, value: MFA}
|
||||
- {key: user, value: user}
|
||||
- {key: user_id, value: "1000"}
|
||||
- {key: group, value: group}
|
||||
- {key: group_id, value: "1000"}
|
||||
- {key: download_path, value: /home/user/iCloud}
|
||||
- {key: folder_structure, value: "{:%Y/%m/%d}"}
|
||||
- {key: directory_permissions, value: "750"}
|
||||
- {key: file_permissions, value: "640"}
|
||||
- {key: download_interval, value: "86400"}
|
||||
- {key: auto_delete, value: "false"}
|
||||
- {key: delete_after_download, value: "false"}
|
||||
loop_control:
|
||||
label: "{{ item.key }}"
|
||||
no_log: true
|
||||
diff: false
|
||||
|
||||
- name: Render the rootless Atlas iCloudPD Quadlet
|
||||
ansible.builtin.template:
|
||||
src: atlas-icloudpd.container.j2
|
||||
dest: "{{ atlas_icloudpd_quadlet_dir }}/atlas-icloudpd.container"
|
||||
owner: "{{ atlas_admin_username }}"
|
||||
group: "{{ atlas_admin_group }}"
|
||||
mode: "0644"
|
||||
register: atlas_icloudpd_quadlet
|
||||
|
||||
- name: Reload the Atlas admin user manager after iCloudPD Quadlet changes
|
||||
become_user: "{{ atlas_admin_username }}"
|
||||
ansible.builtin.systemd:
|
||||
scope: user
|
||||
daemon_reload: true
|
||||
environment:
|
||||
XDG_RUNTIME_DIR: "/run/user/{{ atlas_admin_uid }}"
|
||||
DBUS_SESSION_BUS_ADDRESS: "unix:path=/run/user/{{ atlas_admin_uid }}/bus"
|
||||
when:
|
||||
- atlas_icloudpd_quadlet.changed
|
||||
- not ansible_check_mode
|
||||
|
||||
- name: Keep the rootless Atlas iCloudPD service running
|
||||
become_user: "{{ atlas_admin_username }}"
|
||||
ansible.builtin.systemd:
|
||||
name: atlas-icloudpd.service
|
||||
scope: user
|
||||
state: started
|
||||
environment:
|
||||
XDG_RUNTIME_DIR: "/run/user/{{ atlas_admin_uid }}"
|
||||
DBUS_SESSION_BUS_ADDRESS: "unix:path=/run/user/{{ atlas_admin_uid }}/bus"
|
||||
when: not ansible_check_mode
|
||||
@@ -14,54 +14,6 @@
|
||||
- name: Import Atlas storage tasks
|
||||
ansible.builtin.import_tasks: storage.yml
|
||||
|
||||
- name: Import staged Atlas rootless Gitea tasks
|
||||
ansible.builtin.import_tasks: gitea.yml
|
||||
|
||||
- name: Import the declared Atlas Gitea public domain
|
||||
ansible.builtin.import_tasks: gitea_public_domain.yml
|
||||
|
||||
- name: Import Atlas Nextcloud steady-state stack
|
||||
ansible.builtin.import_tasks: nextcloud.yml
|
||||
|
||||
- name: Import Atlas iCloudPD storage and boot-started Quadlet tasks
|
||||
ansible.builtin.import_tasks: icloudpd.yml
|
||||
|
||||
- name: Import Atlas Paperless-ngx document-management service
|
||||
ansible.builtin.import_tasks: paperless.yml
|
||||
|
||||
- name: Import Atlas torrent service
|
||||
ansible.builtin.import_tasks: qbittorrent.yml
|
||||
|
||||
- name: Import Atlas LAN HTTP downloader
|
||||
ansible.builtin.import_tasks: aria2.yml
|
||||
|
||||
- name: Import Atlas private aria2 RPC gateway
|
||||
ansible.builtin.import_tasks: aria2_gateway.yml
|
||||
|
||||
- name: Import Atlas ZFS maintenance tasks
|
||||
ansible.builtin.import_tasks: zfs_maintenance.yml
|
||||
|
||||
- name: Import Atlas Borg backup tasks
|
||||
ansible.builtin.import_tasks: borg_backup.yml
|
||||
|
||||
- name: Import Atlas offline USB backup tasks
|
||||
ansible.builtin.import_tasks: usb_backup.yml
|
||||
|
||||
- name: Import recurring Nextcloud backup preparation
|
||||
ansible.builtin.import_tasks: nextcloud_backup.yml
|
||||
|
||||
- name: Import Atlas Prometheus backup pull identity tasks
|
||||
ansible.builtin.import_tasks: prometheus_pull_identity.yml
|
||||
|
||||
- name: Import Atlas Prometheus backup pull job tasks
|
||||
ansible.builtin.import_tasks: prometheus_pull_job.yml
|
||||
|
||||
- name: Import Atlas health monitoring tasks
|
||||
ansible.builtin.import_tasks: monitoring.yml
|
||||
|
||||
- name: Import Atlas post-restore SELinux relabeling tasks
|
||||
ansible.builtin.import_tasks: restorecon.yml
|
||||
|
||||
- name: Import Atlas file sharing tasks
|
||||
ansible.builtin.import_tasks: sharing.yml
|
||||
|
||||
|
||||
@@ -1,201 +0,0 @@
|
||||
---
|
||||
- name: Validate Atlas health monitoring policy
|
||||
tags: [atlas, monitoring]
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- atlas_manage_storage | bool
|
||||
- atlas_zfs_pool != 'CHANGEME_ZFS_POOL'
|
||||
- atlas_monitor_calendar | length > 0
|
||||
- atlas_monitor_smart_devices | length > 0
|
||||
- atlas_monitor_effective_timers | length > 0
|
||||
- atlas_monitor_effective_failure_units | length > 0
|
||||
- atlas_monitor_remote_capacity.user == atlas_borg_repository_user
|
||||
- atlas_monitor_remote_capacity.host == atlas_borg_repository_host
|
||||
- atlas_monitor_remote_capacity.run_as == atlas_borg_username
|
||||
- atlas_monitor_remote_capacity.ssh_wrapper == atlas_borg_ssh_wrapper_path
|
||||
- >-
|
||||
0 < atlas_monitor_remote_capacity.warning_percent | int
|
||||
< atlas_monitor_remote_capacity.critical_percent | int < 100
|
||||
- atlas_monitor_remote_capacity.growth_warning_gib_day | int > 0
|
||||
- atlas_monitor_notifier.startswith('/opt/45drives/houston/')
|
||||
- 0 < atlas_monitor_pool_warning_percent | int < atlas_monitor_pool_critical_percent | int < 100
|
||||
- 0 < atlas_monitor_root_warning_percent | int < atlas_monitor_root_critical_percent | int < 100
|
||||
- 0 < atlas_monitor_snapshot_warning_percent | int < atlas_monitor_snapshot_critical_percent | int < 100
|
||||
- atlas_monitor_snapshot_growth_warning_gib_day | int > 0
|
||||
- atlas_monitor_backup_growth_warning_gib_day | int > 0
|
||||
- 0 < atlas_monitor_cpu_warning_c | int < atlas_monitor_cpu_critical_c | int
|
||||
- atlas_monitor_borg_max_runtime_days | int > 0
|
||||
fail_msg: >-
|
||||
Atlas health monitoring needs real devices, job units, a valid calendar,
|
||||
positive ordered thresholds, and the existing Houston notifier.
|
||||
when: atlas_manage_monitoring | bool
|
||||
|
||||
- name: Validate monitored Atlas SMART devices
|
||||
tags: [atlas, monitoring]
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- item.name is match('^[a-z0-9][a-z0-9_-]*$')
|
||||
- item.path.startswith('/dev/disk/by-id/')
|
||||
- 0 < item.warning_c | int < item.critical_c | int
|
||||
fail_msg: "Every monitored disk needs a stable by-id path and ordered temperature thresholds."
|
||||
loop: "{{ atlas_monitor_smart_devices }}"
|
||||
loop_control:
|
||||
label: "{{ item.name }}"
|
||||
when: atlas_manage_monitoring | bool
|
||||
|
||||
- name: Validate monitored Atlas timer names and age thresholds
|
||||
tags: [atlas, monitoring]
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- item.name is match('^[a-zA-Z0-9@_.-]+\\.timer$')
|
||||
- item.max_age_hours | int >= 0
|
||||
loop: "{{ atlas_monitor_effective_timers }}"
|
||||
loop_control:
|
||||
label: "{{ item.name }}"
|
||||
when: atlas_manage_monitoring | bool
|
||||
|
||||
- name: Validate monitored Atlas failure unit names
|
||||
tags: [atlas, monitoring]
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- item is match('^[a-zA-Z0-9@_.-]+\\.service$')
|
||||
loop: "{{ atlas_monitor_effective_failure_units }}"
|
||||
when: atlas_manage_monitoring | bool
|
||||
|
||||
- name: Validate Atlas health monitor calendar
|
||||
tags: [atlas, monitoring]
|
||||
ansible.builtin.command:
|
||||
argv: [systemd-analyze, calendar, "{{ atlas_monitor_calendar }}"]
|
||||
changed_when: false
|
||||
check_mode: false
|
||||
when: atlas_manage_monitoring | bool
|
||||
|
||||
- name: Install SMART tooling for Atlas health checks
|
||||
tags: [atlas, monitoring, packages]
|
||||
ansible.builtin.dnf:
|
||||
name: smartmontools
|
||||
state: present
|
||||
when: atlas_manage_monitoring | bool
|
||||
|
||||
- name: Inspect the existing 45Drives notifier for monitoring
|
||||
tags: [atlas, monitoring]
|
||||
ansible.builtin.stat:
|
||||
path: "{{ atlas_monitor_notifier }}"
|
||||
register: atlas_monitor_notifier_file
|
||||
when: atlas_manage_monitoring | bool
|
||||
|
||||
- name: Require the existing 45Drives notifier for monitoring
|
||||
tags: [atlas, monitoring]
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- atlas_monitor_notifier_file.stat.executable | default(false)
|
||||
fail_msg: "The existing 45Drives Houston notifier must be executable."
|
||||
when: atlas_manage_monitoring | bool
|
||||
|
||||
- name: Create private Atlas health monitor state directory
|
||||
tags: [atlas, monitoring]
|
||||
ansible.builtin.file:
|
||||
path: /var/lib/atlas-health-monitor
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0700"
|
||||
when: atlas_manage_monitoring | bool
|
||||
|
||||
- name: Install Atlas health monitor configuration
|
||||
tags: [atlas, monitoring]
|
||||
ansible.builtin.template:
|
||||
src: atlas-health-monitor.json.j2
|
||||
dest: /etc/atlas-health-monitor.json
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0600"
|
||||
when: atlas_manage_monitoring | bool
|
||||
|
||||
- name: Install Atlas health monitor helper
|
||||
tags: [atlas, monitoring]
|
||||
ansible.builtin.copy:
|
||||
src: atlas-health-monitor.py
|
||||
dest: /usr/local/libexec/atlas-health-monitor
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0750"
|
||||
when: atlas_manage_monitoring | bool
|
||||
|
||||
- name: Install Atlas health monitoring units
|
||||
tags: [atlas, monitoring]
|
||||
ansible.builtin.template:
|
||||
src: "{{ item }}.j2"
|
||||
dest: "/etc/systemd/system/{{ item }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
loop:
|
||||
- atlas-health-monitor.service
|
||||
- atlas-health-monitor.timer
|
||||
- atlas-monitor-failure@.service
|
||||
when: atlas_manage_monitoring | bool
|
||||
|
||||
- name: Create failure hook directories for monitored Atlas jobs
|
||||
tags: [atlas, monitoring]
|
||||
ansible.builtin.file:
|
||||
path: "/etc/systemd/system/{{ item }}.d"
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0755"
|
||||
loop: "{{ atlas_monitor_effective_failure_units }}"
|
||||
when: atlas_manage_monitoring | bool
|
||||
|
||||
- name: Notify 45Drives Alerts when an Atlas job fails
|
||||
tags: [atlas, monitoring]
|
||||
ansible.builtin.template:
|
||||
src: atlas-monitor-failure.conf.j2
|
||||
dest: "/etc/systemd/system/{{ item }}.d/atlas-monitor.conf"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
loop: "{{ atlas_monitor_effective_failure_units }}"
|
||||
when: atlas_manage_monitoring | bool
|
||||
|
||||
- name: Reload systemd after installing Atlas monitoring
|
||||
tags: [atlas, monitoring]
|
||||
ansible.builtin.systemd:
|
||||
daemon_reload: true
|
||||
when:
|
||||
- atlas_manage_monitoring | bool
|
||||
- not ansible_check_mode
|
||||
|
||||
- name: Enable the Atlas health monitoring timer
|
||||
tags: [atlas, monitoring]
|
||||
ansible.builtin.systemd:
|
||||
name: atlas-health-monitor.timer
|
||||
enabled: true
|
||||
state: started
|
||||
when:
|
||||
- atlas_manage_monitoring | bool
|
||||
- not ansible_check_mode
|
||||
|
||||
- name: Validate the deployed Atlas health monitoring units
|
||||
tags: [atlas, monitoring]
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- systemd-analyze
|
||||
- verify
|
||||
- atlas-health-monitor.service
|
||||
- atlas-health-monitor.timer
|
||||
- atlas-monitor-failure@.service
|
||||
changed_when: false
|
||||
when:
|
||||
- atlas_manage_monitoring | bool
|
||||
- not ansible_check_mode
|
||||
|
||||
- name: Probe Atlas health without sending notifications
|
||||
tags: [atlas, monitoring]
|
||||
ansible.builtin.command:
|
||||
argv: [/usr/local/libexec/atlas-health-monitor, --dry-run]
|
||||
register: atlas_monitor_dry_run
|
||||
changed_when: false
|
||||
when:
|
||||
- atlas_manage_monitoring | bool
|
||||
- not ansible_check_mode
|
||||
@@ -1,338 +0,0 @@
|
||||
---
|
||||
- name: Manage the empty Atlas Nextcloud and ONLYOFFICE stack
|
||||
tags: [atlas, nextcloud]
|
||||
when: atlas_manage_nextcloud | bool
|
||||
block:
|
||||
- name: Validate dedicated paths, domains and pinned images
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- atlas_manage_storage | bool
|
||||
- atlas_manage_firewall | bool
|
||||
- atlas_nextcloud_root == atlas_app_data_mountpoint ~ '/nextcloud'
|
||||
- atlas_nextcloud_dataset == atlas_zfs_pool ~ '/services/data/nextcloud'
|
||||
- atlas_nextcloud_domain is match('^[a-z0-9.-]+$')
|
||||
- atlas_onlyoffice_domain is match('^[a-z0-9.-]+$')
|
||||
- atlas_nextcloud_domain != atlas_onlyoffice_domain
|
||||
- atlas_nextcloud_http_port | int > 1024
|
||||
- atlas_onlyoffice_http_port | int > 1024
|
||||
- atlas_nextcloud_http_port != atlas_onlyoffice_http_port
|
||||
- "['calendar', 'contacts', 'onlyoffice', 'groupfolders'] | difference(atlas_nextcloud_apps | map(attribute='id') | list) | length == 0"
|
||||
- atlas_nextcloud_users | length > 0
|
||||
- atlas_nextcloud_admin not in (atlas_nextcloud_users | map(attribute='username') | list)
|
||||
- atlas_nextcloud_users | map(attribute='username') | unique | list | length == atlas_nextcloud_users | length
|
||||
- item is search('@sha256:[0-9a-f]{64}$')
|
||||
loop:
|
||||
- "{{ atlas_nextcloud_image }}"
|
||||
- "{{ atlas_nextcloud_postgres_image }}"
|
||||
- "{{ atlas_nextcloud_redis_image }}"
|
||||
- "{{ atlas_onlyoffice_image }}"
|
||||
|
||||
- name: Require dedicated Vault secrets without exposing them
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- item | default('') is match('^[a-zA-Z0-9]{32,}$')
|
||||
loop: >-
|
||||
{{ [vault_nextcloud_database_password | default(''),
|
||||
vault_nextcloud_redis_password | default(''),
|
||||
vault_nextcloud_admin_password | default(''),
|
||||
vault_nextcloud_onlyoffice_jwt | default('')] +
|
||||
(atlas_nextcloud_users | map(attribute='password') | list) }}
|
||||
no_log: true
|
||||
|
||||
- name: Prepare access to declared existing Archive directories
|
||||
ansible.builtin.include_tasks: nextcloud_external_access.yml
|
||||
when: atlas_nextcloud_external_mounts | length > 0
|
||||
|
||||
- name: Verify the existing application-data parent is mounted
|
||||
community.general.zfs_facts:
|
||||
name: "{{ atlas_zfs_pool }}/{{ atlas_zfs_dataset_app_data }}"
|
||||
properties: name,mounted,mountpoint
|
||||
register: atlas_nextcloud_parent
|
||||
|
||||
- name: Require the verified application-data parent
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- atlas_nextcloud_parent.ansible_facts.ansible_zfs_datasets | length == 1
|
||||
- atlas_nextcloud_parent.ansible_facts.ansible_zfs_datasets[0].mounted == 'yes'
|
||||
- atlas_nextcloud_parent.ansible_facts.ansible_zfs_datasets[0].mountpoint == atlas_app_data_mountpoint
|
||||
|
||||
- name: Create the dedicated Nextcloud namespace and component datasets
|
||||
community.general.zfs:
|
||||
name: "{{ atlas_nextcloud_dataset }}{{ item }}"
|
||||
state: present
|
||||
extra_zfs_properties:
|
||||
compression: zstd
|
||||
mountpoint: "{{ atlas_nextcloud_root }}{{ item }}"
|
||||
loop: ['', /app, /files, /database, /cache, /office]
|
||||
|
||||
- name: Inspect component directories before seeding ownership
|
||||
ansible.builtin.stat:
|
||||
path: "{{ atlas_nextcloud_root }}{{ item }}"
|
||||
follow: false
|
||||
get_checksum: false
|
||||
loop: [/app, /files, /database, /cache, /office]
|
||||
register: atlas_nextcloud_component_paths
|
||||
|
||||
- name: Seed only root-owned new dataset roots without recursive ownership changes
|
||||
ansible.builtin.file:
|
||||
path: "{{ item.stat.path }}"
|
||||
state: directory
|
||||
owner: "{{ atlas_admin_username }}"
|
||||
group: "{{ atlas_admin_group }}"
|
||||
mode: "0700"
|
||||
loop: "{{ atlas_nextcloud_component_paths.results }}"
|
||||
loop_control:
|
||||
label: "{{ item.item }}"
|
||||
when:
|
||||
- item.stat.exists
|
||||
- item.stat.uid | default(-1) | int == 0
|
||||
|
||||
- name: Ensure private rootless stack configuration directories exist
|
||||
ansible.builtin.file:
|
||||
path: "{{ item.path }}"
|
||||
state: directory
|
||||
owner: "{{ atlas_admin_username }}"
|
||||
group: "{{ atlas_admin_group }}"
|
||||
mode: "{{ item.mode }}"
|
||||
loop:
|
||||
- {path: "{{ atlas_nextcloud_private_dir }}", mode: "0700"}
|
||||
- {path: "{{ atlas_nextcloud_app_cache }}", mode: "0755"}
|
||||
- {path: "{{ atlas_nextcloud_quadlet_dir }}", mode: "0700"}
|
||||
- {path: "{{ atlas_admin_home }}/.config/systemd/user", mode: "0700"}
|
||||
|
||||
- name: Inspect the dedicated ONLYOFFICE bind directories
|
||||
ansible.builtin.stat:
|
||||
path: "{{ atlas_nextcloud_root }}/office/{{ item }}"
|
||||
follow: false
|
||||
get_checksum: false
|
||||
loop: [data, lib, logs, database]
|
||||
register: atlas_onlyoffice_bind_paths
|
||||
|
||||
- name: Create ONLYOFFICE bind directories only when absent
|
||||
ansible.builtin.file:
|
||||
path: "{{ item.invocation.module_args.path }}"
|
||||
state: directory
|
||||
owner: "{{ atlas_admin_username }}"
|
||||
group: "{{ atlas_admin_group }}"
|
||||
mode: "0700"
|
||||
loop: "{{ atlas_onlyoffice_bind_paths.results }}"
|
||||
loop_control:
|
||||
label: "{{ item.item }}"
|
||||
when: not item.stat.exists
|
||||
|
||||
- name: Store private mounted password files inside a restricted host directory
|
||||
ansible.builtin.copy:
|
||||
content: "{{ item.value }}\n"
|
||||
dest: "{{ atlas_nextcloud_private_dir }}/{{ item.name }}"
|
||||
owner: "{{ atlas_admin_username }}"
|
||||
group: "{{ atlas_admin_group }}"
|
||||
mode: "0644"
|
||||
loop:
|
||||
- {name: postgres-password, value: "{{ vault_nextcloud_database_password }}"}
|
||||
- {name: redis-password, value: "{{ vault_nextcloud_redis_password }}"}
|
||||
- {name: admin-password, value: "{{ vault_nextcloud_admin_password }}"}
|
||||
- {name: onlyoffice-jwt, value: "{{ vault_nextcloud_onlyoffice_jwt }}"}
|
||||
no_log: true
|
||||
diff: false
|
||||
register: atlas_nextcloud_secret_files
|
||||
|
||||
- name: Render private Redis and ONLYOFFICE configuration
|
||||
ansible.builtin.template:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ atlas_nextcloud_private_dir }}/{{ item.dest }}"
|
||||
owner: "{{ atlas_admin_username }}"
|
||||
group: "{{ atlas_admin_group }}"
|
||||
mode: "{{ item.mode }}"
|
||||
loop:
|
||||
- {src: atlas-nextcloud-redis.conf.j2, dest: redis.conf, mode: "0644"}
|
||||
- {src: atlas-onlyoffice.env.j2, dest: onlyoffice.env, mode: "0600"}
|
||||
no_log: true
|
||||
diff: false
|
||||
register: atlas_nextcloud_private_configuration
|
||||
|
||||
- name: Hide ONLYOFFICE welcome and example endpoints without changing editor routes
|
||||
ansible.builtin.template:
|
||||
src: atlas-onlyoffice-access.conf.j2
|
||||
dest: "{{ atlas_nextcloud_private_dir }}/onlyoffice-access.conf"
|
||||
owner: "{{ atlas_admin_username }}"
|
||||
group: "{{ atlas_admin_group }}"
|
||||
mode: "0644"
|
||||
register: atlas_onlyoffice_access_configuration
|
||||
|
||||
- name: Download checksum-pinned compatible application releases
|
||||
ansible.builtin.get_url:
|
||||
url: "{{ item.url }}"
|
||||
dest: "{{ atlas_nextcloud_app_cache }}/{{ item.id }}-{{ item.version }}.tar.gz"
|
||||
checksum: "{{ item.checksum }}"
|
||||
owner: "{{ atlas_admin_username }}"
|
||||
group: "{{ atlas_admin_group }}"
|
||||
mode: "0644"
|
||||
loop: "{{ atlas_nextcloud_apps }}"
|
||||
loop_control:
|
||||
label: "{{ item.id }} {{ item.version }}"
|
||||
when: not ansible_check_mode
|
||||
|
||||
- name: Admit only the Aegis gateway to the Nextcloud and Office HTTP listeners
|
||||
ansible.posix.firewalld:
|
||||
rich_rule: >-
|
||||
rule family="ipv4" source address="{{ atlas_aegis_ip }}"
|
||||
port port="{{ item }}" protocol="tcp" accept
|
||||
zone: "{{ atlas_firewalld_zone }}"
|
||||
state: enabled
|
||||
permanent: true
|
||||
immediate: true
|
||||
loop: ["{{ atlas_nextcloud_http_port }}", "{{ atlas_onlyoffice_http_port }}"]
|
||||
|
||||
- name: Enable lingering for the declared rootless owner
|
||||
ansible.builtin.command:
|
||||
argv: [loginctl, enable-linger, "{{ atlas_admin_username }}"]
|
||||
creates: "/var/lib/systemd/linger/{{ atlas_admin_username }}"
|
||||
|
||||
- name: Render Nextcloud component and network Quadlets
|
||||
ansible.builtin.template:
|
||||
src: "{{ item }}.j2"
|
||||
dest: "{{ atlas_nextcloud_quadlet_dir }}/{{ item }}"
|
||||
owner: "{{ atlas_admin_username }}"
|
||||
group: "{{ atlas_admin_group }}"
|
||||
mode: "0644"
|
||||
loop:
|
||||
- atlas-nextcloud.network
|
||||
- atlas-nextcloud-db.container
|
||||
- atlas-nextcloud-redis.container
|
||||
- atlas-nextcloud.container
|
||||
- atlas-onlyoffice.container
|
||||
register: atlas_nextcloud_quadlets
|
||||
|
||||
- name: Render recurring Nextcloud cron user units
|
||||
ansible.builtin.template:
|
||||
src: "{{ item }}.j2"
|
||||
dest: "{{ atlas_admin_home }}/.config/systemd/user/{{ item }}"
|
||||
owner: "{{ atlas_admin_username }}"
|
||||
group: "{{ atlas_admin_group }}"
|
||||
mode: "0644"
|
||||
loop: [atlas-nextcloud-cron.service, atlas-nextcloud-cron.timer,
|
||||
atlas-nextcloud-external-scan.service, atlas-nextcloud-external-scan.timer]
|
||||
register: atlas_nextcloud_cron_units
|
||||
|
||||
- name: Manage and verify rootless Nextcloud services
|
||||
become_user: "{{ atlas_admin_username }}"
|
||||
environment:
|
||||
XDG_RUNTIME_DIR: "/run/user/{{ atlas_admin_uid }}"
|
||||
DBUS_SESSION_BUS_ADDRESS: "unix:path=/run/user/{{ atlas_admin_uid }}/bus"
|
||||
when: not ansible_check_mode
|
||||
block:
|
||||
- name: Pull the pinned images before starting services
|
||||
containers.podman.podman_image:
|
||||
name: "{{ item }}"
|
||||
state: present
|
||||
loop:
|
||||
- "{{ atlas_nextcloud_image }}"
|
||||
- "{{ atlas_nextcloud_postgres_image }}"
|
||||
- "{{ atlas_nextcloud_redis_image }}"
|
||||
- "{{ atlas_onlyoffice_image }}"
|
||||
|
||||
- name: Reload the user manager to generate component units
|
||||
ansible.builtin.systemd:
|
||||
scope: user
|
||||
daemon_reload: true
|
||||
|
||||
- name: Start the declared Nextcloud and ONLYOFFICE services
|
||||
ansible.builtin.systemd:
|
||||
scope: user
|
||||
name: "{{ item }}"
|
||||
state: >-
|
||||
{{ 'restarted' if (
|
||||
atlas_nextcloud_quadlets.results |
|
||||
selectattr('item', 'equalto', item | replace('.service', '.container')) |
|
||||
selectattr('changed') | list | length > 0 or
|
||||
atlas_nextcloud_quadlets.results |
|
||||
selectattr('item', 'equalto', 'atlas-nextcloud.network') |
|
||||
selectattr('changed') | list | length > 0 or
|
||||
(item == 'atlas-onlyoffice.service' and atlas_onlyoffice_access_configuration is changed) or
|
||||
atlas_nextcloud_private_configuration is changed or
|
||||
atlas_nextcloud_secret_files is changed) else 'started' }}
|
||||
loop: "{{ atlas_nextcloud_services }}"
|
||||
|
||||
- name: Wait for the application configuration directory to be initialized
|
||||
become: true
|
||||
become_user: root
|
||||
ansible.builtin.wait_for:
|
||||
path: "{{ atlas_nextcloud_root }}/app/config/config.php"
|
||||
timeout: 600
|
||||
|
||||
- name: Derive container web-user host IDs from the actual rootless maps
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- podman
|
||||
- unshare
|
||||
- python3
|
||||
- -c
|
||||
- >-
|
||||
import json;
|
||||
print(json.dumps({k: next(int(b)+33-int(a) for a,b,n in
|
||||
(l.split() for l in open('/proc/self/'+k+'_map'))
|
||||
if int(a)<=33<int(a)+int(n)) for k in ['uid','gid']}))
|
||||
register: atlas_nextcloud_web_mapping
|
||||
changed_when: false
|
||||
|
||||
- name: Read the current application SELinux label without changing it
|
||||
become: true
|
||||
become_user: root
|
||||
ansible.builtin.command:
|
||||
argv: [stat, -c, '%C', "{{ atlas_nextcloud_root }}/app/config"]
|
||||
register: atlas_nextcloud_config_label
|
||||
changed_when: false
|
||||
|
||||
- name: Maintain the managed Nextcloud configuration include
|
||||
become: true
|
||||
become_user: root
|
||||
ansible.builtin.template:
|
||||
src: atlas-nextcloud.config.php.j2
|
||||
dest: "{{ atlas_nextcloud_root }}/app/config/atlas.config.php"
|
||||
owner: "{{ (atlas_nextcloud_web_mapping.stdout | from_json).uid }}"
|
||||
group: "{{ (atlas_nextcloud_web_mapping.stdout | from_json).gid }}"
|
||||
mode: "0640"
|
||||
seuser: "{{ atlas_nextcloud_config_label.stdout.split(':')[0] }}"
|
||||
serole: "{{ atlas_nextcloud_config_label.stdout.split(':')[1] }}"
|
||||
setype: "{{ atlas_nextcloud_config_label.stdout.split(':')[2] }}"
|
||||
selevel: "{{ atlas_nextcloud_config_label.stdout.split(':')[3:] | join(':') }}"
|
||||
diff: false
|
||||
|
||||
- name: Wait for Nextcloud to complete its initial installation
|
||||
ansible.builtin.command:
|
||||
argv: [podman, exec, --user, '33', atlas-nextcloud, php, occ, status, --output=json]
|
||||
register: atlas_nextcloud_status
|
||||
changed_when: false
|
||||
retries: 60
|
||||
delay: 10
|
||||
until: >-
|
||||
atlas_nextcloud_status.rc == 0 and
|
||||
atlas_nextcloud_status.stdout.startswith('{') and
|
||||
(atlas_nextcloud_status.stdout | from_json).installed | default(false)
|
||||
|
||||
- name: Import declared ongoing application and account configuration
|
||||
ansible.builtin.include_tasks: nextcloud_application.yml
|
||||
|
||||
- name: Enable and start the recurring Nextcloud cron timer
|
||||
ansible.builtin.systemd:
|
||||
scope: user
|
||||
name: atlas-nextcloud-cron.timer
|
||||
state: "{{ 'restarted' if atlas_nextcloud_cron_units is changed else 'started' }}"
|
||||
enabled: true
|
||||
|
||||
- name: Enable periodic targeted Archive discovery
|
||||
ansible.builtin.systemd:
|
||||
scope: user
|
||||
name: atlas-nextcloud-external-scan.timer
|
||||
state: "{{ 'restarted' if atlas_nextcloud_cron_units is changed else 'started' }}"
|
||||
enabled: true
|
||||
when: atlas_nextcloud_external_mounts | length > 0
|
||||
|
||||
- name: Verify ONLYOFFICE local health without publishing the domain
|
||||
ansible.builtin.uri:
|
||||
url: "http://127.0.0.1:{{ atlas_onlyoffice_http_port }}/healthcheck"
|
||||
return_content: true
|
||||
register: atlas_onlyoffice_health
|
||||
retries: 60
|
||||
delay: 10
|
||||
until: atlas_onlyoffice_health.status | default(0) == 200 and atlas_onlyoffice_health.content | default('') | trim == 'true'
|
||||
@@ -1,186 +0,0 @@
|
||||
---
|
||||
- name: Inspect installed application state
|
||||
ansible.builtin.command:
|
||||
argv: [podman, exec, --user, '33', atlas-nextcloud, php, occ, app:list, --output=json]
|
||||
register: atlas_nextcloud_current_apps
|
||||
changed_when: false
|
||||
|
||||
- name: Record enabled and disabled application versions
|
||||
ansible.builtin.set_fact:
|
||||
atlas_nextcloud_installed_apps: >-
|
||||
{{ (atlas_nextcloud_current_apps.stdout | from_json).enabled |
|
||||
combine((atlas_nextcloud_current_apps.stdout | from_json).disabled) }}
|
||||
|
||||
- name: Refuse implicit application upgrades or downgrades
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- item.id not in atlas_nextcloud_installed_apps or atlas_nextcloud_installed_apps[item.id] == item.version
|
||||
fail_msg: Application versions must be changed in a deliberate upgrade window.
|
||||
loop: "{{ atlas_nextcloud_apps }}"
|
||||
loop_control:
|
||||
label: "{{ item.id }}"
|
||||
|
||||
- name: Install only absent checksum-verified application archives
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- podman
|
||||
- exec
|
||||
- --user
|
||||
- '33'
|
||||
- atlas-nextcloud
|
||||
- tar
|
||||
- -xzf
|
||||
- "/mnt/atlas-apps/{{ item.id }}-{{ item.version }}.tar.gz"
|
||||
- -C
|
||||
- /var/www/html/custom_apps
|
||||
loop: "{{ atlas_nextcloud_apps }}"
|
||||
loop_control:
|
||||
label: "{{ item.id }}"
|
||||
when: item.id not in atlas_nextcloud_installed_apps
|
||||
changed_when: true
|
||||
|
||||
- name: Enable the declared applications
|
||||
ansible.builtin.command:
|
||||
argv: [podman, exec, --user, '33', atlas-nextcloud, php, occ, app:enable, "{{ item.id }}"]
|
||||
loop: "{{ atlas_nextcloud_apps }}"
|
||||
loop_control:
|
||||
label: "{{ item.id }}"
|
||||
when: item.id not in (atlas_nextcloud_current_apps.stdout | from_json).enabled
|
||||
changed_when: true
|
||||
|
||||
- name: Inspect existing application users without exposing passwords
|
||||
ansible.builtin.command:
|
||||
argv: [podman, exec, --user, '33', atlas-nextcloud, php, occ, user:list, --output=json]
|
||||
register: atlas_nextcloud_current_users
|
||||
changed_when: false
|
||||
|
||||
- name: Ensure the two standard users exist without resetting existing passwords
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- podman
|
||||
- exec
|
||||
- --user
|
||||
- '33'
|
||||
- --env
|
||||
- OC_PASS
|
||||
- atlas-nextcloud
|
||||
- php
|
||||
- occ
|
||||
- user:add
|
||||
- --password-from-env
|
||||
- --display-name
|
||||
- "{{ item.display_name }}"
|
||||
- "{{ item.username }}"
|
||||
environment:
|
||||
OC_PASS: "{{ item.password }}"
|
||||
loop: "{{ atlas_nextcloud_users }}"
|
||||
when: item.username not in (atlas_nextcloud_current_users.stdout | from_json)
|
||||
changed_when: true
|
||||
no_log: true
|
||||
diff: false
|
||||
|
||||
- name: Inspect standard-user group membership and quota
|
||||
ansible.builtin.command:
|
||||
argv: [podman, exec, --user, '33', atlas-nextcloud, php, occ, user:info, --output=json, "{{ item.username }}"]
|
||||
loop: "{{ atlas_nextcloud_users }}"
|
||||
loop_control:
|
||||
label: "{{ item.username }}"
|
||||
register: atlas_nextcloud_user_info
|
||||
changed_when: false
|
||||
no_log: true
|
||||
|
||||
- name: Require that family users are not administrators
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- "'admin' not in (item.stdout | from_json).groups"
|
||||
loop: "{{ atlas_nextcloud_user_info.results }}"
|
||||
no_log: true
|
||||
|
||||
- name: Maintain unlimited initial standard-user quotas
|
||||
ansible.builtin.command:
|
||||
argv: [podman, exec, --user, '33', atlas-nextcloud, php, occ, user:setting, "{{ item.item.username }}", files, quota, none]
|
||||
loop: "{{ atlas_nextcloud_user_info.results }}"
|
||||
when: (item.stdout | from_json).quota != 'none'
|
||||
changed_when: true
|
||||
no_log: true
|
||||
|
||||
- name: Inspect the family group
|
||||
ansible.builtin.command:
|
||||
argv: [podman, exec, --user, '33', atlas-nextcloud, php, occ, group:list, --output=json]
|
||||
register: atlas_nextcloud_groups
|
||||
changed_when: false
|
||||
|
||||
- name: Ensure the family group exists
|
||||
ansible.builtin.command:
|
||||
argv: [podman, exec, --user, '33', atlas-nextcloud, php, occ, group:add, famiglia]
|
||||
when: "'famiglia' not in (atlas_nextcloud_groups.stdout | from_json)"
|
||||
changed_when: true
|
||||
|
||||
- name: Ensure both standard users belong to the family group
|
||||
ansible.builtin.command:
|
||||
argv: [podman, exec, --user, '33', atlas-nextcloud, php, occ, group:adduser, famiglia, "{{ item.username }}"]
|
||||
loop: "{{ atlas_nextcloud_users }}"
|
||||
when: item.username not in ((atlas_nextcloud_groups.stdout | from_json).get('famiglia', []))
|
||||
changed_when: true
|
||||
no_log: true
|
||||
|
||||
- name: Inspect configured family folders
|
||||
ansible.builtin.command:
|
||||
argv: [podman, exec, --user, '33', atlas-nextcloud, php, occ, groupfolders:list, --output=json]
|
||||
register: atlas_nextcloud_folders_before
|
||||
changed_when: false
|
||||
|
||||
- name: Ensure a shared Famiglia folder exists
|
||||
ansible.builtin.command:
|
||||
argv: [podman, exec, --user, '33', atlas-nextcloud, php, occ, groupfolders:create, Famiglia]
|
||||
when: >-
|
||||
(atlas_nextcloud_folders_before.stdout | from_json |
|
||||
selectattr('mountPoint', 'equalto', 'Famiglia') | list | length) == 0
|
||||
changed_when: true
|
||||
|
||||
- name: Inspect the resulting family folder
|
||||
ansible.builtin.command:
|
||||
argv: [podman, exec, --user, '33', atlas-nextcloud, php, occ, groupfolders:list, --output=json]
|
||||
register: atlas_nextcloud_folders_after
|
||||
changed_when: false
|
||||
|
||||
- name: Select the existing family folder without changing unrelated folders
|
||||
ansible.builtin.set_fact:
|
||||
atlas_nextcloud_family_folder: >-
|
||||
{{ atlas_nextcloud_folders_after.stdout | from_json |
|
||||
selectattr('mountPoint', 'equalto', 'Famiglia') | first }}
|
||||
|
||||
- name: Maintain family read, create, write and delete permissions
|
||||
ansible.builtin.command:
|
||||
argv: [podman, exec, --user, '33', atlas-nextcloud, php, occ, groupfolders:group,
|
||||
"{{ atlas_nextcloud_family_folder.id }}", famiglia, write, delete]
|
||||
when: (atlas_nextcloud_family_folder.groups_list | default({}, true)).get('famiglia', 0) | int != 15
|
||||
changed_when: true
|
||||
|
||||
- name: Inspect the background job mode
|
||||
ansible.builtin.command:
|
||||
argv: [podman, exec, --user, '33', atlas-nextcloud, php, occ, config:app:get, core, backgroundjobs_mode]
|
||||
register: atlas_nextcloud_background_mode
|
||||
changed_when: false
|
||||
failed_when: atlas_nextcloud_background_mode.rc not in [0, 1]
|
||||
|
||||
- name: Maintain cron background processing
|
||||
ansible.builtin.command:
|
||||
argv: [podman, exec, --user, '33', atlas-nextcloud, php, occ, background:cron]
|
||||
when: atlas_nextcloud_background_mode.stdout | trim != 'cron'
|
||||
changed_when: true
|
||||
|
||||
- name: Enable shipped external storage support when required
|
||||
ansible.builtin.command:
|
||||
argv: [podman, exec, --user, '33', atlas-nextcloud, php, occ, app:enable, files_external]
|
||||
when:
|
||||
- atlas_nextcloud_external_mounts | length > 0
|
||||
- "'files_external' not in (atlas_nextcloud_current_apps.stdout | from_json).enabled"
|
||||
changed_when: true
|
||||
|
||||
- name: Maintain only the declared Archive mounts
|
||||
ansible.builtin.include_tasks: nextcloud_external_mount.yml
|
||||
loop: "{{ atlas_nextcloud_external_mounts }}"
|
||||
loop_control:
|
||||
loop_var: atlas_nextcloud_mount
|
||||
label: "{{ atlas_nextcloud_mount.name }}"
|
||||
@@ -1,58 +0,0 @@
|
||||
---
|
||||
- name: Manage recurring consistent Nextcloud backup preparation
|
||||
tags: [atlas, nextcloud_backup]
|
||||
when: atlas_manage_nextcloud | bool
|
||||
block:
|
||||
- name: Validate private backup scope, retention, and bundle reuse window
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- atlas_nextcloud_backup_root == atlas_mount_root ~ '/backup/nextcloud'
|
||||
- atlas_nextcloud_backup_keep | int >= 2
|
||||
- atlas_nextcloud_backup_reuse_max_seconds | int >= 0
|
||||
# Below 24h the nightly Borg run cannot reuse the previous bundle.
|
||||
- atlas_nextcloud_backup_reuse_max_seconds | int < 86400
|
||||
- atlas_manage_borg_backup | bool
|
||||
- atlas_manage_usb_backup | bool
|
||||
|
||||
- name: Install recurring backup helper with shell syntax validation
|
||||
ansible.builtin.template:
|
||||
src: atlas-nextcloud-backup.sh.j2
|
||||
dest: /usr/local/sbin/atlas-nextcloud-backup
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0750"
|
||||
validate: /bin/bash -n %s
|
||||
|
||||
- name: Install Nextcloud backup preparation and boot recovery units
|
||||
ansible.builtin.template:
|
||||
src: "{{ item }}.j2"
|
||||
dest: "/etc/systemd/system/{{ item }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
loop: [atlas-nextcloud-backup.service, atlas-nextcloud-backup-recovery.service]
|
||||
|
||||
- name: Create backup dependency drop-in directories
|
||||
ansible.builtin.file:
|
||||
path: "/etc/systemd/system/{{ item }}.d"
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0755"
|
||||
loop: [atlas-borg-backup.service, atlas-usb-backup.service]
|
||||
|
||||
- name: Require a fresh consistent bundle before offsite and manual USB backups
|
||||
ansible.builtin.template:
|
||||
src: atlas-nextcloud-backup-dependency.conf.j2
|
||||
dest: "/etc/systemd/system/{{ item }}.d/nextcloud.conf"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
loop: [atlas-borg-backup.service, atlas-usb-backup.service]
|
||||
|
||||
- name: Reload systemd and enable interruption recovery without running a backup
|
||||
ansible.builtin.systemd:
|
||||
daemon_reload: true
|
||||
name: atlas-nextcloud-backup-recovery.service
|
||||
enabled: true
|
||||
when: not ansible_check_mode
|
||||
@@ -1,112 +0,0 @@
|
||||
---
|
||||
- name: Restrict external storage to explicit Archive directories
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- item.source in [atlas_archive_mountpoint ~ '/Documents', atlas_icloudpd_photos_dir]
|
||||
- item.target is match('^/mnt/archive-[a-z]+$')
|
||||
- item.name is match('^[A-Za-z][A-Za-z ]+$')
|
||||
- item.readonly is boolean
|
||||
- item.user in (atlas_nextcloud_users | map(attribute='username') | list)
|
||||
- item.source != atlas_icloudpd_photos_dir or item.readonly
|
||||
loop: "{{ atlas_nextcloud_external_mounts }}"
|
||||
|
||||
- name: Inspect existing sources without creating or moving data
|
||||
ansible.builtin.stat:
|
||||
path: "{{ item.source }}"
|
||||
follow: false
|
||||
loop: "{{ atlas_nextcloud_external_mounts }}"
|
||||
register: atlas_nextcloud_external_sources
|
||||
|
||||
- name: Refuse missing sources and symlinks
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- item.stat.isdir | default(false)
|
||||
- not (item.stat.islnk | default(false))
|
||||
loop: "{{ atlas_nextcloud_external_sources.results }}"
|
||||
loop_control:
|
||||
label: "{{ item.item.source }}"
|
||||
|
||||
- name: Verify the Archive dataset before modifying its ACL capability
|
||||
community.general.zfs_facts:
|
||||
name: "{{ atlas_zfs_pool }}/{{ atlas_zfs_dataset_archive }}"
|
||||
properties: name,mounted,mountpoint
|
||||
register: atlas_nextcloud_external_dataset
|
||||
|
||||
- name: Refuse an absent or unmounted Archive dataset
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- atlas_nextcloud_external_dataset.ansible_facts.ansible_zfs_datasets | length == 1
|
||||
- atlas_nextcloud_external_dataset.ansible_facts.ansible_zfs_datasets[0].mounted == 'yes'
|
||||
- atlas_nextcloud_external_dataset.ansible_facts.ansible_zfs_datasets[0].mountpoint == atlas_archive_mountpoint
|
||||
|
||||
- name: Enable persistent POSIX ACL support on the verified Archive dataset
|
||||
community.general.zfs:
|
||||
name: "{{ atlas_zfs_pool }}/{{ atlas_zfs_dataset_archive }}"
|
||||
state: present
|
||||
extra_zfs_properties:
|
||||
acltype: posix
|
||||
|
||||
- name: Derive actual rootless web UID for narrowly scoped Archive ACLs
|
||||
become_user: "{{ atlas_admin_username }}"
|
||||
environment:
|
||||
XDG_RUNTIME_DIR: "/run/user/{{ atlas_admin_uid }}"
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- podman
|
||||
- unshare
|
||||
- python3
|
||||
- -c
|
||||
- >-
|
||||
print(next(int(b)+33-int(a) for a,b,n in
|
||||
(l.split() for l in open('/proc/self/uid_map')) if int(a)<=33<int(a)+int(n)))
|
||||
register: atlas_nextcloud_external_uid
|
||||
changed_when: false
|
||||
check_mode: false
|
||||
|
||||
- name: Grant web user access only inside the declared sources
|
||||
ansible.posix.acl:
|
||||
path: "{{ item.source }}"
|
||||
entity: "{{ atlas_nextcloud_external_uid.stdout | trim }}"
|
||||
etype: user
|
||||
permissions: "{{ 'rX' if item.readonly else 'rwX' }}"
|
||||
recursive: true
|
||||
follow: false
|
||||
state: present
|
||||
loop: "{{ atlas_nextcloud_external_mounts }}"
|
||||
|
||||
- name: Restore effective web write access inside writable external storage
|
||||
ansible.posix.acl:
|
||||
path: "{{ item.source }}"
|
||||
etype: mask
|
||||
permissions: rwX
|
||||
recursive: true
|
||||
follow: false
|
||||
recalculate_mask: no_mask
|
||||
state: present
|
||||
loop: "{{ atlas_nextcloud_external_mounts }}"
|
||||
when: not item.readonly
|
||||
|
||||
- name: Inherit web access on new files and directories
|
||||
ansible.posix.acl:
|
||||
path: "{{ item.source }}"
|
||||
entity: "{{ atlas_nextcloud_external_uid.stdout | trim }}"
|
||||
etype: user
|
||||
permissions: "{{ 'rX' if item.readonly else 'rwX' }}"
|
||||
default: true
|
||||
recursive: true
|
||||
follow: false
|
||||
state: present
|
||||
loop: "{{ atlas_nextcloud_external_mounts }}"
|
||||
|
||||
- name: Preserve administrator access to documents created through Nextcloud
|
||||
ansible.posix.acl:
|
||||
path: "{{ item.source }}"
|
||||
entity: "{{ atlas_admin_uid }}"
|
||||
etype: user
|
||||
permissions: rwX
|
||||
default: true
|
||||
recursive: true
|
||||
follow: false
|
||||
state: present
|
||||
loop: "{{ atlas_nextcloud_external_mounts }}"
|
||||
when: not item.readonly
|
||||
@@ -1,94 +0,0 @@
|
||||
---
|
||||
- name: Inspect current system mounts without exposing credentials
|
||||
ansible.builtin.command:
|
||||
argv: [podman, exec, --user, '33', atlas-nextcloud, php, occ, files_external:list, --output=json]
|
||||
register: atlas_nextcloud_mount_list
|
||||
changed_when: false
|
||||
no_log: true
|
||||
|
||||
- name: Select only the matching mount name
|
||||
ansible.builtin.set_fact:
|
||||
atlas_nextcloud_matching_mounts: >-
|
||||
{{ atlas_nextcloud_mount_list.stdout | from_json |
|
||||
selectattr('mount_point', 'equalto', '/' ~ atlas_nextcloud_mount.name) | list }}
|
||||
no_log: true
|
||||
|
||||
- name: Refuse duplicates or repurposing of existing unrelated storage
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- atlas_nextcloud_matching_mounts | length <= 1
|
||||
- >-
|
||||
atlas_nextcloud_matching_mounts | length == 0 or
|
||||
(atlas_nextcloud_matching_mounts[0].configuration.datadir | default('') == atlas_nextcloud_mount.target
|
||||
and atlas_nextcloud_matching_mounts[0].storage == '\\OC\\Files\\Storage\\Local')
|
||||
fail_msg: Existing storage conflicts with the declared Archive mount; refusing an implicit replacement.
|
||||
|
||||
- name: Create an absent local mount restricted to its declared user
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- podman
|
||||
- exec
|
||||
- --user
|
||||
- '33'
|
||||
- atlas-nextcloud
|
||||
- php
|
||||
- occ
|
||||
- files_external:create
|
||||
- "{{ atlas_nextcloud_mount.name }}"
|
||||
- local
|
||||
- null::null
|
||||
- --config
|
||||
- "datadir={{ atlas_nextcloud_mount.target }}"
|
||||
- --applicable-user
|
||||
- "{{ atlas_nextcloud_mount.user }}"
|
||||
- --output=json
|
||||
when: atlas_nextcloud_matching_mounts | length == 0
|
||||
register: atlas_nextcloud_mount_created
|
||||
changed_when: true
|
||||
|
||||
- name: Record the managed mount ID and options
|
||||
ansible.builtin.set_fact:
|
||||
atlas_nextcloud_mount_id: >-
|
||||
{{ atlas_nextcloud_mount_created.stdout | trim if atlas_nextcloud_matching_mounts | length == 0
|
||||
else atlas_nextcloud_matching_mounts[0].mount_id }}
|
||||
atlas_nextcloud_mount_options: >-
|
||||
{{ {} if atlas_nextcloud_matching_mounts | length == 0 else atlas_nextcloud_matching_mounts[0].options }}
|
||||
|
||||
- name: Restrict the managed mount to exactly its declared user
|
||||
ansible.builtin.command:
|
||||
argv: >-
|
||||
{{ ['podman', 'exec', '--user', '33', 'atlas-nextcloud', 'php', 'occ',
|
||||
'files_external:applicable', atlas_nextcloud_mount_id | string,
|
||||
'--add-user=' ~ atlas_nextcloud_mount.user] +
|
||||
(atlas_nextcloud_matching_mounts[0].applicable_groups |
|
||||
map('regex_replace', '^', '--remove-group=') | list) +
|
||||
(atlas_nextcloud_matching_mounts[0].applicable_users |
|
||||
reject('equalto', atlas_nextcloud_mount.user) |
|
||||
map('regex_replace', '^', '--remove-user=') | list) }}
|
||||
when:
|
||||
- atlas_nextcloud_matching_mounts | length > 0
|
||||
- >-
|
||||
atlas_nextcloud_matching_mounts[0].applicable_groups | length > 0 or
|
||||
atlas_nextcloud_matching_mounts[0].applicable_users != [atlas_nextcloud_mount.user]
|
||||
changed_when: true
|
||||
|
||||
- name: Maintain read-only photos and external change detection
|
||||
ansible.builtin.command:
|
||||
argv: [podman, exec, --user, '33', atlas-nextcloud, php, occ, files_external:option,
|
||||
"{{ atlas_nextcloud_mount_id }}", "{{ item.key }}", "{{ item.value | to_json }}"]
|
||||
loop:
|
||||
- {key: readonly, value: "{{ atlas_nextcloud_mount.readonly }}"}
|
||||
- {key: filesystem_check_changes, value: 1}
|
||||
- {key: enable_sharing, value: false}
|
||||
# Nextcloud persists option values as strings ("1" / "" for booleans).
|
||||
when: >-
|
||||
item.key not in atlas_nextcloud_mount_options or
|
||||
atlas_nextcloud_mount_options[item.key] | string !=
|
||||
(('1' if item.value else '') if item.value is boolean else item.value | string)
|
||||
changed_when: true
|
||||
|
||||
- name: Verify the managed local storage is accessible
|
||||
ansible.builtin.command:
|
||||
argv: [podman, exec, --user, '33', atlas-nextcloud, php, occ, files_external:verify,
|
||||
"{{ atlas_nextcloud_mount_id }}"]
|
||||
changed_when: false
|
||||
@@ -1,255 +0,0 @@
|
||||
---
|
||||
- name: Manage Atlas rootless Paperless-ngx
|
||||
tags: [atlas, paperless]
|
||||
when: atlas_manage_paperless | bool
|
||||
block:
|
||||
- name: Require isolated Paperless state, public domain and pinned images
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- atlas_manage_storage | bool
|
||||
- atlas_manage_firewall | bool
|
||||
- atlas_paperless_root == atlas_app_data_mountpoint ~ '/paperless'
|
||||
- atlas_paperless_dataset == atlas_zfs_pool ~ '/services/data/paperless'
|
||||
- atlas_paperless_domain is match('^[a-z0-9]+([.-][a-z0-9]+)+$')
|
||||
- atlas_paperless_http_port | int > 1024
|
||||
- atlas_paperless_http_port | int < 65536
|
||||
- atlas_paperless_network_subnet != atlas_nextcloud_network_subnet
|
||||
- item is search('@sha256:[0-9a-f]{64}$')
|
||||
loop:
|
||||
- "{{ atlas_paperless_image }}"
|
||||
- "{{ atlas_paperless_postgres_image }}"
|
||||
- "{{ atlas_paperless_valkey_image }}"
|
||||
- "{{ atlas_paperless_tika_image }}"
|
||||
- "{{ atlas_paperless_gotenberg_image }}"
|
||||
- "{{ atlas_paperless_ollama_image }}"
|
||||
|
||||
- name: Require dedicated Paperless Vault secrets without exposing them
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- vault_paperless_database_password | default('') is match('^[a-zA-Z0-9]{32,}$')
|
||||
- vault_paperless_secret_key | default('') | length >= 64
|
||||
no_log: true
|
||||
|
||||
- name: Verify the existing application-data parent is mounted
|
||||
community.general.zfs_facts:
|
||||
name: "{{ atlas_zfs_pool }}/{{ atlas_zfs_dataset_app_data }}"
|
||||
properties: name,mounted,mountpoint
|
||||
register: atlas_paperless_parent
|
||||
|
||||
- name: Require the verified application-data parent
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- atlas_paperless_parent.ansible_facts.ansible_zfs_datasets | length == 1
|
||||
- atlas_paperless_parent.ansible_facts.ansible_zfs_datasets[0].mounted == 'yes'
|
||||
- atlas_paperless_parent.ansible_facts.ansible_zfs_datasets[0].mountpoint == atlas_app_data_mountpoint
|
||||
|
||||
- name: Create dedicated Paperless component datasets
|
||||
community.general.zfs:
|
||||
name: "{{ atlas_paperless_dataset }}{{ item }}"
|
||||
state: present
|
||||
extra_zfs_properties:
|
||||
compression: zstd
|
||||
mountpoint: "{{ atlas_paperless_root }}{{ item }}"
|
||||
loop: ['', /data, /media, /consume, /database, /cache, /ollama]
|
||||
|
||||
- name: Prepare private Paperless paths and Quadlet directory
|
||||
ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
owner: "{{ atlas_admin_username }}"
|
||||
group: "{{ atlas_admin_group }}"
|
||||
mode: "0700"
|
||||
loop:
|
||||
- "{{ atlas_paperless_root }}"
|
||||
- "{{ atlas_paperless_root }}/data"
|
||||
- "{{ atlas_paperless_root }}/media"
|
||||
- "{{ atlas_paperless_root }}/consume"
|
||||
- "{{ atlas_paperless_root }}/ollama"
|
||||
- "{{ atlas_paperless_private_dir }}"
|
||||
- "{{ atlas_paperless_quadlet_dir }}"
|
||||
|
||||
- name: Derive the rootless PostgreSQL host UID
|
||||
become_user: "{{ atlas_admin_username }}"
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- podman
|
||||
- unshare
|
||||
- python3
|
||||
- -c
|
||||
- >-
|
||||
print(next(int(host) + 999 - int(container) for container, host, size in
|
||||
(line.split() for line in open('/proc/self/uid_map'))
|
||||
if int(container) <= 999 < int(container) + int(size)))
|
||||
register: atlas_paperless_postgres_host_uid
|
||||
check_mode: false
|
||||
changed_when: false
|
||||
|
||||
- name: Allow the rootless PostgreSQL UID to traverse its dataset root
|
||||
ansible.builtin.file:
|
||||
path: "{{ atlas_paperless_root }}/database"
|
||||
state: directory
|
||||
owner: "{{ atlas_paperless_postgres_host_uid.stdout | trim }}"
|
||||
group: "{{ atlas_admin_group }}"
|
||||
mode: "0700"
|
||||
|
||||
- name: Allow the rootless Valkey UID to write its persistent cache
|
||||
ansible.builtin.file:
|
||||
path: "{{ atlas_paperless_root }}/cache"
|
||||
state: directory
|
||||
owner: "{{ atlas_paperless_postgres_host_uid.stdout | trim }}"
|
||||
group: "{{ atlas_admin_group }}"
|
||||
mode: "0700"
|
||||
register: atlas_paperless_cache_root
|
||||
|
||||
- name: Store Paperless secrets in private mounted files
|
||||
ansible.builtin.copy:
|
||||
content: "{{ item.value }}\n"
|
||||
dest: "{{ atlas_paperless_private_dir }}/{{ item.name }}"
|
||||
owner: "{{ atlas_admin_username }}"
|
||||
group: "{{ atlas_admin_group }}"
|
||||
mode: "0644"
|
||||
loop:
|
||||
- {name: postgres-password, value: "{{ vault_paperless_database_password }}"}
|
||||
- {name: secret-key, value: "{{ vault_paperless_secret_key }}"}
|
||||
no_log: true
|
||||
diff: false
|
||||
register: atlas_paperless_secret_files
|
||||
|
||||
- name: Admit only the Aegis gateway to the Paperless listener
|
||||
ansible.posix.firewalld:
|
||||
rich_rule: >-
|
||||
rule family="ipv4" source address="{{ atlas_aegis_ip }}"
|
||||
port port="{{ atlas_paperless_http_port }}" protocol="tcp" accept
|
||||
zone: "{{ atlas_firewalld_zone }}"
|
||||
state: enabled
|
||||
permanent: true
|
||||
immediate: true
|
||||
|
||||
- name: Keep the Paperless rootless user manager available at boot
|
||||
ansible.builtin.command:
|
||||
argv: [loginctl, enable-linger, "{{ atlas_admin_username }}"]
|
||||
args:
|
||||
creates: "/var/lib/systemd/linger/{{ atlas_admin_username }}"
|
||||
|
||||
- name: Render the private Paperless Quadlets
|
||||
ansible.builtin.template:
|
||||
src: "{{ item }}.j2"
|
||||
dest: "{{ atlas_paperless_quadlet_dir }}/{{ item }}"
|
||||
owner: "{{ atlas_admin_username }}"
|
||||
group: "{{ atlas_admin_group }}"
|
||||
mode: "0644"
|
||||
loop:
|
||||
- atlas-paperless.network
|
||||
- atlas-paperless-db.container
|
||||
- atlas-paperless-valkey.container
|
||||
- atlas-paperless-tika.container
|
||||
- atlas-paperless-gotenberg.container
|
||||
- atlas-paperless-ollama.container
|
||||
- atlas-paperless.container
|
||||
register: atlas_paperless_quadlets
|
||||
|
||||
- name: Pull, start and verify Paperless
|
||||
become_user: "{{ atlas_admin_username }}"
|
||||
environment:
|
||||
XDG_RUNTIME_DIR: "/run/user/{{ atlas_admin_uid }}"
|
||||
DBUS_SESSION_BUS_ADDRESS: "unix:path=/run/user/{{ atlas_admin_uid }}/bus"
|
||||
when: not ansible_check_mode
|
||||
block:
|
||||
- name: Pull the pinned Paperless images before starting services
|
||||
containers.podman.podman_image:
|
||||
name: "{{ item }}"
|
||||
state: present
|
||||
loop:
|
||||
- "{{ atlas_paperless_image }}"
|
||||
- "{{ atlas_paperless_postgres_image }}"
|
||||
- "{{ atlas_paperless_valkey_image }}"
|
||||
- "{{ atlas_paperless_tika_image }}"
|
||||
- "{{ atlas_paperless_gotenberg_image }}"
|
||||
- "{{ atlas_paperless_ollama_image }}"
|
||||
|
||||
- name: Reload the rootless user manager for Paperless
|
||||
ansible.builtin.systemd:
|
||||
scope: user
|
||||
daemon_reload: true
|
||||
|
||||
- name: Start Paperless component services
|
||||
ansible.builtin.systemd:
|
||||
scope: user
|
||||
name: "{{ item }}"
|
||||
state: >-
|
||||
{{ 'restarted' if
|
||||
(atlas_paperless_quadlets.results |
|
||||
selectattr('item', 'equalto', item | replace('.service', '.container')) |
|
||||
selectattr('changed') | list | length > 0) or
|
||||
(atlas_paperless_quadlets.results |
|
||||
selectattr('item', 'equalto', 'atlas-paperless.network') |
|
||||
selectattr('changed') | list | length > 0) or
|
||||
(atlas_paperless_secret_files is changed and
|
||||
item in ['atlas-paperless-db.service', 'atlas-paperless.service']) or
|
||||
(atlas_paperless_cache_root is changed and
|
||||
item == 'atlas-paperless-valkey.service') else 'started' }}
|
||||
enabled: true
|
||||
loop: "{{ atlas_paperless_services }}"
|
||||
|
||||
- name: Verify the Paperless HTTP service through its LAN listener
|
||||
ansible.builtin.uri:
|
||||
url: "http://{{ ansible_host }}:{{ atlas_paperless_http_port }}/"
|
||||
status_code: [200, 302]
|
||||
register: atlas_paperless_http
|
||||
retries: 60
|
||||
delay: 5
|
||||
until: atlas_paperless_http is succeeded
|
||||
|
||||
- name: Verify the private Ollama API from Paperless
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- podman
|
||||
- exec
|
||||
- atlas-paperless
|
||||
- python3
|
||||
- -c
|
||||
- >-
|
||||
import urllib.request;
|
||||
urllib.request.urlopen('http://atlas-paperless-ollama:11434/api/tags', timeout=10).close()
|
||||
register: atlas_paperless_ollama_health
|
||||
changed_when: false
|
||||
retries: 30
|
||||
delay: 5
|
||||
until: atlas_paperless_ollama_health.rc == 0
|
||||
|
||||
- name: Check whether the local AI models are present
|
||||
ansible.builtin.command:
|
||||
argv: [podman, exec, atlas-paperless-ollama, ollama, show, "{{ item }}"]
|
||||
loop:
|
||||
- "{{ atlas_paperless_llm_model }}"
|
||||
- "{{ atlas_paperless_embedding_model }}"
|
||||
register: atlas_paperless_model_checks
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
|
||||
- name: Download missing local AI models
|
||||
ansible.builtin.command:
|
||||
argv: [podman, exec, atlas-paperless-ollama, ollama, pull, "{{ item.item }}"]
|
||||
loop: "{{ atlas_paperless_model_checks.results }}"
|
||||
when: item.rc != 0
|
||||
loop_control:
|
||||
label: "{{ item.item }}"
|
||||
|
||||
- name: Verify private Office conversion endpoints from Paperless
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- podman
|
||||
- exec
|
||||
- atlas-paperless
|
||||
- python3
|
||||
- -c
|
||||
- >-
|
||||
import urllib.request;
|
||||
urls = ['http://atlas-paperless-tika:9998/version',
|
||||
'http://atlas-paperless-gotenberg:3000/health'];
|
||||
[urllib.request.urlopen(url, timeout=10).close() for url in urls]
|
||||
register: atlas_paperless_office_health
|
||||
changed_when: false
|
||||
retries: 30
|
||||
delay: 5
|
||||
until: atlas_paperless_office_health.rc == 0
|
||||
@@ -16,7 +16,6 @@
|
||||
- name: Inspect declared Atlas pool disks
|
||||
ansible.builtin.stat:
|
||||
path: "{{ item }}"
|
||||
follow: true
|
||||
loop: "{{ atlas_zpool_disks }}"
|
||||
loop_control:
|
||||
label: "{{ item }}"
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
---
|
||||
- name: Validate Atlas Prometheus pull identity inputs
|
||||
tags: [atlas, backup, prometheus_backup, prometheus_backup_key]
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- atlas_prometheus_pull_ssh_dir.startswith('/etc/')
|
||||
- atlas_prometheus_pull_private_key_path.startswith(atlas_prometheus_pull_ssh_dir ~ '/')
|
||||
- atlas_prometheus_pull_known_hosts_path.startswith(atlas_prometheus_pull_ssh_dir ~ '/')
|
||||
- atlas_prometheus_ssh_host_key.startswith(
|
||||
(hostvars['prometheus'].ansible_host | string) ~ ' ssh-ed25519 '
|
||||
)
|
||||
fail_msg: Pin the verified Prometheus ED25519 SSH host key before enabling the pull.
|
||||
when: atlas_manage_prometheus_backup_pull | bool
|
||||
|
||||
- name: Create private Atlas Prometheus pull SSH directory
|
||||
tags: [atlas, backup, prometheus_backup, prometheus_backup_key]
|
||||
ansible.builtin.file:
|
||||
path: "{{ atlas_prometheus_pull_ssh_dir }}"
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0700"
|
||||
when: atlas_manage_prometheus_backup_pull | bool
|
||||
|
||||
- name: Generate Atlas-only Prometheus pull SSH identity
|
||||
tags: [atlas, backup, prometheus_backup, prometheus_backup_key]
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- ssh-keygen
|
||||
- -q
|
||||
- -t
|
||||
- ed25519
|
||||
- -N
|
||||
- ""
|
||||
- -C
|
||||
- atlas-prometheus-pull@atlas
|
||||
- -f
|
||||
- "{{ atlas_prometheus_pull_private_key_path }}"
|
||||
creates: "{{ atlas_prometheus_pull_private_key_path }}"
|
||||
when: atlas_manage_prometheus_backup_pull | bool
|
||||
|
||||
- name: Protect Atlas-only Prometheus pull SSH identity
|
||||
tags: [atlas, backup, prometheus_backup, prometheus_backup_key]
|
||||
ansible.builtin.file:
|
||||
path: "{{ item.path }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "{{ item.mode }}"
|
||||
loop:
|
||||
- { path: "{{ atlas_prometheus_pull_private_key_path }}", mode: "0600" }
|
||||
- { path: "{{ atlas_prometheus_pull_private_key_path }}.pub", mode: "0644" }
|
||||
loop_control:
|
||||
label: "{{ item.path }}"
|
||||
when:
|
||||
- atlas_manage_prometheus_backup_pull | bool
|
||||
- not ansible_check_mode
|
||||
|
||||
- name: Pin Prometheus SSH host key on Atlas
|
||||
tags: [atlas, backup, prometheus_backup, prometheus_backup_key]
|
||||
ansible.builtin.copy:
|
||||
content: "{{ atlas_prometheus_ssh_host_key }}\n"
|
||||
dest: "{{ atlas_prometheus_pull_known_hosts_path }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0600"
|
||||
when: atlas_manage_prometheus_backup_pull | bool
|
||||
@@ -1,90 +0,0 @@
|
||||
---
|
||||
- name: Validate Atlas Prometheus backup pull inputs
|
||||
tags: [atlas, backup, prometheus_backup]
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- atlas_manage_storage | bool
|
||||
- atlas_prometheus_pull_source_user is match('^[a-z_][a-z0-9_-]*$')
|
||||
- atlas_prometheus_pull_source_port | int > 0
|
||||
- atlas_prometheus_pull_source_port | int < 65536
|
||||
- atlas_prometheus_pull_keep_daily | int > 0
|
||||
- atlas_prometheus_pull_keep_weekly | int > 0
|
||||
- atlas_prometheus_pull_keep_monthly | int > 0
|
||||
- atlas_prometheus_pull_max_age_hours | int > 0
|
||||
- atlas_backup_prometheus_mountpoint.startswith(atlas_mount_root ~ '/')
|
||||
fail_msg: Define the Atlas backup destination, source account, and retention before enabling the pull.
|
||||
when: atlas_manage_prometheus_backup_pull | bool
|
||||
|
||||
- name: Validate Atlas Prometheus backup pull calendar
|
||||
tags: [atlas, backup, prometheus_backup]
|
||||
ansible.builtin.command:
|
||||
argv: [systemd-analyze, calendar, "{{ atlas_prometheus_pull_calendar }}"]
|
||||
changed_when: false
|
||||
check_mode: false
|
||||
when: atlas_manage_prometheus_backup_pull | bool
|
||||
|
||||
- name: Create private Atlas Prometheus backup version directory
|
||||
tags: [atlas, backup, prometheus_backup]
|
||||
ansible.builtin.file:
|
||||
path: "{{ atlas_backup_prometheus_mountpoint }}/snapshots"
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0700"
|
||||
when: atlas_manage_prometheus_backup_pull | bool
|
||||
|
||||
- name: Install Atlas Prometheus backup pull helper
|
||||
tags: [atlas, backup, prometheus_backup]
|
||||
ansible.builtin.template:
|
||||
src: atlas-prometheus-pull.sh.j2
|
||||
dest: /usr/local/sbin/atlas-prometheus-pull
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0750"
|
||||
when: atlas_manage_prometheus_backup_pull | bool
|
||||
|
||||
- name: Install Atlas Prometheus backup retention helper
|
||||
tags: [atlas, backup, prometheus_backup]
|
||||
ansible.builtin.copy:
|
||||
src: atlas-prometheus-prune.py
|
||||
dest: /usr/local/libexec/atlas-prometheus-prune
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0750"
|
||||
when: atlas_manage_prometheus_backup_pull | bool
|
||||
|
||||
- name: Install Atlas Prometheus backup pull systemd units
|
||||
tags: [atlas, backup, prometheus_backup]
|
||||
ansible.builtin.template:
|
||||
src: "{{ item }}.j2"
|
||||
dest: "/etc/systemd/system/{{ item }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
loop:
|
||||
- atlas-prometheus-pull.service
|
||||
- atlas-prometheus-pull.timer
|
||||
loop_control:
|
||||
label: "{{ item }}"
|
||||
register: atlas_prometheus_pull_units
|
||||
when: atlas_manage_prometheus_backup_pull | bool
|
||||
|
||||
- name: Reload systemd after Atlas Prometheus pull unit changes
|
||||
tags: [atlas, backup, prometheus_backup]
|
||||
ansible.builtin.systemd:
|
||||
daemon_reload: true
|
||||
when:
|
||||
- atlas_manage_prometheus_backup_pull | bool
|
||||
- atlas_prometheus_pull_units is changed
|
||||
- not ansible_check_mode
|
||||
|
||||
- name: Enable Atlas Prometheus pull timer only after explicit activation
|
||||
tags: [atlas, backup, prometheus_backup]
|
||||
ansible.builtin.systemd:
|
||||
name: atlas-prometheus-pull.timer
|
||||
enabled: true
|
||||
state: started
|
||||
when:
|
||||
- atlas_manage_prometheus_backup_pull | bool
|
||||
- atlas_prometheus_pull_start_timer | bool
|
||||
- not ansible_check_mode
|
||||
@@ -1,186 +0,0 @@
|
||||
---
|
||||
- name: Manage Atlas rootless qBittorrent
|
||||
tags: [atlas, qbittorrent]
|
||||
when: atlas_manage_qbittorrent | bool
|
||||
block:
|
||||
- name: Require isolated paths and a pinned image
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- atlas_manage_storage | bool
|
||||
- atlas_qbittorrent_state_dir == atlas_app_data_mountpoint ~ '/qbittorrent'
|
||||
- atlas_qbittorrent_downloads_dir == atlas_archive_mountpoint ~ '/Downloads'
|
||||
- atlas_qbittorrent_image is search('@sha256:[0-9a-f]{64}$')
|
||||
|
||||
- name: Inspect the existing parent datasets
|
||||
community.general.zfs_facts:
|
||||
name: "{{ item.dataset }}"
|
||||
properties: name,mounted,mountpoint
|
||||
loop:
|
||||
- dataset: "{{ atlas_zfs_pool }}/{{ atlas_zfs_dataset_archive }}"
|
||||
mountpoint: "{{ atlas_archive_mountpoint }}"
|
||||
- dataset: "{{ atlas_zfs_pool }}/{{ atlas_zfs_dataset_app_data }}"
|
||||
mountpoint: "{{ atlas_app_data_mountpoint }}"
|
||||
register: atlas_qbittorrent_parents
|
||||
|
||||
- name: Refuse missing or unmounted parent datasets
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- item.ansible_facts.ansible_zfs_datasets | length == 1
|
||||
- item.ansible_facts.ansible_zfs_datasets[0].mounted == 'yes'
|
||||
- item.ansible_facts.ansible_zfs_datasets[0].mountpoint == item.item.mountpoint
|
||||
loop: "{{ atlas_qbittorrent_parents.results }}"
|
||||
loop_control:
|
||||
label: "{{ item.item.dataset }}"
|
||||
|
||||
- name: Inspect the proposed download directory without following links
|
||||
ansible.builtin.stat:
|
||||
path: "{{ atlas_qbittorrent_downloads_dir }}"
|
||||
follow: false
|
||||
register: atlas_qbittorrent_downloads
|
||||
|
||||
- name: Refuse unrelated or symlinked download paths
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- >-
|
||||
not atlas_qbittorrent_downloads.stat.exists or
|
||||
(atlas_qbittorrent_downloads.stat.isdir | default(false) and
|
||||
atlas_qbittorrent_downloads.stat.uid | int == atlas_admin_uid | int)
|
||||
|
||||
- name: Create the dedicated configuration dataset
|
||||
community.general.zfs:
|
||||
name: "{{ atlas_zfs_pool }}/services/data/qbittorrent"
|
||||
state: present
|
||||
extra_zfs_properties:
|
||||
compression: zstd
|
||||
mountpoint: "{{ atlas_qbittorrent_state_dir }}"
|
||||
|
||||
- name: Prepare private state and the SMB download directory
|
||||
ansible.builtin.file:
|
||||
path: "{{ item.path }}"
|
||||
state: directory
|
||||
owner: "{{ atlas_admin_username }}"
|
||||
group: "{{ atlas_admin_group }}"
|
||||
mode: "{{ item.mode }}"
|
||||
loop:
|
||||
- {path: "{{ atlas_qbittorrent_state_dir }}", mode: "0700"}
|
||||
- {path: "{{ atlas_qbittorrent_state_dir }}/qBittorrent/config", mode: "0700"}
|
||||
- {path: "{{ atlas_qbittorrent_downloads_dir }}", mode: "0770"}
|
||||
- {path: "{{ atlas_admin_home }}/.config/containers/systemd", mode: "0700"}
|
||||
|
||||
- name: Seed qBittorrent settings without overwriting application-managed state
|
||||
ansible.builtin.template:
|
||||
src: atlas-qbittorrent.conf.j2
|
||||
dest: "{{ atlas_qbittorrent_state_dir }}/qBittorrent/config/qBittorrent.conf"
|
||||
owner: "{{ atlas_admin_username }}"
|
||||
group: "{{ atlas_admin_group }}"
|
||||
mode: "0600"
|
||||
force: false
|
||||
diff: false
|
||||
|
||||
- name: Allow only the declared LAN to reach the Web UI
|
||||
ansible.posix.firewalld:
|
||||
zone: "{{ atlas_firewalld_zone }}"
|
||||
rich_rule: >-
|
||||
rule family="ipv4" source address="{{ atlas_lan_subnet }}"
|
||||
port port="{{ atlas_qbittorrent_web_port }}" protocol="tcp" accept
|
||||
permanent: true
|
||||
immediate: true
|
||||
state: enabled
|
||||
|
||||
- name: Keep the rootless user manager available at boot
|
||||
ansible.builtin.command: "loginctl enable-linger {{ atlas_admin_username }}"
|
||||
args:
|
||||
creates: "/var/lib/systemd/linger/{{ atlas_admin_username }}"
|
||||
|
||||
- name: Render the rootless torrent Quadlet
|
||||
ansible.builtin.template:
|
||||
src: atlas-qbittorrent.container.j2
|
||||
dest: "{{ atlas_admin_home }}/.config/containers/systemd/atlas-qbittorrent.container"
|
||||
owner: "{{ atlas_admin_username }}"
|
||||
group: "{{ atlas_admin_group }}"
|
||||
mode: "0644"
|
||||
register: atlas_qbittorrent_quadlet
|
||||
|
||||
- name: Reload the user manager after a new or changed Quadlet
|
||||
become_user: "{{ atlas_admin_username }}"
|
||||
ansible.builtin.systemd:
|
||||
scope: user
|
||||
daemon_reload: true
|
||||
environment:
|
||||
XDG_RUNTIME_DIR: "/run/user/{{ atlas_admin_uid }}"
|
||||
DBUS_SESSION_BUS_ADDRESS: "unix:path=/run/user/{{ atlas_admin_uid }}/bus"
|
||||
when:
|
||||
- atlas_qbittorrent_quadlet.changed
|
||||
- not ansible_check_mode
|
||||
|
||||
- name: Manage the declared qBittorrent reverse-proxy settings
|
||||
when: atlas_qbittorrent_reverse_proxy_enabled | bool
|
||||
block:
|
||||
- name: Require a specific public domain and existing Aegis gateway
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- atlas_qbittorrent_public_domain is match('^[a-z0-9]+([.-][a-z0-9]+)+$')
|
||||
- "'CHANGEME' not in atlas_aegis_ip"
|
||||
|
||||
- name: Check whether managed Web settings need an update
|
||||
community.general.ini_file:
|
||||
path: "{{ atlas_qbittorrent_state_dir }}/qBittorrent/config/qBittorrent.conf"
|
||||
section: Preferences
|
||||
option: "{{ item.key }}"
|
||||
value: "{{ item.value }}"
|
||||
no_extra_spaces: true
|
||||
mode: "0600"
|
||||
loop: "{{ atlas_qbittorrent_web_settings }}"
|
||||
check_mode: true
|
||||
register: atlas_qbittorrent_web_probe
|
||||
no_log: true
|
||||
diff: false
|
||||
|
||||
- name: Stop only qBittorrent before editing its application-managed settings
|
||||
become_user: "{{ atlas_admin_username }}"
|
||||
ansible.builtin.systemd:
|
||||
name: atlas-qbittorrent.service
|
||||
scope: user
|
||||
state: stopped
|
||||
environment:
|
||||
XDG_RUNTIME_DIR: "/run/user/{{ atlas_admin_uid }}"
|
||||
DBUS_SESSION_BUS_ADDRESS: "unix:path=/run/user/{{ atlas_admin_uid }}/bus"
|
||||
when:
|
||||
- atlas_qbittorrent_web_probe.changed
|
||||
- not ansible_check_mode
|
||||
|
||||
- name: Preserve credentials and change only the declared Web settings
|
||||
community.general.ini_file:
|
||||
path: "{{ atlas_qbittorrent_state_dir }}/qBittorrent/config/qBittorrent.conf"
|
||||
section: Preferences
|
||||
option: "{{ item.key }}"
|
||||
value: "{{ item.value }}"
|
||||
no_extra_spaces: true
|
||||
owner: "{{ atlas_admin_username }}"
|
||||
group: "{{ atlas_admin_group }}"
|
||||
mode: "0600"
|
||||
loop: "{{ atlas_qbittorrent_web_settings }}"
|
||||
when: atlas_qbittorrent_web_probe.changed
|
||||
no_log: true
|
||||
diff: false
|
||||
|
||||
- name: Start qBittorrent and restart only after a Quadlet change
|
||||
become_user: "{{ atlas_admin_username }}"
|
||||
ansible.builtin.systemd:
|
||||
name: atlas-qbittorrent.service
|
||||
scope: user
|
||||
state: "{{ 'restarted' if atlas_qbittorrent_quadlet.changed else 'started' }}"
|
||||
environment:
|
||||
XDG_RUNTIME_DIR: "/run/user/{{ atlas_admin_uid }}"
|
||||
DBUS_SESSION_BUS_ADDRESS: "unix:path=/run/user/{{ atlas_admin_uid }}/bus"
|
||||
when: not ansible_check_mode
|
||||
|
||||
- name: Verify the Web UI responds on the LAN address
|
||||
ansible.builtin.uri:
|
||||
url: "http://{{ ansible_host }}:{{ atlas_qbittorrent_web_port }}/"
|
||||
status_code: 200
|
||||
register: atlas_qbittorrent_http
|
||||
retries: 15
|
||||
delay: 2
|
||||
until: atlas_qbittorrent_http is succeeded
|
||||
when: not ansible_check_mode
|
||||
@@ -1,27 +0,0 @@
|
||||
---
|
||||
- name: Validate requested Atlas post-restore relabel paths
|
||||
tags: [atlas, restorecon, recovery]
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- item is string
|
||||
- item.startswith(atlas_mount_root ~ '/')
|
||||
- item != atlas_mount_root
|
||||
fail_msg: >-
|
||||
Post-restore relabeling accepts only explicit paths below the Atlas pool
|
||||
mount root. Do not relabel the whole pool during routine provisioning.
|
||||
loop: "{{ atlas_restorecon_paths }}"
|
||||
when: atlas_restorecon_paths | length > 0
|
||||
|
||||
- name: Restore SELinux labels on explicitly restored Atlas paths
|
||||
tags: [atlas, restorecon, recovery]
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- restorecon
|
||||
- -RFv
|
||||
- "{{ item }}"
|
||||
register: atlas_restorecon_result
|
||||
changed_when: atlas_restorecon_result.stdout | length > 0
|
||||
loop: "{{ atlas_restorecon_paths }}"
|
||||
when:
|
||||
- atlas_restorecon_paths | length > 0
|
||||
- not ansible_check_mode
|
||||
@@ -56,16 +56,6 @@
|
||||
notify: Reload NFS exports
|
||||
when: atlas_manage_sharing | bool
|
||||
|
||||
- name: Ensure Atlas NFS configuration drop-in directory exists
|
||||
tags: [atlas, sharing]
|
||||
ansible.builtin.file:
|
||||
path: /etc/nfs.conf.d
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0755"
|
||||
when: atlas_manage_sharing | bool
|
||||
|
||||
- name: Configure Atlas NFSv4-only service
|
||||
tags: [atlas, sharing]
|
||||
ansible.builtin.template:
|
||||
@@ -224,22 +214,9 @@
|
||||
- atlas_manage_sharing | bool
|
||||
- not ansible_check_mode
|
||||
|
||||
- name: Check active Atlas file-sharing services
|
||||
- name: Read Atlas file-sharing service state
|
||||
tags: [atlas, sharing, services, security]
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- systemctl
|
||||
- is-active
|
||||
- --quiet
|
||||
- "{{ item }}"
|
||||
loop:
|
||||
- nfs-server.service
|
||||
- smb.service
|
||||
loop_control:
|
||||
label: "{{ item }}"
|
||||
register: atlas_file_sharing_service_activity
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
ansible.builtin.service_facts:
|
||||
when:
|
||||
- atlas_manage_sharing | bool
|
||||
- not ansible_check_mode
|
||||
@@ -248,7 +225,10 @@
|
||||
tags: [atlas, sharing, services, security]
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- atlas_file_sharing_service_activity.results | map(attribute='rc') | list == [0, 0]
|
||||
- ansible_facts.services['nfs-server.service'] is defined
|
||||
- ansible_facts.services['nfs-server.service'].state == 'running'
|
||||
- ansible_facts.services['smb.service'] is defined
|
||||
- ansible_facts.services['smb.service'].state == 'running'
|
||||
fail_msg: Atlas NFSv4 or SMB3 did not start after its managed configuration was applied.
|
||||
when:
|
||||
- atlas_manage_sharing | bool
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
tags: [atlas, storage]
|
||||
ansible.builtin.set_fact:
|
||||
atlas_zfs_datasets:
|
||||
- name: "{{ atlas_zfs_pool }}/{{ atlas_zfs_dataset_work }}"
|
||||
mountpoint: "{{ atlas_work_mountpoint }}"
|
||||
owner: "{{ atlas_admin_username }}"
|
||||
group: "{{ atlas_admin_group }}"
|
||||
properties:
|
||||
mountpoint: "{{ atlas_work_mountpoint }}"
|
||||
- name: "{{ atlas_zfs_pool }}/{{ atlas_zfs_dataset_archive }}"
|
||||
mountpoint: "{{ atlas_archive_mountpoint }}"
|
||||
owner: "{{ atlas_admin_username }}"
|
||||
@@ -10,14 +16,6 @@
|
||||
properties:
|
||||
compression: zstd
|
||||
mountpoint: "{{ atlas_archive_mountpoint }}"
|
||||
acltype: posix
|
||||
- name: "{{ atlas_zfs_pool }}/{{ atlas_zfs_dataset_services }}"
|
||||
mountpoint: "{{ atlas_services_mountpoint }}"
|
||||
owner: "{{ atlas_admin_username }}"
|
||||
group: "{{ atlas_admin_group }}"
|
||||
properties:
|
||||
compression: zstd
|
||||
mountpoint: "{{ atlas_services_mountpoint }}"
|
||||
- name: "{{ atlas_zfs_pool }}/{{ atlas_zfs_dataset_app_data }}"
|
||||
mountpoint: "{{ atlas_app_data_mountpoint }}"
|
||||
owner: "{{ atlas_admin_username }}"
|
||||
@@ -53,27 +51,11 @@
|
||||
properties:
|
||||
compression: lz4
|
||||
mountpoint: "{{ atlas_music_mountpoint }}"
|
||||
- name: "{{ atlas_zfs_pool }}/{{ atlas_zfs_dataset_backup }}"
|
||||
mountpoint: "{{ atlas_backup_mountpoint }}"
|
||||
owner: "{{ atlas_admin_username }}"
|
||||
group: "{{ atlas_admin_group }}"
|
||||
properties:
|
||||
compression: lz4
|
||||
mountpoint: "{{ atlas_backup_mountpoint }}"
|
||||
reservation: "{{ atlas_zfs_backup_reservation }}"
|
||||
- name: "{{ atlas_zfs_pool }}/{{ atlas_zfs_dataset_host_backups }}"
|
||||
mountpoint: "{{ atlas_host_backups_mountpoint }}"
|
||||
owner: "{{ atlas_admin_username }}"
|
||||
group: "{{ atlas_admin_group }}"
|
||||
properties:
|
||||
compression: lz4
|
||||
mountpoint: "{{ atlas_host_backups_mountpoint }}"
|
||||
- name: "{{ atlas_zfs_pool }}/{{ atlas_zfs_dataset_backup_prometheus }}"
|
||||
mountpoint: "{{ atlas_backup_prometheus_mountpoint }}"
|
||||
owner: "{{ atlas_admin_username }}"
|
||||
group: "{{ atlas_admin_group }}"
|
||||
properties:
|
||||
compression: lz4
|
||||
mountpoint: "{{ atlas_backup_prometheus_mountpoint }}"
|
||||
- name: "{{ atlas_zfs_pool }}/{{ atlas_zfs_dataset_photobook }}"
|
||||
mountpoint: "{{ atlas_photobook_mountpoint }}"
|
||||
@@ -82,6 +64,21 @@
|
||||
properties:
|
||||
compression: lz4
|
||||
mountpoint: "{{ atlas_photobook_mountpoint }}"
|
||||
- name: "{{ atlas_zfs_pool }}/{{ atlas_zfs_dataset_backups }}"
|
||||
mountpoint: "{{ atlas_backups_mountpoint }}"
|
||||
owner: "{{ atlas_admin_username }}"
|
||||
group: "{{ atlas_admin_group }}"
|
||||
properties:
|
||||
compression: lz4
|
||||
mountpoint: "{{ atlas_backups_mountpoint }}"
|
||||
- name: "{{ atlas_zfs_pool }}/{{ atlas_zfs_dataset_service_backups }}"
|
||||
mountpoint: "{{ atlas_service_backups_mountpoint }}"
|
||||
owner: "{{ atlas_admin_username }}"
|
||||
group: "{{ atlas_admin_group }}"
|
||||
properties:
|
||||
compression: lz4
|
||||
mountpoint: "{{ atlas_service_backups_mountpoint }}"
|
||||
refreservation: "{{ atlas_zfs_service_backups_refreservation }}"
|
||||
|
||||
- name: Require completed Atlas storage placeholders
|
||||
tags: [atlas, storage]
|
||||
|
||||
@@ -1,145 +0,0 @@
|
||||
---
|
||||
- name: Validate Atlas offline USB backup configuration
|
||||
tags: [atlas, storage, backup, usb_backup]
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- atlas_manage_storage | bool
|
||||
- atlas_zfs_pool != 'CHANGEME_ZFS_POOL'
|
||||
- atlas_mount_root.startswith('/')
|
||||
- atlas_usb_backup_luks_uuid is match('^[0-9a-fA-F]{8}(-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}$')
|
||||
- atlas_usb_backup_fs_uuid is match('^[0-9a-fA-F]{8}(-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}$')
|
||||
- atlas_usb_backup_luks_uuid != atlas_usb_backup_fs_uuid
|
||||
- atlas_usb_backup_mapper_name is match('^[a-z][a-z0-9_-]*$')
|
||||
- atlas_usb_backup_min_free_bytes | int > 0
|
||||
- atlas_usb_backup_snapshot_prefix is match('^[a-z0-9][a-z0-9_-]*$')
|
||||
- atlas_usb_backup_snapshot_prefix != atlas_borg_snapshot_prefix
|
||||
- atlas_usb_backup_snapshot_prefix != atlas_zfs_snapshot_prefix
|
||||
fail_msg: >-
|
||||
The manual Atlas USB backup needs verified LUKS and ext4 UUIDs, a safe
|
||||
mapper name, positive free-space reserve, and a unique snapshot prefix.
|
||||
when: atlas_manage_usb_backup | bool
|
||||
|
||||
- name: Install rsync for the Atlas offline USB backup
|
||||
tags: [atlas, storage, backup, usb_backup]
|
||||
ansible.builtin.dnf:
|
||||
name: rsync
|
||||
state: present
|
||||
when: atlas_manage_usb_backup | bool
|
||||
|
||||
- name: Install the manual Atlas offline USB backup helper
|
||||
tags: [atlas, storage, backup, usb_backup]
|
||||
ansible.builtin.template:
|
||||
src: atlas-usb-backup.sh.j2
|
||||
dest: /usr/local/sbin/atlas-usb-backup
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0750"
|
||||
when: atlas_manage_usb_backup | bool
|
||||
|
||||
- name: Install the Atlas USB snapshot cleanup helper
|
||||
tags: [atlas, storage, backup, usb_backup]
|
||||
ansible.builtin.template:
|
||||
src: atlas-usb-snapshot-cleanup.sh.j2
|
||||
dest: /usr/local/sbin/atlas-usb-snapshot-cleanup
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0750"
|
||||
when: atlas_manage_usb_backup | bool
|
||||
|
||||
- name: Install the manual Atlas offline USB backup service
|
||||
tags: [atlas, storage, backup, usb_backup]
|
||||
ansible.builtin.template:
|
||||
src: atlas-usb-backup.service.j2
|
||||
dest: /etc/systemd/system/atlas-usb-backup.service
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
when: atlas_manage_usb_backup | bool
|
||||
|
||||
- name: Reload systemd for the Atlas offline USB backup service
|
||||
tags: [atlas, storage, backup, usb_backup]
|
||||
ansible.builtin.systemd:
|
||||
daemon_reload: true
|
||||
when:
|
||||
- atlas_manage_usb_backup | bool
|
||||
- not ansible_check_mode
|
||||
|
||||
- name: Validate the 45Drives Atlas USB reminder configuration
|
||||
tags: [atlas, backup, usb_reminder]
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- atlas_manage_usb_backup | bool
|
||||
- atlas_usb_reminder_calendar | length > 0
|
||||
- atlas_usb_reminder_notifier.startswith('/opt/45drives/houston/')
|
||||
fail_msg: >-
|
||||
Enable the manual USB backup and declare a systemd calendar before
|
||||
enabling its 45Drives Alerts reminder.
|
||||
when: atlas_manage_usb_reminder | bool
|
||||
|
||||
- name: Validate the Atlas USB reminder calendar
|
||||
tags: [atlas, backup, usb_reminder]
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- systemd-analyze
|
||||
- calendar
|
||||
- "{{ atlas_usb_reminder_calendar }}"
|
||||
changed_when: false
|
||||
check_mode: false
|
||||
when: atlas_manage_usb_reminder | bool
|
||||
|
||||
- name: Inspect the existing 45Drives notifier
|
||||
tags: [atlas, backup, usb_reminder]
|
||||
ansible.builtin.stat:
|
||||
path: "{{ atlas_usb_reminder_notifier }}"
|
||||
register: atlas_usb_reminder_notifier_file
|
||||
when: atlas_manage_usb_reminder | bool
|
||||
|
||||
- name: Require the configured 45Drives notifier for USB reminders
|
||||
tags: [atlas, backup, usb_reminder]
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- atlas_usb_reminder_notifier_file.stat.executable | default(false)
|
||||
fail_msg: >-
|
||||
The existing 45Drives Houston notifier must be executable.
|
||||
when: atlas_manage_usb_reminder | bool
|
||||
|
||||
- name: Install the 45Drives Atlas USB reminder helper
|
||||
tags: [atlas, backup, usb_reminder]
|
||||
ansible.builtin.template:
|
||||
src: atlas-usb-reminder.py.j2
|
||||
dest: /usr/local/libexec/atlas-usb-reminder
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0750"
|
||||
when: atlas_manage_usb_reminder | bool
|
||||
|
||||
- name: Install the 45Drives Atlas USB reminder service
|
||||
tags: [atlas, backup, usb_reminder]
|
||||
ansible.builtin.template:
|
||||
src: atlas-usb-reminder.service.j2
|
||||
dest: /etc/systemd/system/atlas-usb-reminder.service
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
when: atlas_manage_usb_reminder | bool
|
||||
|
||||
- name: Install the 45Drives Atlas USB reminder timer
|
||||
tags: [atlas, backup, usb_reminder]
|
||||
ansible.builtin.template:
|
||||
src: atlas-usb-reminder.timer.j2
|
||||
dest: /etc/systemd/system/atlas-usb-reminder.timer
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
when: atlas_manage_usb_reminder | bool
|
||||
|
||||
- name: Enable only the Atlas USB notification reminder timer
|
||||
tags: [atlas, backup, usb_reminder]
|
||||
ansible.builtin.systemd:
|
||||
name: atlas-usb-reminder.timer
|
||||
enabled: true
|
||||
state: started
|
||||
daemon_reload: true
|
||||
when:
|
||||
- atlas_manage_usb_reminder | bool
|
||||
- not ansible_check_mode
|
||||
@@ -1,175 +0,0 @@
|
||||
---
|
||||
- name: Validate Atlas ZFS snapshot policy
|
||||
tags: [atlas, storage, snapshots]
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- atlas_manage_storage | bool
|
||||
- atlas_zfs_pool != 'CHANGEME_ZFS_POOL'
|
||||
- atlas_zfs_snapshot_prefix is match('^[a-z0-9][a-z0-9_-]*$')
|
||||
- atlas_zfs_snapshot_policies | length > 0
|
||||
- >-
|
||||
(atlas_zfs_snapshot_policies | map(attribute='name') | unique | list | length)
|
||||
== (atlas_zfs_snapshot_policies | length)
|
||||
fail_msg: >-
|
||||
Enable Atlas storage and declare a non-empty snapshot policy with a safe
|
||||
prefix and unique policy names before managing automatic snapshots.
|
||||
when: atlas_manage_zfs_snapshots | bool
|
||||
|
||||
- name: Validate Atlas ZFS snapshot policy entries
|
||||
tags: [atlas, storage, snapshots]
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- item.name is match('^[a-z][a-z0-9_-]*$')
|
||||
- item.keep | int > 0
|
||||
- item.calendar | length > 0
|
||||
fail_msg: >-
|
||||
Every Atlas snapshot policy needs a safe name, a positive retention
|
||||
count, and a systemd calendar expression.
|
||||
loop: "{{ atlas_zfs_snapshot_policies }}"
|
||||
loop_control:
|
||||
label: "{{ item.name | default('unnamed') }}"
|
||||
when: atlas_manage_zfs_snapshots | bool
|
||||
|
||||
- name: Validate Atlas ZFS snapshot calendars
|
||||
tags: [atlas, storage, snapshots]
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- systemd-analyze
|
||||
- calendar
|
||||
- "{{ item.calendar }}"
|
||||
loop: "{{ atlas_zfs_snapshot_policies }}"
|
||||
loop_control:
|
||||
label: "{{ item.name }}: {{ item.calendar }}"
|
||||
changed_when: false
|
||||
check_mode: false
|
||||
when: atlas_manage_zfs_snapshots | bool
|
||||
|
||||
- name: Install Atlas ZFS snapshot and retention helper
|
||||
tags: [atlas, storage, snapshots]
|
||||
ansible.builtin.template:
|
||||
src: atlas-zfs-snapshot.sh.j2
|
||||
dest: /usr/local/sbin/atlas-zfs-snapshot
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0750"
|
||||
when: atlas_manage_zfs_snapshots | bool
|
||||
|
||||
- name: Install Atlas ZFS snapshot systemd service
|
||||
tags: [atlas, storage, snapshots]
|
||||
ansible.builtin.template:
|
||||
src: atlas-zfs-snapshot@.service.j2
|
||||
dest: /etc/systemd/system/atlas-zfs-snapshot@.service
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
when: atlas_manage_zfs_snapshots | bool
|
||||
|
||||
- name: Install Atlas ZFS snapshot systemd timers
|
||||
tags: [atlas, storage, snapshots]
|
||||
ansible.builtin.template:
|
||||
src: atlas-zfs-snapshot.timer.j2
|
||||
dest: "/etc/systemd/system/atlas-zfs-snapshot-{{ item.name }}.timer"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
loop: "{{ atlas_zfs_snapshot_policies }}"
|
||||
loop_control:
|
||||
label: "{{ item.name }}"
|
||||
when: atlas_manage_zfs_snapshots | bool
|
||||
|
||||
- name: Enable Atlas ZFS snapshot systemd timers
|
||||
tags: [atlas, storage, snapshots]
|
||||
ansible.builtin.systemd:
|
||||
name: "atlas-zfs-snapshot-{{ item.name }}.timer"
|
||||
enabled: true
|
||||
state: started
|
||||
daemon_reload: true
|
||||
loop: "{{ atlas_zfs_snapshot_policies }}"
|
||||
loop_control:
|
||||
label: "{{ item.name }}"
|
||||
when:
|
||||
- atlas_manage_zfs_snapshots | bool
|
||||
- not ansible_check_mode
|
||||
|
||||
- name: Validate Atlas ZFS scrub policy
|
||||
tags: [atlas, storage, scrub]
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- atlas_manage_storage | bool
|
||||
- atlas_zfs_pool != 'CHANGEME_ZFS_POOL'
|
||||
- atlas_zfs_scrub_calendar | length > 0
|
||||
fail_msg: >-
|
||||
Enable Atlas storage and declare a systemd calendar expression before
|
||||
managing periodic ZFS scrubs.
|
||||
when: atlas_manage_zfs_scrub | bool
|
||||
|
||||
- name: Validate Atlas ZFS scrub calendar
|
||||
tags: [atlas, storage, scrub]
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- systemd-analyze
|
||||
- calendar
|
||||
- "{{ atlas_zfs_scrub_calendar }}"
|
||||
changed_when: false
|
||||
check_mode: false
|
||||
when: atlas_manage_zfs_scrub | bool
|
||||
|
||||
- name: Require OpenZFS scrub systemd units
|
||||
tags: [atlas, storage, scrub]
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- systemctl
|
||||
- cat
|
||||
- "{{ item }}"
|
||||
loop:
|
||||
- "zfs-scrub@{{ atlas_zfs_pool }}.service"
|
||||
- "zfs-scrub-monthly@{{ atlas_zfs_pool }}.timer"
|
||||
- "zfs-scrub-weekly@{{ atlas_zfs_pool }}.timer"
|
||||
loop_control:
|
||||
label: "{{ item }}"
|
||||
changed_when: false
|
||||
check_mode: false
|
||||
when: atlas_manage_zfs_scrub | bool
|
||||
|
||||
- name: Create Atlas ZFS scrub timer override directory
|
||||
tags: [atlas, storage, scrub]
|
||||
ansible.builtin.file:
|
||||
path: "/etc/systemd/system/zfs-scrub-monthly@{{ atlas_zfs_pool }}.timer.d"
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0755"
|
||||
when: atlas_manage_zfs_scrub | bool
|
||||
|
||||
- name: Configure Atlas ZFS monthly scrub schedule
|
||||
tags: [atlas, storage, scrub]
|
||||
ansible.builtin.template:
|
||||
src: atlas-zfs-scrub-timer.conf.j2
|
||||
dest: >-
|
||||
/etc/systemd/system/zfs-scrub-monthly@{{ atlas_zfs_pool }}.timer.d/override.conf
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
when: atlas_manage_zfs_scrub | bool
|
||||
|
||||
- name: Disable the conflicting weekly OpenZFS scrub timer
|
||||
tags: [atlas, storage, scrub]
|
||||
ansible.builtin.systemd:
|
||||
name: "zfs-scrub-weekly@{{ atlas_zfs_pool }}.timer"
|
||||
enabled: false
|
||||
state: stopped
|
||||
daemon_reload: true
|
||||
when:
|
||||
- atlas_manage_zfs_scrub | bool
|
||||
- not ansible_check_mode
|
||||
|
||||
- name: Enable the Atlas monthly OpenZFS scrub timer
|
||||
tags: [atlas, storage, scrub]
|
||||
ansible.builtin.systemd:
|
||||
name: "zfs-scrub-monthly@{{ atlas_zfs_pool }}.timer"
|
||||
enabled: true
|
||||
state: started
|
||||
daemon_reload: true
|
||||
when:
|
||||
- atlas_manage_zfs_scrub | bool
|
||||
- not ansible_check_mode
|
||||
@@ -4,12 +4,7 @@ PubkeyAuthentication yes
|
||||
PasswordAuthentication no
|
||||
KbdInteractiveAuthentication no
|
||||
AuthenticationMethods publickey
|
||||
AuthorizedKeysFile {{
|
||||
atlas_admin_ssh_keys
|
||||
| map(attribute='name')
|
||||
| map('regex_replace', '^', '%h/.ssh/authorized_keys.d/')
|
||||
| join(' ')
|
||||
}}
|
||||
AuthorizedKeysFile {% for key in atlas_admin_ssh_keys %}%h/.ssh/authorized_keys.d/{{ key.name }}{% if not loop.last %} {% endif %}{% endfor %}
|
||||
X11Forwarding no
|
||||
AllowTcpForwarding {{ atlas_ssh_allow_tcp_forwarding }}
|
||||
AllowAgentForwarding no
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
# Managed by Ansible. NPM authenticates callers; this private adapter adds RPC credentials.
|
||||
[Unit]
|
||||
Description=Atlas private aria2 RPC gateway
|
||||
After=atlas-aria2.service
|
||||
Requires=atlas-aria2.service
|
||||
PartOf=atlas-aria2.service
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/bin/python3 {{ atlas_aria2_state_dir }}/rpc-gateway.py --listen {{ ansible_host }} --port {{ atlas_aria2_gateway_port }} --upstream-port {{ atlas_aria2_rpc_port }} --peer {{ atlas_aegis_ip }} --domain {{ atlas_aria2_public_domain }} --secret-file {{ atlas_aria2_state_dir }}/rpc-secret
|
||||
Restart=on-failure
|
||||
RestartSec=5
|
||||
NoNewPrivileges=true
|
||||
UMask=0077
|
||||
RestrictAddressFamilies=AF_INET AF_UNIX
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
@@ -1,30 +0,0 @@
|
||||
# Managed by Ansible. Never expose this file: it contains the RPC secret.
|
||||
dir=/downloads
|
||||
input-file=/config/session
|
||||
save-session=/config/session
|
||||
save-session-interval=30
|
||||
auto-save-interval=30
|
||||
continue=true
|
||||
allow-overwrite=false
|
||||
auto-file-renaming=false
|
||||
max-concurrent-downloads=1
|
||||
max-connection-per-server=1
|
||||
split=1
|
||||
max-tries=20
|
||||
retry-wait=10
|
||||
connect-timeout=30
|
||||
timeout=60
|
||||
check-certificate=true
|
||||
file-allocation=none
|
||||
umask=007
|
||||
enable-rpc=true
|
||||
rpc-listen-all=true
|
||||
rpc-listen-port=6800
|
||||
rpc-allow-origin-all=true
|
||||
rpc-secret={{ atlas_aria2_rpc_secret.content | b64decode | trim }}
|
||||
rpc-max-request-size=2M
|
||||
enable-dht=false
|
||||
enable-dht6=false
|
||||
enable-peer-exchange=false
|
||||
bt-enable-lpd=false
|
||||
console-log-level=warn
|
||||
@@ -1,30 +0,0 @@
|
||||
# Managed by Ansible. Bypass upstream init, tracker updates and deletion hooks.
|
||||
[Unit]
|
||||
Description=Atlas rootless HTTP downloader
|
||||
RequiresMountsFor={{ atlas_aria2_state_dir }} {{ atlas_aria2_downloads_dir }}
|
||||
|
||||
[Container]
|
||||
ContainerName=atlas-aria2
|
||||
Image={{ atlas_aria2_image }}
|
||||
UserNS=keep-id
|
||||
User={{ atlas_admin_uid }}
|
||||
Group={{ atlas_admin_gid }}
|
||||
Entrypoint=/usr/local/bin/aria2c
|
||||
Exec=--conf-path=/config/aria2.conf
|
||||
PublishPort={{ ansible_host }}:{{ atlas_aria2_rpc_port }}:6800
|
||||
Volume={{ atlas_aria2_state_dir }}:/config:Z
|
||||
Volume={{ atlas_aria2_downloads_dir }}:/downloads:z
|
||||
ReadOnly=true
|
||||
Tmpfs=/tmp:rw,nosuid,nodev
|
||||
NoNewPrivileges=true
|
||||
DropCapability=all
|
||||
StopTimeout=60
|
||||
|
||||
[Service]
|
||||
Restart=on-failure
|
||||
RestartSec=10
|
||||
TimeoutStartSec=900
|
||||
TimeoutStopSec=90
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
@@ -1,22 +0,0 @@
|
||||
# Managed by Ansible. Static frontend only; no host data or RPC secret mounted.
|
||||
[Unit]
|
||||
Description=Atlas AriaNg LAN Web UI
|
||||
|
||||
[Container]
|
||||
ContainerName=atlas-ariang
|
||||
Image={{ atlas_ariang_image }}
|
||||
UserNS=keep-id
|
||||
User={{ atlas_admin_uid }}
|
||||
Group={{ atlas_admin_gid }}
|
||||
PublishPort={{ ansible_host }}:{{ atlas_ariang_web_port }}:6880
|
||||
ReadOnly=true
|
||||
NoNewPrivileges=true
|
||||
DropCapability=all
|
||||
|
||||
[Service]
|
||||
Restart=on-failure
|
||||
RestartSec=10
|
||||
TimeoutStartSec=900
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
@@ -1,41 +0,0 @@
|
||||
[Unit]
|
||||
Description=Back up Atlas ZFS datasets to the encrypted Borg repository
|
||||
Documentation=man:borg-create(1) man:borg-prune(1) man:borg-compact(1)
|
||||
Requires=zfs.target
|
||||
Wants=network-online.target
|
||||
After=zfs.target network-online.target
|
||||
StartLimitIntervalSec=6h
|
||||
StartLimitBurst=3
|
||||
ConditionFileIsExecutable=/usr/local/sbin/atlas-borg-backup
|
||||
ConditionPathExists={{ atlas_borg_passphrase_path }}
|
||||
ConditionPathExists={{ atlas_borg_ssh_private_key_path }}
|
||||
ConditionPathExists={{ atlas_borg_known_hosts_path }}
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/local/sbin/atlas-borg-backup
|
||||
ExecStopPost=+/usr/local/sbin/atlas-borg-snapshot-cleanup
|
||||
User=root
|
||||
Group=root
|
||||
UMask=0077
|
||||
SuccessExitStatus=1
|
||||
Restart=on-failure
|
||||
RestartSec=30m
|
||||
TimeoutStartSec=infinity
|
||||
RuntimeDirectory=atlas-borg
|
||||
RuntimeDirectoryMode=0750
|
||||
Nice=15
|
||||
IOSchedulingClass=best-effort
|
||||
IOSchedulingPriority=7
|
||||
NoNewPrivileges=true
|
||||
PrivateMounts=true
|
||||
PrivateTmp=true
|
||||
ProtectHome=true
|
||||
ProtectSystem=strict
|
||||
ReadWritePaths={{ atlas_borg_cache_dir }} {{ atlas_borg_config_dir }} /run/atlas-borg /run/lock
|
||||
ProtectKernelTunables=true
|
||||
ProtectKernelModules=true
|
||||
ProtectControlGroups=true
|
||||
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
|
||||
RestrictRealtime=true
|
||||
LockPersonality=true
|
||||
@@ -1,215 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -Eeuo pipefail
|
||||
|
||||
export LC_ALL=C.utf8
|
||||
export PATH=/usr/sbin:/usr/bin:/sbin:/bin
|
||||
export BORG_CACHE_DIR={{ atlas_borg_cache_dir | quote }}
|
||||
export BORG_CONFIG_DIR={{ atlas_borg_config_dir | quote }}
|
||||
export BORG_PASSCOMMAND={{ ('cat ' ~ atlas_borg_passphrase_path) | quote }}
|
||||
export BORG_RSH={{ atlas_borg_ssh_wrapper_path | quote }}
|
||||
|
||||
readonly pool={{ atlas_zfs_pool | quote }}
|
||||
readonly mount_root={{ atlas_mount_root | quote }}
|
||||
readonly repository={{ ('ssh://' ~ atlas_borg_repository_user ~ '@' ~ atlas_borg_repository_host
|
||||
~ ':' ~ (atlas_borg_repository_port | string) ~ '/' ~ atlas_borg_repository_path) | quote }}
|
||||
readonly remote_path={{ atlas_borg_remote_path | quote }}
|
||||
readonly archive_prefix={{ atlas_borg_archive_prefix | quote }}
|
||||
readonly snapshot_prefix={{ atlas_borg_snapshot_prefix | quote }}
|
||||
readonly compression={{ atlas_borg_compression | quote }}
|
||||
readonly stage=/run/atlas-borg/source
|
||||
readonly snapshot_marker=/run/atlas-borg/snapshot-name
|
||||
readonly borg_user={{ atlas_borg_username | quote }}
|
||||
readonly borg_group={{ atlas_borg_group | quote }}
|
||||
readonly borg_home={{ atlas_borg_home | quote }}
|
||||
readonly borg_lock={{ atlas_borg_lock_path | quote }}
|
||||
readonly progress_filter=/usr/local/libexec/atlas-borg-progress
|
||||
|
||||
snapshot_name=""
|
||||
mounted_targets=()
|
||||
|
||||
# Invoked through the EXIT trap below.
|
||||
# shellcheck disable=SC2329
|
||||
cleanup() {
|
||||
local status=$?
|
||||
local cleanup_status=0
|
||||
local index
|
||||
local source_mount_failed=false
|
||||
trap - EXIT HUP INT TERM
|
||||
set +e
|
||||
|
||||
{% raw %}
|
||||
for ((index = ${#mounted_targets[@]} - 1; index >= 0; index--)); do
|
||||
{% endraw %}
|
||||
if mountpoint -q "${mounted_targets[$index]}" && ! umount -R "${mounted_targets[$index]}"; then
|
||||
printf 'Source snapshot mount cleanup failed: %s\n' "${mounted_targets[$index]}" >&2
|
||||
source_mount_failed=true
|
||||
fi
|
||||
if mountpoint -q "${mounted_targets[$index]}"; then
|
||||
printf 'Source snapshot mount is still active: %s\n' "${mounted_targets[$index]}" >&2
|
||||
source_mount_failed=true
|
||||
else
|
||||
rmdir -- "${mounted_targets[$index]}" 2>/dev/null || true
|
||||
fi
|
||||
done
|
||||
if [[ "$source_mount_failed" == false ]]; then
|
||||
if [[ -d "$stage" ]]; then
|
||||
rmdir -- "$stage" 2>/dev/null || cleanup_status=2
|
||||
fi
|
||||
else
|
||||
cleanup_status=2
|
||||
printf 'Source bind mount cleanup failed; keeping the snapshot for recovery\n' >&2
|
||||
fi
|
||||
|
||||
if ((status == 0 && cleanup_status != 0)); then
|
||||
status=$cleanup_status
|
||||
fi
|
||||
exit "$status"
|
||||
}
|
||||
|
||||
trap cleanup EXIT
|
||||
trap 'exit 143' HUP INT TERM
|
||||
|
||||
run_as_borg() {
|
||||
setpriv \
|
||||
--reuid "$borg_user" \
|
||||
--regid "$borg_group" \
|
||||
--clear-groups \
|
||||
--inh-caps=-all,+dac_read_search \
|
||||
--ambient-caps=-all,+dac_read_search \
|
||||
--bounding-set=-all,+dac_read_search \
|
||||
-- env HOME="$borg_home" USER="$borg_user" LOGNAME="$borg_user" "$@"
|
||||
}
|
||||
|
||||
exec 8>"$borg_lock"
|
||||
flock 8
|
||||
exec 9>/run/lock/atlas-zfs-snapshot.lock
|
||||
|
||||
zpool list -H -o name "$pool" >/dev/null
|
||||
rm -rf "$stage"
|
||||
mkdir -p "$stage"
|
||||
# Keep systemd's root:root ownership of RuntimeDirectory: changing it makes
|
||||
# ExecStopPost re-chown its contents, which SELinux denies for the marker.
|
||||
setfacl -m "u:${borg_user}:rx" /run/atlas-borg
|
||||
chown root:"$borg_group" "$stage"
|
||||
chmod 0750 /run/atlas-borg "$stage"
|
||||
|
||||
flock 9
|
||||
while IFS= read -r stale_snapshot; do
|
||||
stale_suffix="${stale_snapshot#"${pool}@${snapshot_prefix}-"}"
|
||||
if [[ "$stale_suffix" =~ ^[0-9]{8}T[0-9]{6}Z$ ]]; then
|
||||
zfs destroy -r "$stale_snapshot"
|
||||
printf 'Removed stale Borg source snapshot %s\n' "$stale_snapshot"
|
||||
fi
|
||||
done < <(
|
||||
zfs list -H -t snapshot -o name -r "$pool" |
|
||||
grep -E "^${pool}@${snapshot_prefix}-[0-9]{8}T[0-9]{6}Z$" || true
|
||||
)
|
||||
|
||||
timestamp="$(date -u +%Y%m%dT%H%M%SZ)"
|
||||
readonly timestamp
|
||||
snapshot_name="${snapshot_prefix}-${timestamp}"
|
||||
readonly snapshot_name
|
||||
printf '%s\n' "$snapshot_name" >"$snapshot_marker"
|
||||
zfs snapshot -r "${pool}@${snapshot_name}"
|
||||
flock -u 9
|
||||
printf 'Created recursive Borg source snapshot %s@%s\n' "$pool" "$snapshot_name"
|
||||
|
||||
while IFS=$'\t' read -r dataset dataset_mountpoint mounted; do
|
||||
if [[ "$mounted" != yes ]]; then
|
||||
printf 'Dataset %s is not mounted; refusing an incomplete backup\n' "$dataset" >&2
|
||||
exit 65
|
||||
fi
|
||||
if [[ "$dataset_mountpoint" != "$mount_root" && "$dataset_mountpoint" != "$mount_root/"* ]]; then
|
||||
printf 'Dataset %s has unexpected mountpoint %s\n' "$dataset" "$dataset_mountpoint" >&2
|
||||
exit 65
|
||||
fi
|
||||
|
||||
dataset_suffix="${dataset#"$pool"}"
|
||||
source_path="${dataset_mountpoint}/.zfs/snapshot/${snapshot_name}"
|
||||
target_path="${stage}${dataset_suffix}"
|
||||
mkdir -p "$target_path"
|
||||
mount --bind "$source_path" "$target_path"
|
||||
mounted_targets+=("$target_path")
|
||||
mount -o remount,bind,ro "$target_path"
|
||||
done < <(zfs list -H -o name,mountpoint,mounted -s name -r "$pool")
|
||||
|
||||
estimated_source_bytes=0
|
||||
while IFS=$'\t' read -r source_snapshot logical_bytes; do
|
||||
if [[ "$source_snapshot" == *"@${snapshot_name}" ]]; then
|
||||
[[ "$logical_bytes" =~ ^[0-9]+$ ]] || {
|
||||
printf 'Invalid logical size for Borg source snapshot %s\n' "$source_snapshot" >&2
|
||||
exit 74
|
||||
}
|
||||
estimated_source_bytes=$((estimated_source_bytes + logical_bytes))
|
||||
fi
|
||||
done < <(zfs list -H -p -t snapshot -o name,logicalreferenced -r "$pool")
|
||||
((estimated_source_bytes > 0)) || {
|
||||
printf 'Could not estimate the Borg source snapshot size\n' >&2
|
||||
exit 74
|
||||
}
|
||||
printf 'Estimated Borg source logical size: %s bytes (ZFS; progress percentage is approximate)\n' \
|
||||
"$estimated_source_bytes"
|
||||
|
||||
archive="${archive_prefix}-${timestamp}"
|
||||
readonly archive
|
||||
borg_status=0
|
||||
|
||||
printf 'Starting Borg archive %s from snapshot %s@%s\n' "$archive" "$pool" "$snapshot_name"
|
||||
set +e
|
||||
(
|
||||
cd /run/atlas-borg
|
||||
run_as_borg borg --remote-path "$remote_path" --lock-wait 600 --log-json --progress create \
|
||||
--show-rc \
|
||||
--stats \
|
||||
--checkpoint-interval 900 \
|
||||
--compression "$compression" \
|
||||
"${repository}::${archive}" \
|
||||
source 2>&1
|
||||
) | /usr/bin/python3 -u "$progress_filter" --estimated-total-bytes "$estimated_source_bytes"
|
||||
create_pipeline_status=("${PIPESTATUS[@]}")
|
||||
set -e
|
||||
create_status=${create_pipeline_status[0]}
|
||||
if ((create_pipeline_status[1] != 0)); then
|
||||
printf 'Borg progress logging failed with status %s\n' "${create_pipeline_status[1]}" >&2
|
||||
exit 2
|
||||
fi
|
||||
if ((create_status >= 2)); then
|
||||
exit "$create_status"
|
||||
fi
|
||||
borg_status=$create_status
|
||||
|
||||
printf 'Borg archive %s created; applying retention\n' "$archive"
|
||||
set +e
|
||||
run_as_borg borg --remote-path "$remote_path" --lock-wait 600 prune \
|
||||
--show-rc \
|
||||
--list \
|
||||
--glob-archives "${archive_prefix}-*" \
|
||||
--keep-daily {{ atlas_borg_keep_daily | int }} \
|
||||
--keep-weekly {{ atlas_borg_keep_weekly | int }} \
|
||||
--keep-monthly {{ atlas_borg_keep_monthly | int }} \
|
||||
"$repository"
|
||||
prune_status=$?
|
||||
set -e
|
||||
if ((prune_status >= 2)); then
|
||||
exit "$prune_status"
|
||||
fi
|
||||
if ((prune_status > borg_status)); then
|
||||
borg_status=$prune_status
|
||||
fi
|
||||
|
||||
printf 'Borg retention complete; compacting repository\n'
|
||||
set +e
|
||||
run_as_borg borg --remote-path "$remote_path" --lock-wait 600 compact \
|
||||
--show-rc \
|
||||
"$repository"
|
||||
compact_status=$?
|
||||
set -e
|
||||
if ((compact_status >= 2)); then
|
||||
exit "$compact_status"
|
||||
fi
|
||||
if ((compact_status > borg_status)); then
|
||||
borg_status=$compact_status
|
||||
fi
|
||||
|
||||
printf 'Borg backup %s completed with status %s\n' "$archive" "$borg_status"
|
||||
exit "$borg_status"
|
||||
@@ -1,12 +0,0 @@
|
||||
[Unit]
|
||||
Description=Schedule the encrypted Atlas Borg backup
|
||||
|
||||
[Timer]
|
||||
OnCalendar={{ atlas_borg_backup_calendar }}
|
||||
Persistent=true
|
||||
RandomizedDelaySec={{ atlas_borg_randomized_delay }}
|
||||
AccuracySec=1min
|
||||
Unit=atlas-borg-backup.service
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
@@ -1,32 +0,0 @@
|
||||
[Unit]
|
||||
Description=Check the encrypted Atlas Borg repository
|
||||
Documentation=man:borg-check(1)
|
||||
Wants=network-online.target
|
||||
After=network-online.target atlas-borg-backup.service
|
||||
ConditionFileIsExecutable=/usr/local/sbin/atlas-borg-check
|
||||
ConditionPathExists={{ atlas_borg_passphrase_path }}
|
||||
ConditionPathExists={{ atlas_borg_ssh_private_key_path }}
|
||||
ConditionPathExists={{ atlas_borg_known_hosts_path }}
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/local/sbin/atlas-borg-check
|
||||
User={{ atlas_borg_username }}
|
||||
Group={{ atlas_borg_group }}
|
||||
UMask=0077
|
||||
SuccessExitStatus=1
|
||||
TimeoutStartSec=infinity
|
||||
Nice=15
|
||||
IOSchedulingClass=best-effort
|
||||
IOSchedulingPriority=7
|
||||
NoNewPrivileges=true
|
||||
PrivateTmp=true
|
||||
ProtectHome=true
|
||||
ProtectSystem=strict
|
||||
ReadWritePaths={{ atlas_borg_cache_dir }} {{ atlas_borg_config_dir }}
|
||||
ProtectKernelTunables=true
|
||||
ProtectKernelModules=true
|
||||
ProtectControlGroups=true
|
||||
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
|
||||
RestrictRealtime=true
|
||||
LockPersonality=true
|
||||
@@ -1,23 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -Eeuo pipefail
|
||||
|
||||
export LC_ALL=C
|
||||
export PATH=/usr/sbin:/usr/bin:/sbin:/bin
|
||||
export BORG_CACHE_DIR={{ atlas_borg_cache_dir | quote }}
|
||||
export BORG_CONFIG_DIR={{ atlas_borg_config_dir | quote }}
|
||||
export BORG_PASSCOMMAND={{ ('cat ' ~ atlas_borg_passphrase_path) | quote }}
|
||||
export BORG_RSH={{ atlas_borg_ssh_wrapper_path | quote }}
|
||||
|
||||
readonly repository={{ ('ssh://' ~ atlas_borg_repository_user ~ '@' ~ atlas_borg_repository_host
|
||||
~ ':' ~ (atlas_borg_repository_port | string) ~ '/' ~ atlas_borg_repository_path) | quote }}
|
||||
readonly remote_path={{ atlas_borg_remote_path | quote }}
|
||||
readonly archive_prefix={{ atlas_borg_archive_prefix | quote }}
|
||||
readonly borg_lock={{ atlas_borg_lock_path | quote }}
|
||||
|
||||
exec 8>"$borg_lock"
|
||||
flock 8
|
||||
|
||||
exec borg --remote-path "$remote_path" --lock-wait 600 check \
|
||||
--show-rc \
|
||||
--glob-archives "${archive_prefix}-*" \
|
||||
"$repository"
|
||||
@@ -1,12 +0,0 @@
|
||||
[Unit]
|
||||
Description=Schedule checks of the encrypted Atlas Borg repository
|
||||
|
||||
[Timer]
|
||||
OnCalendar={{ atlas_borg_check_calendar }}
|
||||
Persistent=true
|
||||
RandomizedDelaySec={{ atlas_borg_randomized_delay }}
|
||||
AccuracySec=1min
|
||||
Unit=atlas-borg-check.service
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
@@ -1,51 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -Eeuo pipefail
|
||||
|
||||
export PATH=/usr/sbin:/usr/bin:/sbin:/bin
|
||||
|
||||
readonly pool={{ atlas_zfs_pool | quote }}
|
||||
readonly mount_root={{ atlas_mount_root | quote }}
|
||||
readonly snapshot_prefix={{ atlas_borg_snapshot_prefix | quote }}
|
||||
readonly marker=/run/atlas-borg/snapshot-name
|
||||
|
||||
[[ -e "$marker" ]] || exit 0
|
||||
[[ -f "$marker" && ! -L "$marker" ]] || {
|
||||
printf 'Unsafe Atlas Borg snapshot marker; leaving snapshots unchanged\n' >&2
|
||||
exit 2
|
||||
}
|
||||
IFS= read -r snapshot_name <"$marker"
|
||||
[[ "$snapshot_name" =~ ^${snapshot_prefix}-[0-9]{8}T[0-9]{6}Z$ ]] || {
|
||||
printf 'Invalid Atlas Borg snapshot marker; leaving snapshots unchanged\n' >&2
|
||||
exit 2
|
||||
}
|
||||
|
||||
exec 9>/run/lock/atlas-zfs-snapshot.lock
|
||||
flock 9
|
||||
if zfs list -H -t snapshot -o name "${pool}@${snapshot_name}" >/dev/null 2>&1; then
|
||||
# The private bind mounts are gone, but ZFS may leave its on-demand
|
||||
# .zfs/snapshot mounts in the host namespace until explicitly unmounted.
|
||||
snapshot_mounts=()
|
||||
snapshot_sources=()
|
||||
while IFS=$'\t' read -r dataset dataset_mountpoint; do
|
||||
[[ "$dataset_mountpoint" == "$mount_root" || "$dataset_mountpoint" == "$mount_root/"* ]] || continue
|
||||
snapshot_mounts+=("${dataset_mountpoint}/.zfs/snapshot/${snapshot_name}")
|
||||
snapshot_sources+=("${dataset}@${snapshot_name}")
|
||||
done < <(zfs list -H -o name,mountpoint -s name -r "$pool")
|
||||
|
||||
{% raw %}
|
||||
for ((index = ${#snapshot_mounts[@]} - 1; index >= 0; index--)); do
|
||||
{% endraw %}
|
||||
mounted_source="$(findmnt -rn -M "${snapshot_mounts[$index]}" -o SOURCE || true)"
|
||||
[[ -n "$mounted_source" ]] || continue
|
||||
[[ "$mounted_source" == "${snapshot_sources[$index]}" ]] || {
|
||||
printf 'Unexpected source on Atlas Borg snapshot mount: %s\n' \
|
||||
"${snapshot_mounts[$index]}" >&2
|
||||
exit 2
|
||||
}
|
||||
umount "${snapshot_mounts[$index]}"
|
||||
done
|
||||
|
||||
zfs destroy -r "${pool}@${snapshot_name}"
|
||||
printf 'Removed recursive Atlas Borg source snapshot %s@%s after backup exit\n' \
|
||||
"$pool" "$snapshot_name"
|
||||
fi
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user