feat(docker): derive the apt architecture from the host #331

Merged
Defame1297 merged 2 commits from feat/300-docker-apt-arch into main 2026-11-23 19:52:59 +00:00
Collaborator

What and why

Closes #300

docker_apt_arch defaulted to amd64, so on an arm64 Ubuntu host that was not overridden the apt source said arch=amd64 and apt found no Docker packages. The default is now empty, which derives the architecture from the host: x86_64 gives amd64, aarch64 gives arm64. A value set in the inventory is always used, so nothing changes for a consumer who already sets it.

The two questions the issue left open, answered as proposed (please confirm): derive it from the fact as the default, and fail for any other architecture instead of falling back to amd64. The failure message names docker_apt_arch and says to set it (for example armhf). The value is written into the one-line apt source, so it must be lowercase letters and digits; a space or a bracket is refused before anything changes.

Layout follows roles/AGENTS.md: the lookup table is a constant in vars/main.yml (__docker_arch_by_fact), the resolution and the check are in a new tasks/validate.yml imported first (tags: always), and install.yml reads __docker_apt_arch. A removal (docker_remove) skips the validation, since it does not write the source.

Behaviour change: a host with an architecture other than x86_64 or aarch64 that relied on the amd64 default now fails with a clear message instead of getting an amd64 source line apt cannot use.

Verified

  • The resolution and the check, with Ansible's own engine, ten cases: x86_64 gives amd64, aarch64 gives arm64, an explicit amd64 on aarch64 wins, an explicit armhf on an unknown ARM host is used; armv7l and riscv64 without an override, a missing architecture fact, bad arch, amd64] and AMD64 are refused, each with a message that names docker_apt_arch.
  • All commit-stage hooks pass (yamllint, ansible-lint, REUSE, changelog lint, Conventional Commit).
  • An independent review of the diff, no blocking finding; it also ran the role with gather_facts: false and with the docker_remove flow, and its wording findings are applied.
  • Molecule additions: a refusal play for a bad docker_apt_arch; the existing verify assertion arch=amd64 now exercises the derived default on the x86_64 container.

Not verified

  • Molecule itself (CI only), and any architecture other than x86_64 in it: the container is x86_64, so the arm64 mapping and the unsupported-architecture failure are covered by my local engine tests but not by CI.
  • The role on a real arm64 host.

  • I confirm third-party material is recorded in NOTICE and REUSE.toml, or there is none.

Assisted-by: Claude Code

## What and why Closes #300 `docker_apt_arch` defaulted to `amd64`, so on an arm64 Ubuntu host that was not overridden the apt source said `arch=amd64` and apt found no Docker packages. The default is now empty, which derives the architecture from the host: `x86_64` gives `amd64`, `aarch64` gives `arm64`. A value set in the inventory is always used, so nothing changes for a consumer who already sets it. The two questions the issue left open, answered as proposed (please confirm): derive it from the fact as the default, and fail for any other architecture instead of falling back to `amd64`. The failure message names `docker_apt_arch` and says to set it (for example `armhf`). The value is written into the one-line apt source, so it must be lowercase letters and digits; a space or a bracket is refused before anything changes. Layout follows `roles/AGENTS.md`: the lookup table is a constant in `vars/main.yml` (`__docker_arch_by_fact`), the resolution and the check are in a new `tasks/validate.yml` imported first (`tags: always`), and `install.yml` reads `__docker_apt_arch`. A removal (`docker_remove`) skips the validation, since it does not write the source. **Behaviour change:** a host with an architecture other than `x86_64` or `aarch64` that relied on the `amd64` default now fails with a clear message instead of getting an `amd64` source line apt cannot use. ## Verified - The resolution and the check, with Ansible's own engine, ten cases: `x86_64` gives `amd64`, `aarch64` gives `arm64`, an explicit `amd64` on `aarch64` wins, an explicit `armhf` on an unknown ARM host is used; `armv7l` and `riscv64` without an override, a missing architecture fact, `bad arch`, `amd64]` and `AMD64` are refused, each with a message that names `docker_apt_arch`. - All commit-stage hooks pass (yamllint, ansible-lint, REUSE, changelog lint, Conventional Commit). - An independent review of the diff, no blocking finding; it also ran the role with `gather_facts: false` and with the `docker_remove` flow, and its wording findings are applied. - Molecule additions: a refusal play for a bad `docker_apt_arch`; the existing verify assertion `arch=amd64` now exercises the derived default on the x86_64 container. ## Not verified - Molecule itself (CI only), and any architecture other than `x86_64` in it: the container is x86_64, so the `arm64` mapping and the unsupported-architecture failure are covered by my local engine tests but not by CI. - The role on a real arm64 host. --- - [x] I confirm third-party material is recorded in `NOTICE` and `REUSE.toml`, or there is none. Assisted-by: Claude Code
Dragonish added 1 commit 2026-11-23 19:31:19 +00:00
feat(docker): derive the apt architecture from the host
Build / build (pull_request) Successful in 19s
Molecule / molecule (pull_request) Canceled after 0s
Lint / lint (pull_request) Canceled after 25s
ba96e98585
docker_apt_arch defaults to empty, which derives amd64 or arm64 from
the host architecture; another architecture fails the play, and a set
value is always used.

Assisted-by: Claude Code
Defame1297 added 1 commit 2026-11-23 19:47:04 +00:00
Merge branch 'main' into feat/300-docker-apt-arch
Build / build (pull_request) Successful in 16s
Molecule / molecule (pull_request) Successful in 3m3s
Lint / lint (pull_request) Successful in 1m18s
a9aa1f2e0e
Defame1297 merged commit 943cd96580 into main 2026-11-23 19:52:59 +00:00
Defame1297 deleted branch feat/300-docker-apt-arch 2026-11-23 19:53:00 +00:00
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mortis/Kamino#331