Skip to content

feat(silo): deploy the single-container image and add silo-migrate - #581

Open
After-Shock wants to merge 5 commits into
saltyorg:masterfrom
After-Shock:feat-silo-omnibus
Open

After-Shock wants to merge 5 commits into
saltyorg:masterfrom
After-Shock:feat-silo-omnibus

Conversation

@After-Shock

@After-Shock After-Shock commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Description

Silo now publishes a single image under its plain tags (latest, build-N, <sha>), with PostgreSQL and Redis bundled and supervised by s6 (Silo-Server/silo-server#3319, 2026-10-31). The split-container layout that #575 found hard to keep up with is no longer needed, and the role as last shipped can't run the current image (/init needs root, and user: was set).

This brings the role back on that image and adds a migration for existing installs.

silo

  • Runs ghcr.io/silo-server/silo-server:latest with /opt/silo/config mounted at /config, PUID/PGID, and ENABLE_REDIS=true. There's no container user:.
  • Drops the postgres and redis sub-roles and the dependency settings.
  • Keeps the 8G shared memory that silo-postgres had and sets a 120s stop timeout, matching the upstream Compose file.
  • Exposes the generated secret key as silo_role_secret_key and validates it before deploying.
  • Refuses to run when a multi-container install is present (/opt/silo/postgres or /opt/silo/plugins) without a completed migration, so Silo never comes up on an empty database. Completion is read from the copied database, not a marker file: with Silo stopped, a one-off container starts the bundled PostgreSQL with no network and checks that the bootstrap role is silo and that users has records.

silo_migrate (sb install sandbox-silo-migrate, never tag, same pattern as koito_migrate)

  1. Records row counts for users, media_items, user_watch_history and user_watch_progress, then stops silo-postgres and removes silo and silo-redis.
  2. Runs upstream's /etc/silo-omnibus/migrate-compose-stack in a one-off container with no network. The old cluster is mounted read-only. The script copies it and hard-links plugins, artwork and compat into config/silo.
  3. Renames the copied cluster's bootstrap role (the Saltbox user) to silo. The bundled PostgreSQL authenticates Silo as silo by peer, and upstream's script only adds a separate silo superuser when POSTGRES_USER differs. Without the rename, Silo's next migration fails with sequence must have same owner as table it is linked to.
  4. Deploys Silo, waits for it to be healthy and compares the counts. silo-postgres is removed only if they match.

The copy is skipped when /opt/silo/config/postgres/data already exists. The counts are read and compared again on every run while the silo-postgres container still exists, so a run that failed after the copy is validated when it is re-run.

The old /opt/silo/postgres, redis, plugins, artwork and compat folders are never modified. Re-running the tag after a successful migration only redeploys Silo.

Legacy settings are read the way the legacy role read them (lookup('role_var', '_x', role='silo', default=<legacy default>)), so both silo_x and silo_role_x overrides are honoured. The legacy PostgreSQL location follows silo_role_postgres_paths_folder, and the configured silo_role_docker_container is used throughout.
External databases. silo_role_database_url is a setting again, in a Postgres section, and is empty by default, meaning the bundled database. When it is set, Silo gets it as DATABASE_URL, which turns the image's own PostgreSQL off. For these installs, silo-migrate runs upstream's script with that URL and without the legacy cluster mounts, so only plugins, artwork and compat move. The PostgreSQL steps (count read, stop, role rename, count comparison) are skipped, and the legacy Redis container is still removed. The silo role checks for config/silo/plugins instead of the copied database. A URL whose host is the legacy PostgreSQL container (or localhost) is refused by both roles before anything is removed, as upstream's script does. silo_role_postgres_deploy: false with no URL fails with a message asking for the URL.

silo_migrate is registered under No CI with the never tag and listed in ignored_roles in .github/ci-role-matrix.yml, like koito_migrate.

A new announcement describing the migration is appended to announcements.yml; the existing entries are unchanged. Docs: saltyorg/docs#433

Validation

Static

Run against this branch rebased on 05056d0:

  • ansible-lint: passed, production profile.
  • saltbox-lint check . (v0.2.7): no findings.
  • git diff --check: clean.
  • ./scripts/check_missing_entries.py: passed.

Live

On a disposable Ubuntu 24.04 test VM with Saltbox 47ae993 and this branch in /opt/sandbox. The legacy data was created earlier by deploying the role as of 5999d5a with the last pre-omnibus image (7ee9615f), then seeding an admin user, a profile, a Movies library (3 items) and 2 watched items through Silo's API.

  • With the legacy data in place and no copied cluster, sb install sandbox-silo failed with the migrate message, and the existing silo container was not removed.

  • sb install sandbox-silo-migrate: failed=0 in about 2.5 minutes. Counts matched (1|3|2|2), the database check in the silo role passed, every public table is owned by silo, silo is the only non-system role, and silo-postgres was removed.

  • Re-ran sandbox-silo-migrate, then sandbox-silo: both failed=0. The copy and count steps were skipped, the database check passed and Silo was healthy with no errors in its log.

  • Fresh install on an empty /opt/silo: sandbox-silo twice, both failed=0, the database check skipped, Silo healthy.

  • Review follow-up (8fcd60a), on the same VM reset to the legacy state:

    • silo_role_postgres_deploy: false: sandbox-silo and sandbox-silo-migrate both fail with the external-database message. Same for silo_database_url with the migrate tag.
    • Legacy cluster moved to /opt/silo-db/postgres, with silo_role_postgres_paths_folder: silo-db, silo_postgres_name: silodb, silo_redis_name: silokv, silo_role_docker_container: silo-server and a running silokv container: sandbox-silo-migrate failed=0. It started silodb on /opt/silo-db/postgres (no silo-postgres anywhere in the run), removed silokv, waited on silo-server until healthy, counts matched (1|3|2|2), and silodb was removed.
  • External-database follow-up (01417b5), on the same VM:

    • silo_role_database_url pointing at Silo-Postgres (uppercase): both tags fail with the legacy-container message before removing anything.
    • Bundled migration re-run from the legacy state: failed=0, counts matched, and the container has no DATABASE_URL.
    • External: legacy plugins, artwork and compat, no legacy cluster, and a separate pgvector/pgvector:pg18 container as the external database. sandbox-silo refused with the migrate message. sandbox-silo-migrate gave failed=0 in about 1.5 minutes: the PostgreSQL steps were skipped, the folders were moved into config/silo, and Silo came up healthy with DATABASE_URL set and no PostgreSQL process in the container. Silo created its 343 tables in the external database. Re-running sandbox-silo passed.

Not covered in this round

  • sandbox-silo-migrate on a fresh install, which should fail with "No legacy Silo PostgreSQL data was found". That task is unchanged and was tested before the rebase.
  • A copied database that fails the check (wrong bootstrap role or no users). I checked the match against sample outputs (silo|1 and silo|12 pass; plex|1, silo|0, empty and error output fail) but did not break a real database to trigger it.
  • When the legacy cluster is outside /opt/silo (a custom silo_role_postgres_paths_folder or location), Docker creates an empty, root-owned /opt/silo/postgres as the mount point for the migration's tmpfs. It's harmless: nothing reads it, and the silo role checks for postgres/PG_VERSION.

@saltydk

saltydk commented Nov 30, 2026

Copy link
Copy Markdown
Member

As mentioned to you on discord this will need to follow the updated instructions for agents.

Comment thread announcements.yml Resolved
@After-Shock

Copy link
Copy Markdown
Contributor Author

As mentioned to you on discord this will need to follow the updated instructions for agents.

Understood was just waiting on your agents.md changes.

Silo now publishes one image under its plain tags, with PostgreSQL and
Redis bundled and supervised by s6. The role runs it with /config under
the Silo appdata folder, PUID/PGID instead of a container user, and no
separate Postgres or Redis containers. The generated secret key is
exposed as silo_role_secret_key.

Existing multi-container installs are refused until they are migrated, so
Silo never starts on an empty database. Completion is checked in the
copied database itself: its bootstrap role must be silo and its users
table must have records.
`sb install sandbox-silo-migrate` moves an existing install into the
single-container layout with Silo's own migrate-compose-stack script.
The legacy cluster is mounted read-only and is never modified; Silo's
plugins, artwork and compat folders are hard-linked.

The copied cluster's bootstrap role is renamed to silo, the role the
bundled PostgreSQL authenticates, so Silo's migrations can alter the
existing tables. Row counts for users, media items and watch history are
compared before and after, and the legacy Postgres container is removed
only once they match.

@saltydk saltydk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: migration must preserve every override the legacy role honoured

The single-container role and the migration flow look solid: the announcement is append-only, containers are removed before the backend import, shm_size/stop_timeout go through the shared create task, and upstream's migrate-compose-stack refuses to copy while postmaster.pid exists. The blocking problem is that silo_migrate does not resolve the legacy settings the way the legacy silo role did, so some user overrides are silently replaced by defaults.

Why

The legacy role read every setting through lookup('role_var', '_x', role='silo'), which checks silo_x first and then silo_role_x. silo_migrate reads silo_role_x | default(...), which only sees the second form. The legacy PostgreSQL path default was also server_appdata_path/<silo_role_postgres_paths_folder>/postgres (independent of the main appdata folder), whereas the migrate default derives it from silo's _paths_location.

Verified resolution (legacy role at 05056d0d vs this PR)

Resolved with the Saltbox role_var plugin, loading postgres, silo and silo_migrate defaults, with each variant in its own process:

Inventory override Legacy role used PR's silo_migrate uses With the suggested fix
none silo-postgres / user.name / silo / pg18 / /opt/silo/postgres same same
silo_role_postgres_* (name, user, db, tag, location) the override the override the override
silo_postgres_name: silodb, silo_postgres_user: foo, silo_postgres_docker_env_db: foodb, silo_postgres_docker_image_tag: pg17, silo_redis_name: silokv the override defaults (silo-postgres, user.name, silo, pg18, silo-redis) the override
silo_postgres_paths_location: /mnt/fast/silo-pg /mnt/fast/silo-pg /opt/silo/postgres /mnt/fast/silo-pg
silo_role_postgres_paths_folder: silo-db /opt/silo-db/postgres /opt/silo/postgres /opt/silo-db/postgres
silo_role_paths_folder: silo-server /opt/silo/postgres /opt/silo-server/postgres /opt/silo/postgres

Consequences

  • Wrong path: sandbox-silo-migrate fails with "No legacy Silo PostgreSQL data was found. Run 'sb install sandbox-silo' for a new installation", while sandbox-silo refuses because plugins/ exists. The user is stuck in a loop.
  • Wrong user or database: Read legacy Silo row counts fails after the Silo container has already been removed. Upstream's script also depends on these values: it probes POSTGRES_USER and renames a non-silo POSTGRES_DB to silo.
  • Wrong container name (most serious): the role starts a second silo-postgres on the same data directory while the user's real legacy container is still running. PostgreSQL's lock-file check does not work across containers, because both postmasters are normally PID 1. Stopping the duplicate removes postmaster.pid, so upstream's "still running" guard passes and it copies a live cluster. This follows from how PostgreSQL's lock check works in containers; it has not been reproduced.
  • Overridden Silo container name: the migrate removes, waits on and execs into silo_name rather than the configured container. See the inline comment.

Requested changes

  1. Resolve every legacy setting in roles/silo_migrate/defaults/main.yml with lookup('role_var', '_x', role='silo', default=<legacy default>), and reproduce the legacy path formula (inline suggestions below).
  2. Use the resolved values in tasks: _postgres_paths_folder and the Silo _docker_container.
  3. Handle the external-database settings (silo_role_postgres_deploy: false, silo_role_database_url) explicitly, at least with an accurate failure message.
  4. Optional cleanup: replace the set_fact with a _lookup default.

With suggestions 1 and 2 applied, saltbox-lint check . (v0.2.7) and ansible-lint roles/silo_migrate both pass with no findings.

koito_migrate uses the same koito_role_x | default() pattern and has the same gap, but that is outside this PR.

Comment thread roles/silo_migrate/defaults/main.yml Resolved
Comment thread roles/silo_migrate/defaults/main.yml Resolved
Comment thread roles/silo_migrate/defaults/main.yml Resolved
Comment thread roles/silo_migrate/tasks/main.yml Resolved
Comment thread roles/silo_migrate/tasks/main.yml Resolved
Comment thread roles/silo_migrate/tasks/main.yml Resolved
Comment thread roles/silo_migrate/tasks/main.yml Resolved
Read every legacy setting with role_var against the silo role and the
legacy defaults, so silo_x overrides are honoured as well as silo_role_x.
The legacy PostgreSQL location is rebuilt from
silo_role_postgres_paths_folder instead of Silo's appdata folder, and
the configured Silo container name is used to remove, wait on and query
Silo.

Installs that used an external database are refused by both roles with
an explicit message instead of being sent to a migration that cannot
succeed. The PostgreSQL user is a _lookup default instead of a set_fact.

@saltydk saltydk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for 8fcd60a. I checked it on my side:

  • The legacy-setting lookups now resolve to the same values as the legacy role for every override form I tried: silo_role_*, silo_*, the PostgreSQL folder, the main appdata folder, the global postgres user, and an empty silo_role_postgres_user.
  • The container-name, folder and _lookup changes are correct.
  • The announcements.yml diff against master only adds lines.

Two follow-ups remain on the external-database handling, both inline. I think both are worth fixing in this PR, because upstream already supports the case.

  1. The refusal is a dead end, and upstream doesn't need one. The omnibus image turns its bundled PostgreSQL off when DATABASE_URL is set, and migrate-compose-stack moves only plugins, artwork and compat when DATABASE_URL names an external database. External installs can therefore be carried over instead of refused.
  2. Any silo_role_database_url is currently treated as external, including a URL that points at the legacy silo-postgres container. Upstream's script refuses that case with "remove it to use the bundled one"; the roles should do the same.

@keldian, could you weigh in on the docs side (saltyorg/docs#433)? Specifically: should the Silo page describe the external-database path (keep silo_role_database_url, run the migrate tag to move the app folders), or link to upstream's omnibus docs for it? And where should the note about removing a silo_role_database_url that points at the old silo-postgres container go?

Comment thread roles/silo_migrate/tasks/main.yml Resolved
Comment thread roles/silo/tasks/main.yml Resolved
silo_role_database_url is a setting again, empty for the bundled
database. When it is set, Silo gets it as DATABASE_URL, which turns the
image's own PostgreSQL off, and silo-migrate runs upstream's script with
that URL and without the legacy cluster mounts, so only plugins, artwork
and compat move. The legacy PostgreSQL steps are skipped for these
installs, and the silo role checks for the moved plugins folder instead
of the copied database.

A URL that points at the legacy PostgreSQL container is refused by both
roles before anything is removed, as upstream's script does.
@keldian

keldian commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

@keldian, could you weigh in on the docs side (saltyorg/docs#433)? Specifically: should the Silo page describe the external-database path (keep silo_role_database_url, run the migrate tag to move the app folders), or link to upstream's omnibus docs for it? And where should the note about removing a silo_role_database_url that points at the old silo-postgres container go?

saltyorg/docs#433 (review)

…tead of rc inference

ansible-core 2.22 deprecates inferring a task failure from a non-zero rc. The legacy and migrated row count reads now state it, as 1f8d01f did for the other docker_container_exec tasks.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants