Author SHA1 Message Date
renovate-bot b55af7c7bf chore(deps): update own ci images
renovate/stability-days Updates have met minimum release age requirement
Gitea release key / check (pull_request) Successful in 25s
Build / build (pull_request) Successful in 52s
Lint / lint (pull_request) Successful in 3m55s
Molecule / molecule (pull_request) Successful in 37m19s
2026-12-02 03:17:36 +00:00
51 changed files with 247 additions and 942 deletions

No files matched your search

+5 -18
View File
@@ -53,8 +53,8 @@ issue.
- **Lint and Build run in the pinned `ci` image and compare the pin files with the checksums - **Lint and Build run in the pinned `ci` image and compare the pin files with the checksums
baked into it (`/opt/ci-pins.sha256`).** A pull request that changes `requirements-dev.txt`, baked into it (`/opt/ci-pins.sha256`).** A pull request that changes `requirements-dev.txt`,
`requirements-dev.lock`, `requirements.yml` or `.pre-commit-config.yaml` takes the slow path, `requirements-dev.lock`, `requirements.yml`, `extensions/molecule/requirements.yml` or
which installs the pinned tools and collections. `.pre-commit-config.yaml` takes the slow path, which installs the pinned tools and collections.
*Why:* a pull request is tested on its own pins, and an unchanged one starts in seconds. *Why:* a pull request is tested on its own pins, and an unchanged one starts in seconds.
*Held:* control: the "Check the baked tooling against the pins" step. *Held:* control: the "Check the baked tooling against the pins" step.
- **On the fast path the network is cut by environment**: `PIP_NO_INDEX=1`, the proxy variables - **On the fast path the network is cut by environment**: `PIP_NO_INDEX=1`, the proxy variables
@@ -72,24 +72,11 @@ issue.
## Molecule ## Molecule
- **Molecule runs on every same-repository pull request, Renovate's included, with no path - **Molecule runs on every same-repository pull request, Renovate's included, with no path
filter.** A fork pull request is skipped by the jobs' shared `if:` guard, which is a convenience, not a filter.** A fork pull request is skipped by the job's `if:`, which is a convenience, not a
boundary: a fork controls its own workflow file. Gitea's approval gate keeps a fork's runs from boundary: a fork controls its own workflow file. Gitea's approval gate keeps a fork's runs from
starting, and the fork rule in [reviewing.md](../../docs/contributing/reviewing.md) keeps it starting, and the fork rule in [reviewing.md](../../docs/contributing/reviewing.md) keeps it
shut. *Why:* a check that always reports can be required, and a new image is tested by its own shut. *Why:* a check that always reports can be required, and a new image is tested by its own
pin pull request. *Held:* review. pin pull request. *Held:* review.
- **Molecule has three jobs: `select`, `scenarios` and `result`.** `select` runs the selector in
a job container on `kamino-docker`, in the `molecule-controller` pin (never the `ci` pin, whose
bumps would then select every scenario), and outputs the selected directories, or `none`.
`scenarios` runs them on `kamino-molecule` and is skipped for `none` or an empty output.
`result` (check `Molecule / Result (pull_request)`) is the required check: it runs
`if: always()` and fails unless `select` passed and `scenarios` passed or was skipped for
`none`, so a lost output fails it. The
controller pin is written in all three jobs, because `container.image` cannot read `env`.
*Why:* a pull request that selects nothing takes no Molecule runner slot, and a skipped job
counts as passing in Gitea, so only a job that always runs can be required. *Held:* control:
`WorkflowJobsTest` in `tests/scripts/test_run_molecule_scenarios.py` for the jobs, runners,
guard and result logic, and `test_every_controller_pin_is_the_same` in
`tests/scripts/test_select_molecule_scenarios.py` for the pin copies.
- **What a pull request runs is chosen by `scripts/select_molecule_scenarios.py`:** the scenarios - **What a pull request runs is chosen by `scripts/select_molecule_scenarios.py`:** the scenarios
of the roles it changes and of the roles that use them (any file naming of the roles it changes and of the roles that use them (any file naming
`mortis.kamino.<role>`, transitively), none for a diff of only IGNORED paths, a failure for a `mortis.kamino.<role>`, transitively), none for a diff of only IGNORED paths, a failure for a
@@ -109,7 +96,7 @@ issue.
(release versions, `build_ignore`) do not change what a scenario runs, and the Build check (release versions, `build_ignore`) do not change what a scenario runs, and the Build check
proves the collection builds; they had caused about a third of full pull request runs and their proves the collection builds; they had caused about a third of full pull request runs and their
minutes (#338). *Held:* control: `scripts/check_scenarios_load_checkout.py`, which minutes (#338). *Held:* control: `scripts/check_scenarios_load_checkout.py`, which
`run_molecule_in_controller.sh` runs on the selected scenarios before they start, fails the run `run_molecule_in_ci_image.sh` runs on the selected scenarios before they start, fails the run
when the environment molecule gives `ansible-playbook` resolves `mortis.kamino` anywhere else, when the environment molecule gives `ansible-playbook` resolves `mortis.kamino` anywhere else,
or when `prerun` is not off once the base config is merged as molecule's CLI merges it (a or when `prerun` is not off once the base config is merged as molecule's CLI merges it (a
scenario turns it on, or the base config is moved or turns it on). scenario turns it on, or the base config is moved or turns it on).
@@ -148,7 +135,7 @@ issue.
`requirements-molecule.lock` selects every scenario; `requirements-dev.*` pins only Lint's tools `requirements-molecule.lock` selects every scenario; `requirements-dev.*` pins only Lint's tools
and selects none. *Why:* a pull request that bumps ansible-core or molecule must run its and selects none. *Why:* a pull request that bumps ansible-core or molecule must run its
scenarios on them before it automerges. *Held:* control: the pin comparison in scenarios on them before it automerges. *Held:* control: the pin comparison in
`run_molecule_in_controller.sh`, and the selector's tests for which pin files select what. `run_molecule_in_ci_image.sh`, and the selector's tests for which pin files select what.
- **Every scenario sets `scenario.test_sequence` to molecule's default minus both `destroy` - **Every scenario sets `scenario.test_sequence` to molecule's default minus both `destroy`
steps, with a role scenario's `check` right before and right after `converge`, names each steps, with a role scenario's `check` right before and right after `converge`, names each
platform `${KAMINO_RUN_ID:-local}-<name>` and labels it platform `${KAMINO_RUN_ID:-local}-<name>` and labels it
+3 -3
View File
@@ -28,7 +28,7 @@ jobs:
timeout-minutes: 30 timeout-minutes: 30
# The ci image (images/ci, built by image.yml): tag for the release, digest enforced. # The ci image (images/ci, built by image.yml): tag for the release, digest enforced.
container: container:
image: git.rkdr.net/mortis/ci:0.2.53@sha256:a106bd35c649fd15f027d4a4e81aa27d60b3c0377bbb6abfd73faf180f8c6f84 image: git.rkdr.net/mortis/ci:0.2.50@sha256:087e2e841e12a24f2b34b4c1a13c40682bef2940d0fe13b74db264f4fe9a1cd4
env: env:
PIP_DISABLE_PIP_VERSION_CHECK: "1" PIP_DISABLE_PIP_VERSION_CHECK: "1"
steps: steps:
@@ -66,8 +66,8 @@ jobs:
HTTP_PROXY=http://127.0.0.1:9 HTTPS_PROXY=http://127.0.0.1:9 no_proxy= NO_PROXY= >> "$GITHUB_ENV" HTTP_PROXY=http://127.0.0.1:9 HTTPS_PROXY=http://127.0.0.1:9 no_proxy= NO_PROXY= >> "$GITHUB_ENV"
echo "::notice::Later steps run with a dead proxy; a download fails the job (bake it into images/ci)." echo "::notice::Later steps run with a dead proxy; a download fails the job (bake it into images/ci)."
else else
echo "::warning::requirements-dev.txt, requirements-dev.lock, requirements.yml" \ echo "::warning::requirements-dev.txt, requirements-dev.lock, requirements.yml," \
"or .pre-commit-config.yaml differ from the ci image;" \ "extensions/molecule/requirements.yml or .pre-commit-config.yaml differ from the ci image;" \
"installing the pinned tools for this run." "installing the pinned tools for this run."
/opt/venv/bin/pip install --quiet --require-hashes -r requirements-dev.lock -r requirements-dev.txt /opt/venv/bin/pip install --quiet --require-hashes -r requirements-dev.lock -r requirements-dev.txt
fi fi
+1 -1
View File
@@ -44,7 +44,7 @@ jobs:
# The ci image (images/ci, built by image.yml), at the pin of lint.yml: tag for the # The ci image (images/ci, built by image.yml), at the pin of lint.yml: tag for the
# release, digest enforced. Only its /opt/venv Python (with PyYAML) is used here. # release, digest enforced. Only its /opt/venv Python (with PyYAML) is used here.
container: container:
image: git.rkdr.net/mortis/ci:0.2.53@sha256:a106bd35c649fd15f027d4a4e81aa27d60b3c0377bbb6abfd73faf180f8c6f84 image: git.rkdr.net/mortis/ci:0.2.50@sha256:087e2e841e12a24f2b34b4c1a13c40682bef2940d0fe13b74db264f4fe9a1cd4
steps: steps:
# The container has no Node, so JavaScript actions such as actions/checkout # The container has no Node, so JavaScript actions such as actions/checkout
# cannot run; clone with git and the job token. # cannot run; clone with git and the job token.
+32 -30
View File
@@ -39,15 +39,15 @@ on: # yamllint disable-line rule:truthy
- main - main
paths: paths:
- 'images/**' - 'images/**'
# The ci image bakes these files' contents in (images/ci/Dockerfile); requirements.yml too. # The ci image bakes these files' contents in (images/ci/Dockerfile).
- 'requirements-dev.txt' - 'requirements-dev.txt'
- 'requirements-dev.lock' - 'requirements-dev.lock'
- 'requirements.yml' - 'requirements.yml'
- 'extensions/molecule/requirements.yml'
- '.pre-commit-config.yaml' - '.pre-commit-config.yaml'
# The molecule-controller image bakes these, and requirements.yml (its Dockerfile). # The molecule-controller image bakes these (images/molecule-controller/Dockerfile).
- 'requirements-molecule.txt' - 'requirements-molecule.txt'
- 'requirements-molecule.lock' - 'requirements-molecule.lock'
- 'extensions/molecule/requirements.yml'
- '.gitea/workflows/image.yml' - '.gitea/workflows/image.yml'
workflow_dispatch: {} workflow_dispatch: {}
@@ -83,22 +83,22 @@ jobs:
base: "0.1" base: "0.1"
subpath: images/molecule-ubuntu2404 subpath: images/molecule-ubuntu2404
dockerfile: Dockerfile dockerfile: Dockerfile
job_image: ubuntu:24.04@sha256:168a88cc61bdd95c8f871e3903d4e0a525e340c2b28a70dadd6d1503ecc7c391 job_image: ubuntu:24.04@sha256:562111b88caa79c71391c0c4d3c2114a7d5c35915c20561fd893cb1e07929e6b
- name: molecule-ubuntu2604 - name: molecule-ubuntu2604
base: "0.1" base: "0.1"
subpath: images/molecule-ubuntu2604 subpath: images/molecule-ubuntu2604
dockerfile: Dockerfile dockerfile: Dockerfile
job_image: ubuntu:26.04@sha256:a8417def3fc37c2d8cf513fe69ef871d415a45a27847779fae461c5047710edd job_image: ubuntu:26.04@sha256:d66b366dac61b575bee2aef07e9c26e8070096fbe84a3d4d3eb0da069b5d76db
- name: ci - name: ci
base: "0.2" base: "0.2"
subpath: "" subpath: ""
dockerfile: images/ci/Dockerfile dockerfile: images/ci/Dockerfile
job_image: ubuntu:26.04@sha256:a8417def3fc37c2d8cf513fe69ef871d415a45a27847779fae461c5047710edd job_image: ubuntu:26.04@sha256:d66b366dac61b575bee2aef07e9c26e8070096fbe84a3d4d3eb0da069b5d76db
- name: molecule-controller - name: molecule-controller
base: "0.1" base: "0.1"
subpath: "" subpath: ""
dockerfile: images/molecule-controller/Dockerfile dockerfile: images/molecule-controller/Dockerfile
job_image: ubuntu:26.04@sha256:a8417def3fc37c2d8cf513fe69ef871d415a45a27847779fae461c5047710edd job_image: ubuntu:26.04@sha256:d66b366dac61b575bee2aef07e9c26e8070096fbe84a3d4d3eb0da069b5d76db
container: container:
image: ${{ matrix.job_image }} image: ${{ matrix.job_image }}
# Keeps a runaway build from taking the whole runner down with it. # Keeps a runaway build from taking the whole runner down with it.
@@ -107,17 +107,21 @@ jobs:
DEBIAN_FRONTEND: noninteractive DEBIAN_FRONTEND: noninteractive
IMAGE_PATH: mortis/${{ matrix.name }} IMAGE_PATH: mortis/${{ matrix.name }}
steps: steps:
# Kaniko unpacks the base image into the job container's own root filesystem and # One step, in this order, so the filesystem the build starts from is the pristine
# snapshots from there, so anything left in it (curl and its libraries) would count # base image. Kaniko unpacks the base image into the job container's own root
# as "already present" and be missing from the layers that install the same packages. # filesystem and snapshots from there, so anything installed in the job container
# The build's --pre-cleanup empties that filesystem first; this step also cleans up # first (curl and its libraries) would count as "already present" and be missing
# after itself, so a leftover fails the job instead of relying on that flag alone. # from the layers that install the same packages (ca-certificates, libkrb5 ...).
# The tools are therefore installed, used, and exactly the packages the install # The tools are therefore installed, used, and exactly the packages the install
# added are purged (not `autoremove`, which would also drop base packages that # added are purged (not `autoremove`, which would also drop base packages that
# are marked auto-installed). The package names must then equal those recorded before # are marked auto-installed). The result is compared with what was recorded
# the install, and a new file under /usr, /lib, /bin, /sbin, /opt or /etc that no # before the install: the package names and versions must be identical, and any
# package owns fails the job. Versions may differ: the install upgrades a base package # file difference under /usr, /lib, /bin, /sbin, /opt or /etc fails the job.
# when Ubuntu has a newer one, and the build starts from the base image's copy again. # Names only, no sizes or modes, and /var/log, /run and dpkg's *-old files are
# not compared: logs and dpkg state the install touched may end up in the first
# layer as modified files. That is cosmetic. Not yet checked: listing the layers
# (crane export | tar t, looking for run/act, root/ and var/log/apt) needs a
# read:package token, which the Claude token lacks.
# #
# The pinned kaniko v1.28.6 image has index digest # The pinned kaniko v1.28.6 image has index digest
# sha256:2fa20b0a4b40c7db72b479d57e55c2cf79f2178533b2d3bcbd129d6bd3c087ed and # sha256:2fa20b0a4b40c7db72b479d57e55c2cf79f2178533b2d3bcbd129d6bd3c087ed and
@@ -159,6 +163,7 @@ jobs:
snapshot > /kaniko/fs.before snapshot > /kaniko/fs.before
pkgs() { dpkg-query -W -f='${Package}:${Architecture}\n' | LC_ALL=C sort; } pkgs() { dpkg-query -W -f='${Package}:${Architecture}\n' | LC_ALL=C sort; }
pkgs > /kaniko/pkgs.before pkgs > /kaniko/pkgs.before
dpkg-query -W -f='${Package}:${Architecture} ${Version}\n' | LC_ALL=C sort > /kaniko/pkgv.before
apt-get update apt-get update
apt-get install -y --no-install-recommends ca-certificates curl python3 apt-get install -y --no-install-recommends ca-certificates curl python3
@@ -168,7 +173,7 @@ jobs:
printf 'header = "Authorization: token %s"\n' "$JOB_TOKEN" \ printf 'header = "Authorization: token %s"\n' "$JOB_TOKEN" \
| curl -fsSL -K - "${SERVER_URL}/api/v1/repos/${REPO}/archive/${SHA}.tar.gz" \ | curl -fsSL -K - "${SERVER_URL}/api/v1/repos/${REPO}/archive/${SHA}.tar.gz" \
| tar -xz -C /tmp/src --strip-components=1 | tar -xz -C /tmp/src --strip-components=1
# -B: no bytecode left behind to break the leftover check below. # -B: no bytecode left behind to break the pristine-filesystem check below.
env -u PAT_USER -u PAT_TOKEN -u JOB_TOKEN python3 -B -E -s \ env -u PAT_USER -u PAT_TOKEN -u JOB_TOKEN python3 -B -E -s \
/tmp/src/scripts/next_image_version.py /tmp/src "$IMAGE_NAME" "$SERVER_URL" > /kaniko/image-version /tmp/src/scripts/next_image_version.py /tmp/src "$IMAGE_NAME" "$SERVER_URL" > /kaniko/image-version
if [ -s /kaniko/image-version ]; then if [ -s /kaniko/image-version ]; then
@@ -238,24 +243,25 @@ jobs:
fi fi
fi fi
# Purge exactly what the install added, then compare packages and files with the record (see above). # Back to the pristine base image (see above): purge exactly what the install
# added, then compare packages (names and versions) and files with the record.
pkgs > /kaniko/pkgs.installed pkgs > /kaniko/pkgs.installed
comm -13 /kaniko/pkgs.before /kaniko/pkgs.installed | xargs apt-get purge -y comm -13 /kaniko/pkgs.before /kaniko/pkgs.installed | xargs apt-get purge -y
apt-get clean apt-get clean
rm -rf /var/lib/apt/lists/* /tmp/* rm -rf /var/lib/apt/lists/* /tmp/*
pkgs > /kaniko/pkgs.after dpkg-query -W -f='${Package}:${Architecture} ${Version}\n' | LC_ALL=C sort > /kaniko/pkgv.after
if ! diff /kaniko/pkgs.before /kaniko/pkgs.after; then if ! diff /kaniko/pkgv.before /kaniko/pkgv.after; then
echo "::error::The installed packages are not those of the base image (differences above)." echo "::error::The installed packages differ from the pristine base image (listed above): the install" \
"upgraded or left packages behind, so the build would start from a modified filesystem."
exit 1 exit 1
fi fi
snapshot > /kaniko/fs.after snapshot > /kaniko/fs.after
comm -13 /kaniko/fs.before /kaniko/fs.after > /kaniko/fs.new diff /kaniko/fs.before /kaniko/fs.after > /kaniko/fs.diff || true
# dpkg -S fails on a path no package owns; an upgraded base package may bring new files of its own. if grep -E '^[<>] /(usr|lib|bin|sbin|opt|etc)/' /kaniko/fs.diff; then
if ! sed -nE '\#^/(usr|lib|bin|sbin|opt|etc)/#p' /kaniko/fs.new | xargs -r -d '\n' dpkg -S > /dev/null; then echo "::error::The job container differs from the pristine base image (listed above); the build would produce wrong layers."
echo "::error::The install left files behind that no package owns (listed above)."
exit 1 exit 1
fi fi
echo "Package and filesystem check passed" echo "Package and filesystem check passed ($(grep -c '^[<>]' /kaniko/fs.diff || true) unrelated file differences outside the checked directories)"
- name: Build and push with kaniko - name: Build and push with kaniko
env: env:
@@ -273,9 +279,6 @@ jobs:
set +x set +x
set -eu set -eu
export DOCKER_CONFIG=/kaniko/.docker export DOCKER_CONFIG=/kaniko/.docker
# A build that fails right after --pre-cleanup leaves no rm for the last step, so empty the
# credential file with a shell builtin.
trap '{ : > "$DOCKER_CONFIG/config.json"; } 2> /dev/null || true' EXIT
# The CA bundle from the kaniko image: the base image has none. # The CA bundle from the kaniko image: the base image has none.
export SSL_CERT_DIR=/kaniko/ssl/certs export SSL_CERT_DIR=/kaniko/ssl/certs
registry="${SERVER_URL#https://}" registry="${SERVER_URL#https://}"
@@ -328,7 +331,6 @@ jobs:
"${ctx[@]}" \ "${ctx[@]}" \
"${dests[@]}" \ "${dests[@]}" \
"${labels[@]}" \ "${labels[@]}" \
--pre-cleanup \
--snapshot-mode=redo \ --snapshot-mode=redo \
--cache=false \ --cache=false \
--push-retry 3 \ --push-retry 3 \
+5 -5
View File
@@ -6,8 +6,8 @@ name: Lint
# The tools come from the ci image (images/ci, built by image.yml): the pinned Python # The tools come from the ci image (images/ci, built by image.yml): the pinned Python
# tools of requirements-dev.txt, the collections of requirements.yml and the hook # tools of requirements-dev.txt, the collections of requirements.yml and the hook
# environments of .pre-commit-config.yaml are baked in. When a PR changes one of those # environments of .pre-commit-config.yaml are baked in. When a PR changes one of those
# files the checksum check below fails and the job installs the pinned tools and # files or extensions/molecule/requirements.yml the checksum check below fails and the
# collections itself for this run (slower, same result). # job installs the pinned tools and collections itself for this run (slower, same result).
on: # yamllint disable-line rule:truthy on: # yamllint disable-line rule:truthy
pull_request: pull_request:
branches: branches:
@@ -31,7 +31,7 @@ jobs:
# The tag says which release, the digest is what is enforced (bump both together # The tag says which release, the digest is what is enforced (bump both together
# when image.yml publishes a new version). # when image.yml publishes a new version).
container: container:
image: git.rkdr.net/mortis/ci:0.2.53@sha256:a106bd35c649fd15f027d4a4e81aa27d60b3c0377bbb6abfd73faf180f8c6f84 image: git.rkdr.net/mortis/ci:0.2.50@sha256:087e2e841e12a24f2b34b4c1a13c40682bef2940d0fe13b74db264f4fe9a1cd4
env: env:
PIP_DISABLE_PIP_VERSION_CHECK: "1" PIP_DISABLE_PIP_VERSION_CHECK: "1"
PRE_COMMIT_HOME: /opt/pre-commit PRE_COMMIT_HOME: /opt/pre-commit
@@ -65,8 +65,8 @@ jobs:
HTTP_PROXY=http://127.0.0.1:9 HTTPS_PROXY=http://127.0.0.1:9 no_proxy= NO_PROXY= >> "$GITHUB_ENV" HTTP_PROXY=http://127.0.0.1:9 HTTPS_PROXY=http://127.0.0.1:9 no_proxy= NO_PROXY= >> "$GITHUB_ENV"
echo "::notice::Later steps run with a dead proxy; a download fails the job (bake it into images/ci)." echo "::notice::Later steps run with a dead proxy; a download fails the job (bake it into images/ci)."
else else
echo "::warning::requirements-dev.txt, requirements-dev.lock, requirements.yml" \ echo "::warning::requirements-dev.txt, requirements-dev.lock, requirements.yml," \
"or .pre-commit-config.yaml differ from the ci image;" \ "extensions/molecule/requirements.yml or .pre-commit-config.yaml differ from the ci image;" \
"installing the pinned tools and collections for this run." "installing the pinned tools and collections for this run."
/opt/venv/bin/pip install --quiet --require-hashes -r requirements-dev.lock -r requirements-dev.txt /opt/venv/bin/pip install --quiet --require-hashes -r requirements-dev.lock -r requirements-dev.txt
# --force: the baked copy of a changed pin is replaced, not kept as "already installed". # --force: the baked copy of a changed pin is replaced, not kept as "already installed".
+30 -118
View File
@@ -4,13 +4,8 @@ name: Molecule
# extensions/molecule/*/ and roles/*/molecule/*/. extensions/molecule/image-smoke and # extensions/molecule/*/ and roles/*/molecule/*/. extensions/molecule/image-smoke and
# image-smoke-2604 test the test images themselves, so they run even before any role exists. # image-smoke-2604 test the test images themselves, so they run even before any role exists.
# #
# Three jobs, so that a pull request that selects no scenario takes no Molecule runner slot: # It runs on the `kamino-molecule` label, a host executor that uses the runner's own
# `select` chooses the scenarios in a job container on `kamino-docker`; `scenarios` runs them on # Docker daemon; no job container is given the Docker socket. That makes the job
# `kamino-molecule`, and is skipped when none is selected; `result` is the required check and
# passes only when `select` passed and `scenarios` passed or was skipped for an empty selection.
#
# The scenarios job runs on the `kamino-molecule` label, a host executor that uses the runner's
# own Docker daemon; no job container is given the Docker socket. That makes the job
# root-equivalent on the runner, which is disposable and holds no secret from outside # root-equivalent on the runner, which is disposable and holds no secret from outside
# this repository. The `if:` guard is a convenience filter, not a boundary: a fork controls its # this repository. The `if:` guard is a convenience filter, not a boundary: a fork controls its
# own workflow file. The boundaries are write access, which only trusted people have, and Gitea's # own workflow file. The boundaries are write access, which only trusted people have, and Gitea's
@@ -21,8 +16,7 @@ name: Molecule
# at the same path, so the paths molecule hands the daemon resolve. Like Lint and Build, it installs # at the same path, so the paths molecule hands the daemon resolve. Like Lint and Build, it installs
# the pull request's pins when they differ from the image's. The images are pinned by tag and # the pull request's pins when they differ from the image's. The images are pinned by tag and
# digest: bump them here when image.yml publishes a new molecule-controller, molecule-ubuntu2404 or # digest: bump them here when image.yml publishes a new molecule-controller, molecule-ubuntu2404 or
# molecule-ubuntu2604 version. The molecule-controller pin is written three times, because # molecule-ubuntu2604 version.
# `container.image` cannot read `env`; a script test holds the copies equal.
on: # yamllint disable-line rule:truthy on: # yamllint disable-line rule:truthy
pull_request: pull_request:
branches: branches:
@@ -50,82 +44,15 @@ concurrency:
cancel-in-progress: ${{ github.event_name == 'pull_request' }} cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs: jobs:
select: molecule:
# Same-repo branches only (bot branches included: a Renovate pin pull request is what tests a new # Same-repo branches only (bot branches included: a Renovate pin pull request is what tests a new
# image); the nightly run and a manual dispatch always run. No paths filter on pull requests, so # image); the nightly run and a manual dispatch always run. No paths filter on pull requests, so
# that Molecule can be a required check: a required check that a pull request never starts would # that Molecule can be a required check: a required check that a pull request never starts would
# block it. A fork pull request is skipped by the guard below, which all three jobs share. # block it. A fork pull request is skipped by the guard below.
if: >- if: >-
github.repository == 'mortis/kamino' && github.repository == 'mortis/kamino' &&
(github.event_name != 'pull_request' || (github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name == github.repository) github.event.pull_request.head.repo.full_name == github.repository)
runs-on: kamino-docker
timeout-minutes: 10
# The molecule-controller pin, as CONTROLLER_IMAGE below: a ci pin here would make every ci
# bump select every scenario (ADR 0003).
container:
image: git.rkdr.net/mortis/molecule-controller:0.1.4@sha256:5658231afaff531161f02aef7a436ed875b1ad6c8d55a8d144e9763c71244420
outputs:
scenarios: ${{ steps.select.outputs.scenarios }}
steps:
# The selector's diff needs origin/main and the full history, so a clone, not a fetch of HEAD.
- name: Checkout the commit under test
env:
GIT_CONFIG_COUNT: "1"
GIT_CONFIG_KEY_0: http.extraheader
GIT_CONFIG_VALUE_0: "AUTHORIZATION: bearer ${{ secrets.GITHUB_TOKEN }}"
SHA: ${{ github.event.pull_request.head.sha || github.sha }}
REF: ${{ github.ref }}
REPO_URL: ${{ github.server_url }}/${{ github.repository }}
run: |
rm -rf ac
mkdir -p ac/ansible_collections/mortis
git clone "$REPO_URL" ac/ansible_collections/mortis/kamino
cd ac/ansible_collections/mortis/kamino
# A clone has no refs/pull/*: fetch the run's ref when the sha is not on a branch.
git checkout "$SHA" || { git fetch origin "$REF" && git checkout "$SHA"; }
echo "Checked out $(git rev-parse HEAD)"
# A pull request runs only the scenarios of the roles it changes (scripts/select_molecule_scenarios.py
# explains the rules); the nightly run and a manual dispatch run all of them, because the
# selector narrows only when EVENT_NAME is pull_request.
- name: Select the scenarios
id: select
working-directory: ac/ansible_collections/mortis/kamino
env:
EVENT_NAME: ${{ github.event_name }}
# The workflow only runs for pull requests to main; lint.yml uses the same constant.
BASE_REF: origin/main
run: |
# The selector comes from the base branch, so a pull request cannot edit the rules it is
# judged by (lint.yml does the same for check_bot_pr_diff.py); the first pull request that
# adds it has no base copy yet and uses its own.
sel=scripts/select_molecule_scenarios.py
if git cat-file -e "$BASE_REF:$sel" 2>/dev/null; then
sel_dir="$(mktemp -d)"
trap 'rm -rf "$sel_dir"' EXIT
git show "$BASE_REF:$sel" > "$sel_dir/select.py"
sel="$sel_dir/select.py"
else
echo "::notice::no base copy of $sel; running this checkout's copy"
fi
selected="$(python3 -I "$sel" "$BASE_REF")" || exit 1
# `none` marks an empty selection, so a lost or empty output fails result, never passes.
if [ -z "$selected" ]; then selected=none; fi
# One directory per line; a random delimiter, so no line of the list can end the value.
delim="scenarios-$(od -An -N16 -tx1 /dev/urandom | tr -d ' \n')"
printf 'scenarios<<%s\n%s\n%s\n' "$delim" "$selected" "$delim" >> "$GITHUB_OUTPUT"
scenarios:
needs: select
# Skipped, not failed, when select fails, selects nothing (`none`) or loses its output (empty);
# result passes only the second.
if: >-
needs.select.outputs.scenarios != 'none' &&
needs.select.outputs.scenarios != '' &&
github.repository == 'mortis/kamino' &&
(github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name == github.repository)
runs-on: [kamino-molecule] runs-on: [kamino-molecule]
# A full run under load takes about 45 minutes (PR #405: 44m53s), so 45 left no margin. Also the # A full run under load takes about 45 minutes (PR #405: 44m53s), so 45 left no margin. Also the
# age past which the sweep step removes a run's containers; a script test holds the two equal. # age past which the sweep step removes a run's containers; a script test holds the two equal.
@@ -134,15 +61,15 @@ jobs:
# The tools and collections molecule runs with, apart from Lint's (ADR 0003), so a tool # The tools and collections molecule runs with, apart from Lint's (ADR 0003), so a tool
# bump only Lint uses selects no scenario. # bump only Lint uses selects no scenario.
CONTROLLER_IMAGE: >- CONTROLLER_IMAGE: >-
git.rkdr.net/mortis/molecule-controller:0.1.4@sha256:5658231afaff531161f02aef7a436ed875b1ad6c8d55a8d144e9763c71244420 git.rkdr.net/mortis/molecule-controller:0.1.2@sha256:acd5079c8dd717fc039aa8eeccb0afccc691f9436716fed84742da69f93b1262
# Used by the scenarios as `image: ${MOLECULE_IMAGE}`; set it the same way to run # Used by the scenarios as `image: ${MOLECULE_IMAGE}`; set it the same way to run
# one locally. # one locally.
MOLECULE_IMAGE: >- MOLECULE_IMAGE: >-
git.rkdr.net/mortis/molecule-ubuntu2404:0.1.13@sha256:536cc31bb5ef5d5912b50afa98dc080bdb583baa601027298ec5e90e5712e178 git.rkdr.net/mortis/molecule-ubuntu2404:0.1.12@sha256:5f96ae95e16e205cc433607bab31307b36633ad73468aa7bdc57f4bbddb1c571
# The same for Ubuntu 26.04, the release the hosts are moving to; used by # The same for Ubuntu 26.04, the release the hosts are moving to; used by
# `image: ${MOLECULE_IMAGE_2604}` in extensions/molecule/image-smoke-2604. # `image: ${MOLECULE_IMAGE_2604}` in extensions/molecule/image-smoke-2604.
MOLECULE_IMAGE_2604: >- MOLECULE_IMAGE_2604: >-
git.rkdr.net/mortis/molecule-ubuntu2604:0.1.9@sha256:8a9e75ecd53c630e56f4df3a2ced990bfcbd49c247103297114a2b9f30f75d62 git.rkdr.net/mortis/molecule-ubuntu2604:0.1.8@sha256:96496c7fb35e6091d08b057e53ba603256d07483769f27c19582d336ddc11173
# Names and labels this run's containers: the scenarios' as `${KAMINO_RUN_ID:-local}-<name>` # Names and labels this run's containers: the scenarios' as `${KAMINO_RUN_ID:-local}-<name>`
# with the label net.rkdr.mortis.molecule-run, and the one molecule runs in. # with the label net.rkdr.mortis.molecule-run, and the one molecule runs in.
KAMINO_RUN_ID: ${{ github.run_id }}-${{ github.run_attempt }} KAMINO_RUN_ID: ${{ github.run_id }}-${{ github.run_attempt }}
@@ -194,15 +121,33 @@ jobs:
for id in $old; do left="$left$(docker ps -aq --filter "id=$id")"; done for id in $old; do left="$left$(docker ps -aq --filter "id=$id")"; done
if [ -n "$left" ]; then echo "::error::could not remove ${left//$'\n'/ }"; exit 1; fi if [ -n "$left" ]; then echo "::error::could not remove ${left//$'\n'/ }"; exit 1; fi
# scripts/run_molecule_scenarios.sh runs the selected scenarios, a few at a time, and removes # A pull request runs only the scenarios of the roles it changes (scripts/select_molecule_scenarios.py
# each scenario's containers as soon as it ends. # explains the rules); the nightly run and a manual dispatch run all of them, a few at a time.
# scripts/run_molecule_scenarios.sh runs them and removes each scenario's containers as soon as
# it ends.
- name: Run the scenarios - name: Run the scenarios
working-directory: ac/ansible_collections/mortis/kamino working-directory: ac/ansible_collections/mortis/kamino
env: env:
SELECTED: ${{ needs.select.outputs.scenarios }} EVENT_NAME: ${{ github.event_name }}
# The workflow only runs for pull requests to main; lint.yml uses the same constant.
BASE_REF: origin/main
# Empty outside a dispatch, which the run script reads as its default. # Empty outside a dispatch, which the run script reads as its default.
MOLECULE_LANES: ${{ inputs.lanes }} MOLECULE_LANES: ${{ inputs.lanes }}
run: | run: |
# The selector comes from the base branch, so a pull request cannot edit the rules it is
# judged by (lint.yml does the same for check_bot_pr_diff.py); the first pull request that
# adds it has no base copy yet and uses its own.
sel=scripts/select_molecule_scenarios.py
if git cat-file -e "$BASE_REF:$sel" 2>/dev/null; then
sel_dir="$(mktemp -d)"
trap 'rm -rf "$sel_dir"' EXIT
git show "$BASE_REF:$sel" > "$sel_dir/select.py"
sel="$sel_dir/select.py"
else
echo "::notice::no base copy of $sel; running this checkout's copy"
fi
selected="$(python3 -I "$sel" "$BASE_REF")" || exit 1
# As the runner user, with the socket's group, so nothing in the job tree is left root-owned. # As the runner user, with the socket's group, so nothing in the job tree is left root-owned.
# HOME (ansible's temp and caches) is in the job tree; a mounted passwd entry points the user # HOME (ansible's temp and caches) is in the job tree; a mounted passwd entry points the user
# at it, because ansible's temp path is `~<user>/.ansible/tmp`. The driver's connection plugin # at it, because ansible's temp path is `~<user>/.ansible/tmp`. The driver's connection plugin
@@ -220,7 +165,7 @@ jobs:
-v "$ac_root:$ac_root" -v "$ac_root/passwd:/etc/passwd:ro" -w "$PWD" \ -v "$ac_root:$ac_root" -v "$ac_root/passwd:/etc/passwd:ro" -w "$PWD" \
-e "AC_ROOT=$ac_root" -e "HOME=$ac_root/home" -e "USER=$(id -un)" \ -e "AC_ROOT=$ac_root" -e "HOME=$ac_root/home" -e "USER=$(id -un)" \
-e MOLECULE_IMAGE -e MOLECULE_IMAGE_2604 -e KAMINO_RUN_ID -e MOLECULE_LANES \ -e MOLECULE_IMAGE -e MOLECULE_IMAGE_2604 -e KAMINO_RUN_ID -e MOLECULE_LANES \
"$CONTROLLER_IMAGE" scripts/run_molecule_in_controller.sh <<< "$SELECTED" "$CONTROLLER_IMAGE" scripts/run_molecule_in_ci_image.sh <<< "$selected"
# A cancelled run can leave its containers running when the docker client is killed. # A cancelled run can leave its containers running when the docker client is killed.
- name: Remove this run's containers - name: Remove this run's containers
@@ -233,36 +178,3 @@ jobs:
for id in $ids; do docker rm -f "$id" >/dev/null || true; done for id in $ids; do docker rm -f "$id" >/dev/null || true; done
left="$(docker ps -aq --filter "label=net.rkdr.mortis.molecule-run=$KAMINO_RUN_ID")" left="$(docker ps -aq --filter "label=net.rkdr.mortis.molecule-run=$KAMINO_RUN_ID")"
if [ -n "$left" ]; then echo "::error::could not remove ${left//$'\n'/ }"; exit 1; fi if [ -n "$left" ]; then echo "::error::could not remove ${left//$'\n'/ }"; exit 1; fi
result:
name: Result
needs: [select, scenarios]
# always(): otherwise a failed select would skip this job, and Gitea counts a skipped job as
# passing. The guard is select's, so a fork pull request skips all three jobs alike and the run
# step below never sees a select skipped by it.
if: >-
always() &&
github.repository == 'mortis/kamino' &&
(github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name == github.repository)
runs-on: kamino-docker
timeout-minutes: 5
# The controller pin again, so this job adds no pin of its own to bump.
container:
image: git.rkdr.net/mortis/molecule-controller:0.1.4@sha256:5658231afaff531161f02aef7a436ed875b1ad6c8d55a8d144e9763c71244420
steps:
- name: Check the select and scenarios jobs
env:
SELECT_RESULT: ${{ needs.select.result }}
SCENARIOS_RESULT: ${{ needs.scenarios.result }}
SELECTED: ${{ needs.select.outputs.scenarios }}
run: |
if [ "$SELECT_RESULT" != success ]; then
echo "::error::select ended as $SELECT_RESULT"; exit 1
fi
# A skip is a pass only for select's `none`: an empty output means it was lost.
if [ "$SCENARIOS_RESULT" = skipped ] && [ "$SELECTED" = none ]; then
echo "No scenario selected."
elif [ "$SCENARIOS_RESULT" != success ]; then
echo "::error::scenarios ended as $SCENARIOS_RESULT"; exit 1
fi
-19
View File
@@ -4,25 +4,6 @@ mortis.kamino Release Notes
.. contents:: Topics .. contents:: Topics
v3.4.0
======
Minor Changes
-------------
- system_baseline - A name in ``system_baseline_sysctl_hardening`` may contain ``*``, which sets the key on every interface.
- system_baseline - New input ``system_baseline_sysctl_file``, the path of the drop-in that persists the sysctl hardening.
Security Fixes
--------------
- system_baseline - Every profile now refuses ICMP redirects on every interface, over IPv4 and IPv6. Before, only ``net.ipv4.conf.all`` was set, so a host that does not forward still accepted them on its interfaces.
Bugfixes
--------
- system_baseline - The sysctl hardening survives a reboot on Debian 13, where ``systemd-sysctl`` no longer reads ``/etc/sysctl.conf``. The role now writes its values to ``/etc/sysctl.d/99-zz-system-baseline.conf`` and removes its keys from ``/etc/sysctl.conf``, so the first run reports ``changed`` once.
v3.3.0 v3.3.0
====== ======
+2 -2
View File
@@ -5,7 +5,7 @@ An Ansible Collection of reusable, hardened roles for a self-hosted home lab:
`nfs_client`, `pihole`, `pve_lxc`, `pve_vm`, `sshd`, `system_baseline`, `systemd_hardening`, `tailscale`, `traefik`, `nfs_client`, `pihole`, `pve_lxc`, `pve_vm`, `sshd`, `system_baseline`, `systemd_hardening`, `tailscale`, `traefik`,
`ufw` and `user_management`, plus the internal `_binary_update`. Roles still to come are listed under [Roadmap](#roadmap). `ufw` and `user_management`, plus the internal `_binary_update`. Roles still to come are listed under [Roadmap](#roadmap).
Status: roles arrive in waves. Release 3.4.0 holds the `cloudflared`, `docker`, `fail2ban`, `gitea`, `gitea_runner`, `network_interfaces`, `nfs_client`, `pihole`, `pve_lxc`, `pve_vm`, `sshd`, `system_baseline`, `systemd_hardening`, `tailscale`, `traefik`, `ufw` and `user_management` roles (and the internal `_binary_update`, which `cloudflared`, `gitea`, `gitea_runner` and `traefik` call). Status: roles arrive in waves. Release 3.3.0 holds the `cloudflared`, `docker`, `fail2ban`, `gitea`, `gitea_runner`, `network_interfaces`, `nfs_client`, `pihole`, `pve_lxc`, `pve_vm`, `sshd`, `system_baseline`, `systemd_hardening`, `tailscale`, `traefik`, `ufw` and `user_management` roles (and the internal `_binary_update`, which `cloudflared`, `gitea`, `gitea_runner` and `traefik` call).
## Consuming ## Consuming
@@ -17,7 +17,7 @@ name (FQCN) only, `mortis.kamino.<role>`:
collections: collections:
- name: https://git.rkdr.net/mortis/kamino.git - name: https://git.rkdr.net/mortis/kamino.git
type: git type: git
version: v3.4.0 version: v3.3.0
``` ```
Its dependencies (`community.general`, `ansible.posix`, `community.proxmox`) are declared in `galaxy.yml`, so Its dependencies (`community.general`, `ansible.posix`, `community.proxmox`) are declared in `galaxy.yml`, so
+1 -1
View File
@@ -93,4 +93,4 @@ plugins:
strategy: {} strategy: {}
test: {} test: {}
vars: {} vars: {}
version: 3.4.0 version: 3.3.0
-23
View File
@@ -576,26 +576,3 @@ releases:
- 482-pve-vm.yml - 482-pve-vm.yml
- system-baseline-internal-registers.yml - system-baseline-internal-registers.yml
release_date: '2026-12-01' release_date: '2026-12-01'
3.4.0:
changes:
bugfixes:
- system_baseline - The sysctl hardening survives a reboot on Debian 13, where
``systemd-sysctl`` no longer reads ``/etc/sysctl.conf``. The role now writes
its values to ``/etc/sysctl.d/99-zz-system-baseline.conf`` and removes its
keys from ``/etc/sysctl.conf``, so the first run reports ``changed`` once.
minor_changes:
- system_baseline - A name in ``system_baseline_sysctl_hardening`` may contain
``*``, which sets the key on every interface.
- system_baseline - New input ``system_baseline_sysctl_file``, the path of the
drop-in that persists the sysctl hardening.
security_fixes:
- system_baseline - Every profile now refuses ICMP redirects on every interface,
over IPv4 and IPv6. Before, only ``net.ipv4.conf.all`` was set, so a host
that does not forward still accepted them on its interfaces.
fragments:
- 505-ufw-check-mode-probe.yml
- 510-system-baseline-sysctl-dropin.yml
- 510-system-baseline-sysctl-file.yml
- 511-system-baseline-icmp-redirects.yml
- 511-system-baseline-sysctl-wildcard.yml
release_date: '2026-12-03'
+4 -4
View File
@@ -56,10 +56,10 @@ Every secret the workflows in [.gitea/workflows/](../../.gitea/workflows/) refer
A checklist, not rules: what the repository and organisation settings should be. The maintainer A checklist, not rules: what the repository and organisation settings should be. The maintainer
applies them and checks them against this list after any change. applies them and checks them against this list after any change.
- Branch protection on `main`: required checks Lint, Build and `Molecule / Result (pull_request)`; - Branch protection on `main`: required checks Lint, Build and Molecule; zero required approvals;
zero required approvals; "Require approval from code owners"; "Dismiss stale approvals"; block "Require approval from code owners"; "Dismiss stale approvals"; block on rejected and on official
on rejected and on official review requests; block on an outdated branch; administrators cannot review requests; block on an outdated branch; administrators cannot override; the approvals
override; the approvals allowlist is the maintainer. allowlist is the maintainer.
- Merge allowlist on `main`: the maintainer, each trusted contributor and the Renovate bot. - Merge allowlist on `main`: the maintainer, each trusted contributor and the Renovate bot.
- Push allowlist on `release/*`: the maintainer; no rule for `renovate/*`. - Push allowlist on `release/*`: the maintainer; no rule for `renovate/*`.
- Tag protection on `v*`, with the maintainer on its allowlist. - Tag protection on `v*`, with the maintainer on its allowlist.
+8 -7
View File
@@ -10,12 +10,13 @@ runs in the [`molecule-controller`](molecule-controller.md) image instead
Ubuntu 26.04 with: Ubuntu 26.04 with:
- **Python tools** in `/opt/venv` (on `PATH`; it runs on Python 3.14, the version of `.python-version`, from the baked copy and not from the distribution's `python3`), from `requirements-dev.lock` (the hashed lock of `requirements-dev.txt`, installed with `pip install --require-hashes`): `ansible-core`, - **Python tools** in `/opt/venv` (on `PATH`; it runs on Python 3.14, the version of `.python-version`, from the baked copy and not from the distribution's `python3`), from `requirements-dev.lock` (the hashed lock of `requirements-dev.txt`, installed with `pip install --require-hashes`): `ansible-core`,
`ansible-lint`, `pre-commit`, `antsibull-changelog`, `galaxy-importer`, `reuse`, `molecule` `ansible-lint`, `pre-commit`, `antsibull-changelog`, `galaxy-importer`, `reuse`, `molecule` and
(without its Docker driver: Lint's "Test the repository scripts" step runs the tests that import it), and `molecule-plugins[docker]` (the Docker driver, with the `docker` Python SDK), and `proxmoxer`, the controller-side
`proxmoxer`, the controller-side library the modules of `community.proxmox` import. library the modules of `community.proxmox` import.
- **The collections the roles call** in `/opt/collections` (`ANSIBLE_COLLECTIONS_PATH` is set to it), from - **The collections the roles call** in `/opt/collections` (`ANSIBLE_COLLECTIONS_PATH` is set to it), from
`requirements.yml`: `community.general`, `ansible.posix` and `community.proxmox` at the exact versions CI tests against, so `requirements.yml`: `community.general`, `ansible.posix` and `community.proxmox` at the exact versions CI tests against, so
`ansible-lint --offline` resolves their modules instead of mocking them. `ansible-lint --offline` resolves their modules instead of mocking them; and from
`extensions/molecule/requirements.yml`, `community.docker`, which the Molecule Docker driver's own playbooks call.
- **Every pre-commit hook environment** of `.pre-commit-config.yaml` in `/opt/pre-commit` - **Every pre-commit hook environment** of `.pre-commit-config.yaml` in `/opt/pre-commit`
(`PRE_COMMIT_HOME`): conventional-pre-commit, gitleaks, yamllint, ruff, shellcheck-py, pre-commit-hooks, actionlint and zizmor. The Go (`PRE_COMMIT_HOME`): conventional-pre-commit, gitleaks, yamllint, ruff, shellcheck-py, pre-commit-hooks, actionlint and zizmor. The Go
hooks are prebuilt; their toolchains, and the binaries of those repositories that no hook runs, are removed to hooks are prebuilt; their toolchains, and the binaries of those repositories that no hook runs, are removed to
@@ -27,7 +28,7 @@ Ubuntu 26.04 with:
`python3`, so sanity runs its compile test for those interpreters instead of skipping it. `python3`, so sanity runs its compile test for those interpreters instead of skipping it.
- `git`, `shellcheck` (actionlint runs it over `run:` blocks), `python3`, `python3-venv` and `ca-certificates`. - `git`, `shellcheck` (actionlint runs it over `run:` blocks), `python3`, `python3-venv` and `ca-certificates`.
The image runs as root and sets no working directory. The image runs as root and sets no working directory.
- `/opt/ci-pins.sha256`: the checksums of the four pin files this image was built from. - `/opt/ci-pins.sha256`: the checksums of the five pin files this image was built from.
It has no Node, so JavaScript actions (`actions/checkout`) cannot run in it: clone with `git`. It has no Node, so JavaScript actions (`actions/checkout`) cannot run in it: clone with `git`.
@@ -60,8 +61,8 @@ jobs:
pre-commit run --all-files --show-diff-on-failure pre-commit run --all-files --show-diff-on-failure
``` ```
`/opt/ci-pins.sha256` lists the four pin files by their checkout-relative path, so `sha256sum -c` runs in the checkout root. When `/opt/ci-pins.sha256` lists the five pin files by their checkout-relative path, so `sha256sum -c` runs in the checkout root. When
the checkout's `requirements-dev.txt`, `requirements-dev.lock`, `requirements.yml` and `.pre-commit-config.yaml` match, the baked tools and the checkout's `requirements-dev.txt`, `requirements-dev.lock`, `requirements.yml`, `extensions/molecule/requirements.yml` and `.pre-commit-config.yaml` match, the baked tools and
collections are used as they are, and Lint and Build cut the network by environment (proxy variables and collections are used as they are, and Lint and Build cut the network by environment (proxy variables and
`PIP_NO_INDEX`) for all but the script tests, so a tool that downloads at run time fails the job. When a pull request changes a pin the check fails and the job installs the pinned `PIP_NO_INDEX`) for all but the script tests, so a tool that downloads at run time fails the job. When a pull request changes a pin the check fails and the job installs the pinned
tools and collections itself for that run tools and collections itself for that run
+1 -1
View File
@@ -33,7 +33,7 @@ checkout). In the checkout root, run `sha256sum --quiet -c /opt/molecule-pins.sh
and collections for that run first (slower, same result), until the image is rebuilt from `main`. and collections for that run first (slower, same result), until the image is rebuilt from `main`.
`.gitea/workflows/molecule.yml` is its consumer: it pins the image as `CONTROLLER_IMAGE`, and `.gitea/workflows/molecule.yml` is its consumer: it pins the image as `CONTROLLER_IMAGE`, and
`scripts/run_molecule_in_controller.sh` runs the pin check inside it. Read the workflow for the full command. `scripts/run_molecule_in_ci_image.sh` runs the pin check inside it. Read the workflow for the full command.
## Tags and pinning ## Tags and pinning
+1 -2
View File
@@ -7,8 +7,7 @@ It is the release the hosts run today.
## What is in it ## What is in it
- Ubuntu 24.04 (the official `ubuntu:24.04` image, pinned by digest in the Dockerfile, with its packages - Ubuntu 24.04 (the official `ubuntu:24.04` image, pinned by digest in the Dockerfile).
upgraded when the image is built).
- systemd as the init system (`systemd`, `systemd-sysv`), D-Bus, `sudo`, `iproute2`, - systemd as the init system (`systemd`, `systemd-sysv`), D-Bus, `sudo`, `iproute2`,
`ca-certificates`. `ca-certificates`.
- Python for Ansible on the target: `python3`, `python3-apt`, `python3-systemd`. - Python for Ansible on the target: `python3`, `python3-apt`, `python3-systemd`.
+1 -2
View File
@@ -7,8 +7,7 @@ It is the release the hosts are moving to; every role scenario whose role declar
## What is in it ## What is in it
- Ubuntu 26.04 (the official `ubuntu:26.04` image, pinned by digest in the Dockerfile, with its packages - Ubuntu 26.04 (the official `ubuntu:26.04` image, pinned by digest in the Dockerfile).
upgraded when the image is built).
- systemd as the init system (`systemd`, `systemd-sysv`), D-Bus, `sudo`, `iproute2`, - systemd as the init system (`systemd`, `systemd-sysv`), D-Bus, `sudo`, `iproute2`,
`ca-certificates`. `ca-certificates`.
- Python for Ansible on the target: `python3`, `python3-apt`, `python3-systemd`. - Python for Ansible on the target: `python3`, `python3-apt`, `python3-systemd`.
+2 -2
View File
@@ -2,8 +2,8 @@
# Collections the Molecule test harness itself calls, as opposed to the roles under test (those are # Collections the Molecule test harness itself calls, as opposed to the roles under test (those are
# in the requirements.yml at the repository root). The Docker driver of molecule-plugins runs # in the requirements.yml at the repository root). The Docker driver of molecule-plugins runs
# community.docker modules in its own create and destroy playbooks, so every scenario needs it. # community.docker modules in its own create and destroy playbooks, so every scenario needs it.
# The molecule-controller image (images/molecule-controller) bakes it into /opt/collections next to the # The ci image (images/ci) bakes it into /opt/collections next to the root one; a pull request that
# root one; a pull request that changes it fails the image's pin check, so the Molecule job installs it itself. # changes it fails the image's pin check, so the Molecule job installs it itself.
# Renovate (renovate.json, ansible-galaxy manager) bumps this pin. # Renovate (renovate.json, ansible-galaxy manager) bumps this pin.
collections: collections:
- name: community.docker - name: community.docker
+1 -1
View File
@@ -1,7 +1,7 @@
--- ---
namespace: mortis namespace: mortis
name: kamino name: kamino
version: 3.4.0 version: 3.3.0
readme: README.md readme: README.md
authors: authors:
- Defame1297 - Defame1297
-2
View File
@@ -65,8 +65,6 @@ it to this repository's organisation in the Gitea registry as `<version>` and `l
the fast path Lint and Build cut the network by environment, so a download through pip or a the fast path Lint and Build cut the network by environment, so a download through pip or a
proxy-honouring client fails the job; review for a raw socket, for the script tests, which keep proxy-honouring client fails the job; review for a raw socket, for the script tests, which keep
network, and for Molecule. network, and for Molecule.
- **Each Dockerfile upgrades the base image's packages in its first apt layer.** *Why:* Ubuntu
publishes package updates before it refreshes the base image. *Held:* review.
- **Recorded speed:** a speed optimisation that adds machinery states its measured saving where - **Recorded speed:** a speed optimisation that adds machinery states its measured saving where
it lives (a comment next to it). *Why:* machinery is kept only for a saving someone can check. it lives (a comment next to it). *Why:* machinery is kept only for a saving someone can check.
*Held:* review. *Held:* review.
+20 -16
View File
@@ -13,13 +13,12 @@
# - OS packages: git, shellcheck (actionlint runs it over run: blocks), the # - OS packages: git, shellcheck (actionlint runs it over run: blocks), the
# distribution's python3 and ca-certificates. # distribution's python3 and ca-certificates.
# - /opt/venv: requirements-dev.lock, the hashed lock of requirements-dev.txt (ansible-core, ansible-lint, pre-commit, # - /opt/venv: requirements-dev.lock, the hashed lock of requirements-dev.txt (ansible-core, ansible-lint, pre-commit,
# antsibull-changelog, galaxy-importer, reuse, molecule, proxmoxer), on the Python of # antsibull-changelog, galaxy-importer, reuse, molecule and its Docker driver, proxmoxer), on the Python of
# .python-version (PYTHON_VERSION below), the one the lock was resolved on and a clone's .venv uses. # .python-version (PYTHON_VERSION below), the one the lock was resolved on and a clone's .venv uses.
# molecule is there for Lint's "Test the repository scripts" step, whose molecule tests import it; its
# Docker driver and community.docker are not: Molecule runs in the molecule-controller image.
# - /opt/collections: the collections of requirements.yml (the versions the roles are # - /opt/collections: the collections of requirements.yml (the versions the roles are
# tested against), found through ANSIBLE_COLLECTIONS_PATH, so `ansible-lint --offline` # tested against), found through ANSIBLE_COLLECTIONS_PATH, so `ansible-lint --offline`
# resolves their modules without a mock list. # resolves their modules without a mock list; and those of extensions/molecule/requirements.yml
# (community.docker), which the Molecule Docker driver's own playbooks call.
# - /opt/pre-commit: every hook environment of .pre-commit-config.yaml, installed by # - /opt/pre-commit: every hook environment of .pre-commit-config.yaml, installed by
# `pre-commit install-hooks` (gitleaks and actionlint are built from source by # `pre-commit install-hooks` (gitleaks and actionlint are built from source by
# pre-commit, which downloads a Go toolchain: that is most of the time saved). # pre-commit, which downloads a Go toolchain: that is most of the time saved).
@@ -28,8 +27,8 @@
# - Python 3.11, 3.13 and PYTHON_VERSION as python<MINOR> on PATH, so that # - Python 3.11, 3.13 and PYTHON_VERSION as python<MINOR> on PATH, so that
# `ansible-test sanity` runs its compile test for them instead of skipping it. # `ansible-test sanity` runs its compile test for them instead of skipping it.
# They come from python-build-standalone through uv, pinned by the uv version. # They come from python-build-standalone through uv, pinned by the uv version.
# - /opt/ci-pins.sha256: the checksums of requirements-dev.txt, requirements-dev.lock, requirements.yml # - /opt/ci-pins.sha256: the checksums of requirements-dev.txt, requirements-dev.lock, requirements.yml,
# and .pre-commit-config.yaml this image was built from. A job runs # extensions/molecule/requirements.yml and .pre-commit-config.yaml this image was built from. A job runs
# `sha256sum -c /opt/ci-pins.sha256` in its checkout; when a pull request changes a # `sha256sum -c /opt/ci-pins.sha256` in its checkout; when a pull request changes a
# pin the check fails and the job installs the tools as before, until the image # pin the check fails and the job installs the tools as before, until the image
# is rebuilt from main. # is rebuilt from main.
@@ -37,16 +36,15 @@
# Layers: each COPY / RUN below is one layer, and a layer is pushed as one request, # Layers: each COPY / RUN below is one layer, and a layer is pushed as one request,
# so it must stay below Cloudflare's 100 MB request-body limit on git.rkdr.net. The # so it must stay below Cloudflare's 100 MB request-body limit on git.rkdr.net. The
# build stage prints the sizes it will copy; the first push is the real test. # build stage prints the sizes it will copy; the first push is the real test.
# Base image: ubuntu:26.04 index digest as of 2026-12-03, same as molecule-ubuntu2604. # Base image: ubuntu:26.04 index digest as of 2026-10-26, same as molecule-ubuntu2604.
FROM ubuntu:26.04@sha256:a8417def3fc37c2d8cf513fe69ef871d415a45a27847779fae461c5047710edd AS os FROM ubuntu:26.04@sha256:d66b366dac61b575bee2aef07e9c26e8070096fbe84a3d4d3eb0da069b5d76db AS os
ENV DEBIAN_FRONTEND=noninteractive ENV DEBIAN_FRONTEND=noninteractive
# No python3-pip: tools are installed with the venv's own pip. python3-venv brings # No python3-pip: tools are installed with the venv's own pip. python3-venv brings
# ensurepip. The upgrade brings in updates newer than the base image. apt lists are removed in the same layer. # ensurepip. apt lists are removed in the same layer.
RUN apt-get update \ RUN apt-get update \
&& apt-get upgrade -y --with-new-pkgs --no-install-recommends \
&& apt-get install -y --no-install-recommends \ && apt-get install -y --no-install-recommends \
ca-certificates git python3 python3-venv shellcheck \ ca-certificates git python3 python3-venv shellcheck \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
@@ -68,6 +66,8 @@ ENV PIP_DISABLE_PIP_VERSION_CHECK=1 \
WORKDIR /src WORKDIR /src
COPY requirements-dev.txt requirements-dev.lock requirements.yml .pre-commit-config.yaml ./ COPY requirements-dev.txt requirements-dev.lock requirements.yml .pre-commit-config.yaml ./
# Kept at its checkout path: its name matches the root requirements.yml.
COPY extensions/molecule/requirements.yml extensions/molecule/
# The interpreters come first: /opt/venv is built from the pinned one (PYTHON_VERSION, kept equal to # The interpreters come first: /opt/venv is built from the pinned one (PYTHON_VERSION, kept equal to
# .python-version and to the lock header by `check_image_versions.py pins`), not from the distribution's # .python-version and to the lock header by `check_image_versions.py pins`), not from the distribution's
@@ -75,7 +75,7 @@ COPY requirements-dev.txt requirements-dev.lock requirements.yml .pre-commit-con
# uv only lives in the build stage (its own venv): the final image keeps the interpreters it # uv only lives in the build stage (its own venv): the final image keeps the interpreters it
# downloaded, not the installer. The distribution's python3 only bootstraps uv. # downloaded, not the installer. The distribution's python3 only bootstraps uv.
RUN python3 -m venv /opt/uv-venv \ RUN python3 -m venv /opt/uv-venv \
&& /opt/uv-venv/bin/pip install uv==0.13.10 \ && /opt/uv-venv/bin/pip install uv==0.13.9 \
&& /opt/uv-venv/bin/uv python install 3.11 3.13 ${PYTHON_VERSION} && /opt/uv-venv/bin/uv python install 3.11 3.13 ${PYTHON_VERSION}
# python-build-standalone ships lib/libpython<MINOR>.so (about 33 MB, 10 MB compressed) next to a statically # python-build-standalone ships lib/libpython<MINOR>.so (about 33 MB, 10 MB compressed) next to a statically
@@ -99,11 +99,13 @@ RUN "$(echo /opt/python/cpython-${PYTHON_VERSION}.*/bin/python${PYTHON_VERSION})
&& /opt/venv/bin/python --version \ && /opt/venv/bin/python --version \
&& /opt/venv/bin/pip install --require-hashes -r requirements-dev.lock -r requirements-dev.txt && /opt/venv/bin/pip install --require-hashes -r requirements-dev.lock -r requirements-dev.txt
# The collections of requirements.yml. ANSIBLE_COLLECTIONS_PATH is set to the target for the # The collections of requirements.yml and extensions/molecule/requirements.yml. ANSIBLE_COLLECTIONS_PATH is set to the target for the
# install only: a collection found anywhere else on the path would be skipped as "already # install only: a collection found anywhere else on the path would be skipped as "already
# installed" and not copied here. # installed" and not copied here.
RUN ANSIBLE_COLLECTIONS_PATH=/opt/collections \ RUN ANSIBLE_COLLECTIONS_PATH=/opt/collections \
/opt/venv/bin/ansible-galaxy collection install -r requirements.yml -p /opt/collections \ /opt/venv/bin/ansible-galaxy collection install -r requirements.yml -p /opt/collections \
&& ANSIBLE_COLLECTIONS_PATH=/opt/collections \
/opt/venv/bin/ansible-galaxy collection install -r extensions/molecule/requirements.yml -p /opt/collections \
&& du -sh /opt/collections && du -sh /opt/collections
# pre-commit needs a git repository to resolve a config. The hook repositories are # pre-commit needs a git repository to resolve a config. The hook repositories are
@@ -176,7 +178,7 @@ FROM os AS final
ARG PYTHON_VERSION=3.14 ARG PYTHON_VERSION=3.14
LABEL org.opencontainers.image.title="ci" \ LABEL org.opencontainers.image.title="ci" \
org.opencontainers.image.description="CI tooling image for the mortis.kamino Ansible Collection: the Lint and Build workflows run in it, so a job only checks out the code and runs; Molecule runs in the molecule-controller image. It bakes in ansible-core, ansible-lint, pre-commit with every hook environment of the repository, antsibull-changelog, galaxy-importer, reuse, molecule (for the script tests), proxmoxer, the collections of requirements.yml, git, shellcheck, Python 3.11, 3.13 and the version of .python-version (the tools in /opt/venv run on it) next to the distribution python3 and primed ansible-test sanity virtualenvs. Pin it by tag and digest, as a job container or with docker run; it has no Node, so clone with git." \ org.opencontainers.image.description="CI tooling image for the mortis.kamino Ansible Collection: the Lint and Build workflows run in it, so a job only checks out the code and runs; Molecule runs in the molecule-controller image. It bakes in ansible-core, ansible-lint, pre-commit with every hook environment of the repository, antsibull-changelog, galaxy-importer, reuse, molecule with its Docker driver, proxmoxer, the collections of requirements.yml and extensions/molecule/requirements.yml, git, shellcheck, Python 3.11, 3.13 and the version of .python-version (the tools in /opt/venv run on it) next to the distribution python3 and primed ansible-test sanity virtualenvs. Pin it by tag and digest, as a job container or with docker run; it has no Node, so clone with git." \
org.opencontainers.image.source="https://git.rkdr.net/mortis/kamino" \ org.opencontainers.image.source="https://git.rkdr.net/mortis/kamino" \
org.opencontainers.image.url="https://git.rkdr.net/mortis/kamino" \ org.opencontainers.image.url="https://git.rkdr.net/mortis/kamino" \
org.opencontainers.image.documentation="https://git.rkdr.net/mortis/kamino/src/branch/main/docs/images/ci.md" \ org.opencontainers.image.documentation="https://git.rkdr.net/mortis/kamino/src/branch/main/docs/images/ci.md" \
@@ -184,7 +186,7 @@ LABEL org.opencontainers.image.title="ci" \
org.opencontainers.image.authors="Defame1297 and contributors" \ org.opencontainers.image.authors="Defame1297 and contributors" \
org.opencontainers.image.base.name="ubuntu:26.04" \ org.opencontainers.image.base.name="ubuntu:26.04" \
net.rkdr.mortis.purpose="CI tooling image for the mortis.kamino Ansible Collection: the Lint and Build workflows run in it, so a job only checks out the code and runs." \ net.rkdr.mortis.purpose="CI tooling image for the mortis.kamino Ansible Collection: the Lint and Build workflows run in it, so a job only checks out the code and runs." \
net.rkdr.mortis.contents="Ubuntu 26.04, /opt/venv (ansible-core, ansible-lint, pre-commit, antsibull-changelog, galaxy-importer, reuse, molecule, proxmoxer), /opt/collections (community.general, ansible.posix, community.proxmox), /opt/pre-commit hook environments, ansible-test sanity venvs, python3 (distribution), python3.11, python3.13, python<PYTHON_VERSION> (the one of /opt/venv), git, shellcheck, /opt/ci-pins.sha256" \ net.rkdr.mortis.contents="Ubuntu 26.04, /opt/venv (ansible-core, ansible-lint, pre-commit, antsibull-changelog, galaxy-importer, reuse, molecule, molecule-plugins[docker], proxmoxer), /opt/collections (community.general, ansible.posix, community.proxmox, community.docker), /opt/pre-commit hook environments, ansible-test sanity venvs, python3 (distribution), python3.11, python3.13, python<PYTHON_VERSION> (the one of /opt/venv), git, shellcheck, /opt/ci-pins.sha256" \
net.rkdr.mortis.usage="Lint and Build: job container on the kamino-docker runner, git.rkdr.net/mortis/ci:version@sha256:digest with PRE_COMMIT_HOME set to /opt/pre-commit. Run sha256sum -c /opt/ci-pins.sha256 in the checkout root and install the pinned tools and collections when a pull request changed them, else use /opt/venv/bin and ANSIBLE_COLLECTIONS_PATH=/opt/collections. See the documentation label." net.rkdr.mortis.usage="Lint and Build: job container on the kamino-docker runner, git.rkdr.net/mortis/ci:version@sha256:digest with PRE_COMMIT_HOME set to /opt/pre-commit. Run sha256sum -c /opt/ci-pins.sha256 in the checkout root and install the pinned tools and collections when a pull request changed them, else use /opt/venv/bin and ANSIBLE_COLLECTIONS_PATH=/opt/collections. See the documentation label."
ENV PIP_DISABLE_PIP_VERSION_CHECK=1 \ ENV PIP_DISABLE_PIP_VERSION_CHECK=1 \
@@ -201,14 +203,16 @@ COPY --from=build /root/.ansible/test /root/.ansible/test
# The target interpreters ansible-test looks for on PATH, and the pin record. # The target interpreters ansible-test looks for on PATH, and the pin record.
COPY --from=build /src/requirements-dev.txt /src/requirements-dev.lock /src/requirements.yml /src/.pre-commit-config.yaml /opt/ci-pins/ COPY --from=build /src/requirements-dev.txt /src/requirements-dev.lock /src/requirements.yml /src/.pre-commit-config.yaml /opt/ci-pins/
# Under its checkout path, so `sha256sum -c` in a checkout root finds it.
COPY --from=build /src/extensions/molecule/requirements.yml /opt/ci-pins/extensions/molecule/
RUN set -eu; \ RUN set -eu; \
for v in $(printf '%s\n' 3.11 3.13 "${PYTHON_VERSION}" | sort -u); do \ for v in $(printf '%s\n' 3.11 3.13 "${PYTHON_VERSION}" | sort -u); do \
ln -sf "$(echo /opt/python/cpython-${v}.*/bin/python${v})" "/usr/local/bin/python${v}"; \ ln -sf "$(echo /opt/python/cpython-${v}.*/bin/python${v})" "/usr/local/bin/python${v}"; \
"python${v}" --version; \ "python${v}" --version; \
done; \ done; \
cd /opt/ci-pins; \ cd /opt/ci-pins; \
sha256sum requirements-dev.txt requirements-dev.lock requirements.yml .pre-commit-config.yaml \ sha256sum requirements-dev.txt requirements-dev.lock requirements.yml extensions/molecule/requirements.yml \
> /opt/ci-pins.sha256; \ .pre-commit-config.yaml > /opt/ci-pins.sha256; \
ansible --version | head -n1; \ ansible --version | head -n1; \
ansible-galaxy collection list; \ ansible-galaxy collection list; \
pre-commit --version; \ pre-commit --version; \
+3 -4
View File
@@ -24,15 +24,14 @@
# stay below Cloudflare's 100 MB request-body limit on git.rkdr.net. The build stage prints the # stay below Cloudflare's 100 MB request-body limit on git.rkdr.net. The build stage prints the
# compressed size of each directory it copies. # compressed size of each directory it copies.
FROM ubuntu:26.04@sha256:a8417def3fc37c2d8cf513fe69ef871d415a45a27847779fae461c5047710edd AS os FROM ubuntu:26.04@sha256:d66b366dac61b575bee2aef07e9c26e8070096fbe84a3d4d3eb0da069b5d76db AS os
ENV DEBIAN_FRONTEND=noninteractive ENV DEBIAN_FRONTEND=noninteractive
# python3 and python3-venv only bootstrap uv in the build stage; ca-certificates serve the # python3 and python3-venv only bootstrap uv in the build stage; ca-certificates serve the
# install a job runs when a pull request changes a pin; git lets the selector diff the checkout. # install a job runs when a pull request changes a pin; git lets the selector diff the checkout.
# The upgrade brings in updates newer than the base image. apt lists are removed in the same layer. # apt lists are removed in the same layer.
RUN apt-get update \ RUN apt-get update \
&& apt-get upgrade -y --with-new-pkgs --no-install-recommends \
&& apt-get install -y --no-install-recommends ca-certificates git python3 python3-venv \ && apt-get install -y --no-install-recommends ca-certificates git python3 python3-venv \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
@@ -57,7 +56,7 @@ COPY extensions/molecule/requirements.yml extensions/molecule/
# removed when the binary does not link it (about 10 MB compressed nothing here loads), as in ci. # removed when the binary does not link it (about 10 MB compressed nothing here loads), as in ci.
RUN set -eu; \ RUN set -eu; \
python3 -m venv /opt/uv-venv; \ python3 -m venv /opt/uv-venv; \
/opt/uv-venv/bin/pip install uv==0.13.10; \ /opt/uv-venv/bin/pip install uv==0.13.9; \
/opt/uv-venv/bin/uv python install "${PYTHON_VERSION}"; \ /opt/uv-venv/bin/uv python install "${PYTHON_VERSION}"; \
d="$(echo /opt/python/cpython-${PYTHON_VERSION}.*/)"; \ d="$(echo /opt/python/cpython-${PYTHON_VERSION}.*/)"; \
if ldd "${d}bin/python${PYTHON_VERSION}" | grep -q libpython; then \ if ldd "${d}bin/python${PYTHON_VERSION}" | grep -q libpython; then \
+3 -6
View File
@@ -17,16 +17,15 @@
# One RUN layer: at most about 30 MB compressed on top of the 29.8 MB base (estimated from # One RUN layer: at most about 30 MB compressed on top of the 29.8 MB base (estimated from
# the real .debs, with the .pyc files the postinst scripts compile), far below # the real .debs, with the .pyc files the postinst scripts compile), far below
# Cloudflare's 100 MB request-body limit on git.rkdr.net (kaniko pushes a layer as # Cloudflare's 100 MB request-body limit on git.rkdr.net (kaniko pushes a layer as
# one request; gnupg adds a few MB, not measured, and the upgraded base packages about 4 MB). # one request; gnupg adds a few MB, not measured). apt packages are not version-pinned, as in the original image; the
# apt packages are not version-pinned, as in the original image; the
# base image is pinned by digest and a rebuild is a reviewed digest bump downstream. # base image is pinned by digest and a rebuild is a reviewed digest bump downstream.
# #
# The image carries SSH host keys and a machine-id generated at build time (the # The image carries SSH host keys and a machine-id generated at build time (the
# openssh-server and systemd postinst scripts). ssh.service runs `sshd -t` and # openssh-server and systemd postinst scripts). ssh.service runs `sshd -t` and
# fails without host keys, so they cannot be removed; image scanners will flag them. # fails without host keys, so they cannot be removed; image scanners will flag them.
# They are throwaway keys of a test target that is never exposed. # They are throwaway keys of a test target that is never exposed.
# ubuntu:24.04 index digest as of 2026-12-03. # ubuntu:24.04 index digest as of 2026-10-24 (24.04.5).
FROM ubuntu:24.04@sha256:168a88cc61bdd95c8f871e3903d4e0a525e340c2b28a70dadd6d1503ecc7c391 FROM ubuntu:24.04@sha256:562111b88caa79c71391c0c4d3c2114a7d5c35915c20561fd893cb1e07929e6b
LABEL org.opencontainers.image.title="molecule-ubuntu2404" \ LABEL org.opencontainers.image.title="molecule-ubuntu2404" \
org.opencontainers.image.description="Disposable Ubuntu 24.04 test target for the molecule scenarios of the mortis.kamino Ansible Collection. systemd runs as PID 1 with D-Bus, sudo, python3 and the test fixtures (iptables, openssh-server, gnupg) preinstalled. A package a role installs is not baked in and no APT lists are kept, so a scenario refreshes the APT cache before a role installs one. Start it as a molecule platform (usage label); it carries throwaway SSH host keys and is a test target only, never to be exposed." \ org.opencontainers.image.description="Disposable Ubuntu 24.04 test target for the molecule scenarios of the mortis.kamino Ansible Collection. systemd runs as PID 1 with D-Bus, sudo, python3 and the test fixtures (iptables, openssh-server, gnupg) preinstalled. A package a role installs is not baked in and no APT lists are kept, so a scenario refreshes the APT cache before a role installs one. Start it as a molecule platform (usage label); it carries throwaway SSH host keys and is a test target only, never to be exposed." \
@@ -42,13 +41,11 @@ LABEL org.opencontainers.image.title="molecule-ubuntu2404" \
ENV DEBIAN_FRONTEND=noninteractive ENV DEBIAN_FRONTEND=noninteractive
# The upgrade brings in updates newer than the base image.
# systemd as PID 1 with D-Bus, sudo and networking tools; the Python Ansible needs on # systemd as PID 1 with D-Bus, sudo and networking tools; the Python Ansible needs on
# the target (python3-apt for the apt module, python3-systemd for the journal); iptables; # the target (python3-apt for the apt module, python3-systemd for the journal); iptables;
# sshd, enabled so a converge can test it under systemd; gnupg, which the docker scenario # sshd, enabled so a converge can test it under systemd; gnupg, which the docker scenario
# signs its stand-in APT repository with. ufw and fail2ban are left out: their roles install them. # signs its stand-in APT repository with. ufw and fail2ban are left out: their roles install them.
RUN apt-get update \ RUN apt-get update \
&& apt-get upgrade -y --with-new-pkgs --no-install-recommends \
&& apt-get install -y --no-install-recommends \ && apt-get install -y --no-install-recommends \
systemd systemd-sysv dbus sudo iproute2 ca-certificates \ systemd systemd-sysv dbus sudo iproute2 ca-certificates \
python3 python3-apt python3-systemd \ python3 python3-apt python3-systemd \
+3 -6
View File
@@ -17,16 +17,15 @@
# One RUN layer: at most about 30 MB compressed on top of the 29.8 MB base (estimated from # One RUN layer: at most about 30 MB compressed on top of the 29.8 MB base (estimated from
# the real .debs, with the .pyc files the postinst scripts compile), far below # the real .debs, with the .pyc files the postinst scripts compile), far below
# Cloudflare's 100 MB request-body limit on git.rkdr.net (kaniko pushes a layer as # Cloudflare's 100 MB request-body limit on git.rkdr.net (kaniko pushes a layer as
# one request; gnupg adds a few MB, not measured, and the upgraded base packages about 4 MB). # one request; gnupg adds a few MB, not measured). apt packages are not version-pinned, as in the original image; the
# apt packages are not version-pinned, as in the original image; the
# base image is pinned by digest and a rebuild is a reviewed digest bump downstream. # base image is pinned by digest and a rebuild is a reviewed digest bump downstream.
# #
# The image carries SSH host keys and a machine-id generated at build time (the # The image carries SSH host keys and a machine-id generated at build time (the
# openssh-server and systemd postinst scripts). ssh.service runs `sshd -t` and # openssh-server and systemd postinst scripts). ssh.service runs `sshd -t` and
# fails without host keys, so they cannot be removed; image scanners will flag them. # fails without host keys, so they cannot be removed; image scanners will flag them.
# They are throwaway keys of a test target that is never exposed. # They are throwaway keys of a test target that is never exposed.
# ubuntu:26.04 index digest as of 2026-12-03. # ubuntu:26.04 index digest as of 2026-10-26.
FROM ubuntu:26.04@sha256:a8417def3fc37c2d8cf513fe69ef871d415a45a27847779fae461c5047710edd FROM ubuntu:26.04@sha256:d66b366dac61b575bee2aef07e9c26e8070096fbe84a3d4d3eb0da069b5d76db
LABEL org.opencontainers.image.title="molecule-ubuntu2604" \ LABEL org.opencontainers.image.title="molecule-ubuntu2604" \
org.opencontainers.image.description="Disposable Ubuntu 26.04 test target for the molecule scenarios of the mortis.kamino Ansible Collection. systemd runs as PID 1 with D-Bus, sudo, python3 and the test fixtures (iptables, openssh-server, gnupg) preinstalled. A package a role installs is not baked in and no APT lists are kept, so a scenario refreshes the APT cache before a role installs one. Start it as a molecule platform (usage label); it carries throwaway SSH host keys and is a test target only, never to be exposed." \ org.opencontainers.image.description="Disposable Ubuntu 26.04 test target for the molecule scenarios of the mortis.kamino Ansible Collection. systemd runs as PID 1 with D-Bus, sudo, python3 and the test fixtures (iptables, openssh-server, gnupg) preinstalled. A package a role installs is not baked in and no APT lists are kept, so a scenario refreshes the APT cache before a role installs one. Start it as a molecule platform (usage label); it carries throwaway SSH host keys and is a test target only, never to be exposed." \
@@ -42,7 +41,6 @@ LABEL org.opencontainers.image.title="molecule-ubuntu2604" \
ENV DEBIAN_FRONTEND=noninteractive ENV DEBIAN_FRONTEND=noninteractive
# The upgrade brings in updates newer than the base image.
# systemd as PID 1 with D-Bus, sudo and networking tools; the Python Ansible needs on # systemd as PID 1 with D-Bus, sudo and networking tools; the Python Ansible needs on
# the target (python3-apt for the apt module, python3-systemd for the journal); iptables; # the target (python3-apt for the apt module, python3-systemd for the journal); iptables;
# sshd, enabled so a converge can test it under systemd; gnupg, which the docker scenario # sshd, enabled so a converge can test it under systemd; gnupg, which the docker scenario
@@ -50,7 +48,6 @@ ENV DEBIAN_FRONTEND=noninteractive
# root's sudo (Ansible's become here) skips pam_unix's account check, whose unix_chkpwd # root's sudo (Ansible's become here) skips pam_unix's account check, whose unix_chkpwd
# helper fails inside the container; non-root callers still go through pam_unix. # helper fails inside the container; non-root callers still go through pam_unix.
RUN apt-get update \ RUN apt-get update \
&& apt-get upgrade -y --with-new-pkgs --no-install-recommends \
&& apt-get install -y --no-install-recommends \ && apt-get install -y --no-install-recommends \
systemd systemd-sysv dbus sudo iproute2 ca-certificates \ systemd systemd-sysv dbus sudo iproute2 ca-certificates \
python3 python3-apt python3-systemd \ python3 python3-apt python3-systemd \
+59 -40
View File
@@ -193,9 +193,9 @@ ansible-builder==3.2.0 \
--hash=sha256:8cd8639011127aaa5046fd60e56ae753eb599061bf493eca2c6b75c54cfc6212 \ --hash=sha256:8cd8639011127aaa5046fd60e56ae753eb599061bf493eca2c6b75c54cfc6212 \
--hash=sha256:9cb948dbd221bdf6d0d48e80fa1575ca5f4336a569c05f510e2d406f01897673 --hash=sha256:9cb948dbd221bdf6d0d48e80fa1575ca5f4336a569c05f510e2d406f01897673
# via galaxy-importer # via galaxy-importer
ansible-compat==26.11.1 \ ansible-compat==26.11.0 \
--hash=sha256:d22e0a48d8d79e727b0f56db3573b02bde2189b5bfbef067230a34c0bcbff94a \ --hash=sha256:35cbe829e0b5a9acb85d34b8d5da2eb45acaf767f6651f90e0ab2f3a96a060bb \
--hash=sha256:ed9717fde1705a58678c1503e46316a36f7392229c2444d2b2f1b6de12be9f25 --hash=sha256:c06a486b39ced440f9f6fb9a99583c73d9239c94ece822a27ea2242173462dda
# via # via
# ansible-lint # ansible-lint
# molecule # molecule
@@ -240,9 +240,9 @@ anyio==4.16.0 \
# via # via
# httpx2 # httpx2
# openai # openai
apm-cli==0.39.1 \ apm-cli==0.38.1 \
--hash=sha256:af1636869ee0217129549f16d8ac9e645c77af5a6d4fbfc9dbd08e47bdefd0da \ --hash=sha256:c2a0394643e54d3516efefcd78bb043509ac48b65cca1f40166023789b8eb89a \
--hash=sha256:b569fea62e19504a8d5fd4983f765241eacebd4d7f64465c105b755450b67b96 --hash=sha256:c2ddd1ea95f7223de2ced83c1bbb61b756a10de2651edc76b93346c925dc162b
# via -r requirements-dev.txt # via -r requirements-dev.txt
attrs==23.2.0 \ attrs==23.2.0 \
--hash=sha256:935dc3b529c262f6cf76e50877d35a4bd3c1de194fd41f47a2b7ae8f19971f30 \ --hash=sha256:935dc3b529c262f6cf76e50877d35a4bd3c1de194fd41f47a2b7ae8f19971f30 \
@@ -687,6 +687,11 @@ distro==1.9.0 \
# via # via
# ansible-lint # ansible-lint
# bindep # bindep
# selinux
docker==7.2.0 \
--hash=sha256:a3f45fdeb9165e2d25d9a1d02ddf3bc70fb572cf5ebbf9b58558c22caf29b71f \
--hash=sha256:cebb93773d334f778e023a7ee352a8d6e13ab1bd3b863a4d4a59dec897df43ac
# via molecule-plugins
docutils==0.23 \ docutils==0.23 \
--hash=sha256:25d013af9bf23bc1c7b2b093dff4208166c53a94786c9e447808335ef1185fea \ --hash=sha256:25d013af9bf23bc1c7b2b093dff4208166c53a94786c9e447808335ef1185fea \
--hash=sha256:746f5060322511280a1e50eb76846ed6bf2342984b2ac04dc42caa1a8d78799e --hash=sha256:746f5060322511280a1e50eb76846ed6bf2342984b2ac04dc42caa1a8d78799e
@@ -698,9 +703,9 @@ enrich==1.2.7 \
--hash=sha256:0a2ab0d2931dff8947012602d1234d2a3ee002d9a355b5d70be6bf5466008893 \ --hash=sha256:0a2ab0d2931dff8947012602d1234d2a3ee002d9a355b5d70be6bf5466008893 \
--hash=sha256:f29b2c8c124b4dbd7c975ab5c3568f6c7a47938ea3b7d2106c8a3bd346545e4f --hash=sha256:f29b2c8c124b4dbd7c975ab5c3568f6c7a47938ea3b7d2106c8a3bd346545e4f
# via molecule # via molecule
filelock==4.3.2 \ filelock==4.3.0 \
--hash=sha256:02a8801bc6b2a80921bf3d7895c63084d53bae2a3c86783adce5ae2b89a1825b \ --hash=sha256:143407310acf479e82d88068e3b9a6486f45fb410c0ed8729fe7359eaabeb6f1 \
--hash=sha256:4f0a21c70447782453c06bb20a9863ee385ead1abaef22049af79289496851b3 --hash=sha256:f933f39f7e01249a4a49b9abab30edc6d4b874624c3de5dd0b0d137aa8adb979
# via # via
# ansible-lint # ansible-lint
# apm-cli # apm-cli
@@ -844,9 +849,9 @@ frozenlist==1.8.0 \
# via # via
# aiohttp # aiohttp
# aiosignal # aiosignal
galaxy-importer==0.4.45 \ galaxy-importer==0.4.44 \
--hash=sha256:189204ab6ca8d4f1619ac8eae7bb9867088a48fc31ba13cf0d4b10ff4f4ad857 \ --hash=sha256:6c024fed7689f854bc8131d613a677f5929e34b01e2c9d63ac63ec69ae37004c \
--hash=sha256:ec9d77f95d8e700ad0792fff0fc909e395af963dbd8aa862b1ab30c8bff6f53e --hash=sha256:c2261e6480cb71c445228233f2de906ef96fa5dc55b138a85e5e5a7c30902de7
# via -r requirements-dev.txt # via -r requirements-dev.txt
gitdb==4.0.12 \ gitdb==4.0.12 \
--hash=sha256:5ef71f855d191a3326fcfbc0d5da835f26b13fbcba60c32c21091c349ffdb571 \ --hash=sha256:5ef71f855d191a3326fcfbc0d5da835f26b13fbcba60c32c21091c349ffdb571 \
@@ -1030,9 +1035,9 @@ llm-github-models==0.18.0 \
--hash=sha256:b0b702c563b6c2f581a707e9b809017c38f094a4d4fffc066e0b56bf209eb281 \ --hash=sha256:b0b702c563b6c2f581a707e9b809017c38f094a4d4fffc066e0b56bf209eb281 \
--hash=sha256:b778aa6fa43e53ecb3b868fcf9875bc0e760a774a1fad76ea907a269582a2043 --hash=sha256:b778aa6fa43e53ecb3b868fcf9875bc0e760a774a1fad76ea907a269582a2043
# via apm-cli # via apm-cli
markdown==3.11.4 \ markdown==3.11.3 \
--hash=sha256:2e30b19cead1968f391206e184ca67dfe6805c2eb8f383fb07b4dc90f8288075 \ --hash=sha256:81eb91631dc97ad1efbc76019ef0f80fe90ca49ddf81546752d79989c3bfff3e \
--hash=sha256:c911a757f33d64a2578bed2d20c57e007b2aedd8a67bceabd593b31143d54ead --hash=sha256:e1a31a112232504d753e5c01bb8c2de90d3f0ba986b063e10770cf7695b09e73
# via galaxy-importer # via galaxy-importer
markdown-it-py==4.3.0 \ markdown-it-py==4.3.0 \
--hash=sha256:7aa1511a46c39138de78d9eba92ce47e63124d8003fc98b3a351909e04239efa \ --hash=sha256:7aa1511a46c39138de78d9eba92ce47e63124d8003fc98b3a351909e04239efa \
@@ -1202,6 +1207,12 @@ mdurl==0.1.2 \
molecule==26.11.1 \ molecule==26.11.1 \
--hash=sha256:34035f2852f1c0461539051ec1dd2398492c1e4f370ba507b81a781f322e4147 \ --hash=sha256:34035f2852f1c0461539051ec1dd2398492c1e4f370ba507b81a781f322e4147 \
--hash=sha256:dcd147fb60bb66c060e0bf6a3eaa18f34433a18254a6f56f25ac254fb7980f64 --hash=sha256:dcd147fb60bb66c060e0bf6a3eaa18f34433a18254a6f56f25ac254fb7980f64
# via
# -r requirements-dev.txt
# molecule-plugins
molecule-plugins==26.11.0 \
--hash=sha256:194be2c43d950545cc699ab19f1a55b26853809e6e8c855ea1a42edacf5c7ee7 \
--hash=sha256:513808288b7027c465b124e66a2a31002c7c907b2fea9002f63ee90bb2d0ef84
# via -r requirements-dev.txt # via -r requirements-dev.txt
multidict==7.2.1 \ multidict==7.2.1 \
--hash=sha256:02009b402129a73e1f3da68f48eb999afbacd29f25aef0d5052b84ff5c2786a2 \ --hash=sha256:02009b402129a73e1f3da68f48eb999afbacd29f25aef0d5052b84ff5c2786a2 \
@@ -1420,13 +1431,13 @@ nodeenv==1.12.0 \
--hash=sha256:4ea7f88339310afebc3253f2c7a91b94bacf97d73a36a5c108962abdfaca501e \ --hash=sha256:4ea7f88339310afebc3253f2c7a91b94bacf97d73a36a5c108962abdfaca501e \
--hash=sha256:80644d65c10cc2be12e3e4b54b3367ff288c7ad24ae75c2dcc65454fc7449d4d --hash=sha256:80644d65c10cc2be12e3e4b54b3367ff288c7ad24ae75c2dcc65454fc7449d4d
# via pre-commit # via pre-commit
openai==3.60.0 \ openai==3.57.0 \
--hash=sha256:077657587f7d2d55b943a135c3e183f87cf7dc66644caa3c0bbc2bde1fe65de9 \ --hash=sha256:5a0a89d6a542efc85e2a8cec701ca9265b795d578c777828e10fafdf80e333b6 \
--hash=sha256:476e79f256a4ce74848b7abae9f074352a69dca6e7e8987d565ee883a3b7e496 --hash=sha256:f97bc74024c06ced8428b56c4a3594066709d3082779bf9d0b4b6092fbf587a8
# via llm # via llm
packaging==26.4 \ packaging==26.3 \
--hash=sha256:81383611a09c1bc0b08b76e0fd5829d7c6824c65b27a6aee339da133f4233ea2 \ --hash=sha256:94edc256424af38762eb31306eed28beb9f0efc50a8837492c9d6fd6004aed79 \
--hash=sha256:c4b671c41ddb9bf26e543c37723610d28fb6bf7affc4da17cf048d419d2c062a --hash=sha256:d7193f7c8e4e93f444fde0262bf90af30e16fa0ad0ad44cb553c87339b23cd1c
# via # via
# ansible-builder # ansible-builder
# ansible-compat # ansible-compat
@@ -1453,9 +1464,9 @@ pbr==7.1.3 \
--hash=sha256:6583e878a1d97cb135fdc509811f31b9235905cde8d4dacd3dbadf9efc45d745 \ --hash=sha256:6583e878a1d97cb135fdc509811f31b9235905cde8d4dacd3dbadf9efc45d745 \
--hash=sha256:9a4a85b84e906337708009af0b5f5cdabeeb72d4dc213c9e97974da54fd9acc5 --hash=sha256:9a4a85b84e906337708009af0b5f5cdabeeb72d4dc213c9e97974da54fd9acc5
# via bindep # via bindep
platformdirs==4.14.9 \ platformdirs==4.14.8 \
--hash=sha256:c6b188e03ffd4dfe1bf8c4bcb47cd94711af244a9852dbff60297bd753684d5d \ --hash=sha256:1e34af590de4d978631b751eb2202f2fee4497537a17c1720b12fcf57b331392 \
--hash=sha256:d0d3a23e7ff282cfa94b77f5a22b81030dcb68ba0430f90c74f4bd8d090782ea --hash=sha256:96893d686e84e9e6f358a9ea41a8de544df66dbf2ba6cda250e7dc73acf85b9b
# via # via
# black # black
# virtualenv # virtualenv
@@ -1795,9 +1806,9 @@ python-debian==1.1.1 \
--hash=sha256:f98ae013e8e5310e49041cc3860a7105df73af73d4ff1d8afb474770d328a6ad \ --hash=sha256:f98ae013e8e5310e49041cc3860a7105df73af73d4ff1d8afb474770d328a6ad \
--hash=sha256:fe4fc3dc798dbf1f0ef5865e2b1b4f7cc0352b6a511b25ab7594906c64a73629 --hash=sha256:fe4fc3dc798dbf1f0ef5865e2b1b4f7cc0352b6a511b25ab7594906c64a73629
# via reuse # via reuse
python-discovery==1.9.8 \ python-discovery==1.9.6 \
--hash=sha256:4e0c3349272923b6f58db8c5dad111b09dec9d3e2c97f9b79023f8b2e9acf7ab \ --hash=sha256:383aa67858d73a9585a843a37a4383c6be98e4d86a981a031328e393a6eb2632 \
--hash=sha256:5d66dd004e6972687438a799fa0895b7a900c1b7324a525196f1826bf7cebb03 --hash=sha256:93b10b90363d4151964cdeee2ec6601f3041b17fc2b253a1c3da7d6e7ddd8337
# via virtualenv # via virtualenv
python-frontmatter==1.3.0 \ python-frontmatter==1.3.0 \
--hash=sha256:9f7dd9260bec99044219159a329f64f039087f9d1a2124c9442556f2fe6f82ec \ --hash=sha256:9f7dd9260bec99044219159a329f64f039087f9d1a2124c9442556f2fe6f82ec \
@@ -1958,7 +1969,9 @@ requests==2.34.2 \
# via # via
# apm-cli # apm-cli
# azure-core # azure-core
# docker
# galaxy-importer # galaxy-importer
# molecule-plugins
resolvelib==1.2.1 \ resolvelib==1.2.1 \
--hash=sha256:7d08a2022f6e16ce405d60b68c390f054efcfd0477d4b9bd019cc941c28fad1c \ --hash=sha256:7d08a2022f6e16ce405d60b68c390f054efcfd0477d4b9bd019cc941c28fad1c \
--hash=sha256:fb06b66c8da04172d9e72a21d7d06186d8919e32ae5ab5cdf5b9d920be805ac2 --hash=sha256:fb06b66c8da04172d9e72a21d7d06186d8919e32ae5ab5cdf5b9d920be805ac2
@@ -2126,6 +2139,10 @@ ruamel-yaml==0.19.1 \
# via # via
# ansible-lint # ansible-lint
# apm-cli # apm-cli
selinux==0.3.0 \
--hash=sha256:2a88b337ac46ad0f06f557b2806c3df62421972f766673dd8bf26732fb75a9ea \
--hash=sha256:ecf7add45c939e9dda682c390a2cd0a845c94a4793a2cce9e8870d4ee9501f99
# via molecule-plugins
semantic-version==2.10.0 \ semantic-version==2.10.0 \
--hash=sha256:bdabb6d336998cbb378d4b9db3a4b56a1e3235701dc05ea2690d9a997ed5041c \ --hash=sha256:bdabb6d336998cbb378d4b9db3a4b56a1e3235701dc05ea2690d9a997ed5041c \
--hash=sha256:de78a3b8e0feda74cabc54aab2da702113e33ac9d9eb9d2389bcf1f58b7d9177 --hash=sha256:de78a3b8e0feda74cabc54aab2da702113e33ac9d9eb9d2389bcf1f58b7d9177
@@ -2148,9 +2165,9 @@ sqlite-fts4==1.0.3 \
--hash=sha256:0359edd8dea6fd73c848989e1e2b1f31a50fe5f9d7272299ff0e8dbaa62d035f \ --hash=sha256:0359edd8dea6fd73c848989e1e2b1f31a50fe5f9d7272299ff0e8dbaa62d035f \
--hash=sha256:78b05eeaf6680e9dbed8986bde011e9c086a06cb0c931b3cf7da94c214e8930c --hash=sha256:78b05eeaf6680e9dbed8986bde011e9c086a06cb0c931b3cf7da94c214e8930c
# via sqlite-utils # via sqlite-utils
sqlite-utils==4.2.2 \ sqlite-utils==4.2.1 \
--hash=sha256:5c54dc4d77260b44e8d0ccf4461c321c40ca1451dd6b6a63398ed058722aff13 \ --hash=sha256:76114b6a5414714e6c70e5fa5c4781b301b590f6951b5da39c8cc60c21382ba1 \
--hash=sha256:e92aa6c2bcefa1877cbd56e8da6fe3924ca5b45954f98e7d738c49d19325fa0d --hash=sha256:7fbaee670713b25eceba05779b844f0895efaf680d9a226fa5ba7dfe165721c5
# via llm # via llm
subprocess-tee==0.4.2 \ subprocess-tee==0.4.2 \
--hash=sha256:21942e976715af4a19a526918adb03a8a27a8edab959f2d075b777e3d78f532d \ --hash=sha256:21942e976715af4a19a526918adb03a8a27a8edab959f2d075b777e3d78f532d \
@@ -2166,9 +2183,9 @@ toml==0.10.2 \
--hash=sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b \ --hash=sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b \
--hash=sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f --hash=sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f
# via apm-cli # via apm-cli
tomlkit==0.15.3 \ tomlkit==0.15.2 \
--hash=sha256:a83ce6de3b648e68dd9b50aabadad749ba823eb58b1d026f3c0a283c4767a9c1 \ --hash=sha256:05562412163a3037b94497385fb7f9204c637bc605af7a48199e41cf2272f437 \
--hash=sha256:b3c3020ec1a4bd469d12e31fb4da938e7f6ba758cdbec3fd9047db63120eaf81 --hash=sha256:83e32755ba1d20d9340bd069ee97e9f6232ba2346b63ffcba425de01f7e327a6
# via # via
# apm-cli # apm-cli
# reuse # reuse
@@ -2179,9 +2196,9 @@ truststore==0.10.5 \
# apm-cli # apm-cli
# httpcore2 # httpcore2
# httpx2 # httpx2
typer==0.29.3 \ typer==0.29.2 \
--hash=sha256:1fd37275046faecc86caa2e0e313978c10db71533fc0fe1a48f4e03a60efc23c \ --hash=sha256:b1998dc5f2c3dedafa1517a9521fa944cc4dc1fadcea085d81a3b10ebcaeb075 \
--hash=sha256:8189a53bb9684dc551e0b61e71904b323214884f2eb14bfe71aa859ae980d10a --hash=sha256:f30731f8ca758368b836b3714872e58e395cef8fcaff918c853b1969ed5274e7
# via rstcheck # via rstcheck
typing-extensions==4.16.0 \ typing-extensions==4.16.0 \
--hash=sha256:481caa481374e813c1b176ada14e97f1f67a4539ce9cfeb3f350d78d6370c2e8 \ --hash=sha256:481caa481374e813c1b176ada14e97f1f67a4539ce9cfeb3f350d78d6370c2e8 \
@@ -2206,10 +2223,12 @@ tzdata==2026.6 \
urllib3==2.8.0 \ urllib3==2.8.0 \
--hash=sha256:0cf3cae568d36aa9576b28dfb35f11328f1cb974ca7647d9475ebb86c75ac6e3 \ --hash=sha256:0cf3cae568d36aa9576b28dfb35f11328f1cb974ca7647d9475ebb86c75ac6e3 \
--hash=sha256:63bf2ead4c879426ebf22ef2a781eeb4aa3b4ae798a0435506f8687fd5bb9b63 --hash=sha256:63bf2ead4c879426ebf22ef2a781eeb4aa3b4ae798a0435506f8687fd5bb9b63
# via requests # via
virtualenv==21.15.14 \ # docker
--hash=sha256:6c6e7aaf88064767c75c32a9df92eaa425cee5db4cc21caf031a78d89375d57f \ # requests
--hash=sha256:816503d7826a2269abc03f7f0dd48ffd3b63db1958a7a3cbeea5a70dd7fe0ff1 virtualenv==21.15.12 \
--hash=sha256:a3976f886eb6019fcb1d137b223d160adaeff524ab0ad785c729a43c31cc158c \
--hash=sha256:bbbf764388a18dee8c3532c77af7a29680cd8121911d6dcb3484335d76547323
# via pre-commit # via pre-commit
watchdog==7.1.1 \ watchdog==7.1.1 \
--hash=sha256:05e85c22dcd53f7152d1e03e785e241341d586b06a5115be7c0ea86436ccc1f6 \ --hash=sha256:05e85c22dcd53f7152d1e03e785e241341d586b06a5115be7c0ea86436ccc1f6 \
+5 -6
View File
@@ -1,4 +1,4 @@
# Pinned tooling for Lint and Build, used by CI (.gitea/workflows) and locally: # Pinned tooling for lint, build and Molecule, used by CI (.gitea/workflows) and locally:
# python3 -m venv .venv && . .venv/bin/activate && pip install --require-hashes -r requirements-dev.lock -r requirements-dev.txt # python3 -m venv .venv && . .venv/bin/activate && pip install --require-hashes -r requirements-dev.lock -r requirements-dev.txt
# This file holds the direct pins; requirements-dev.lock is their hashed lock (every transitive # This file holds the direct pins; requirements-dev.lock is their hashed lock (every transitive
# package too, with the sha256 of each release file) and is what gets installed; pip refuses an # package too, with the sha256 of each release file) and is what gets installed; pip refuses an
@@ -10,14 +10,13 @@ ansible-core==2.22.0
ansible-lint==26.10.1 ansible-lint==26.10.1
pre-commit==4.7.0 pre-commit==4.7.0
antsibull-changelog==0.38.0 antsibull-changelog==0.38.0
galaxy-importer==0.4.45 galaxy-importer==0.4.44
reuse==6.3.0 reuse==6.3.0
# molecule without its Docker driver: Lint's "Test the repository scripts" step imports it in
# test_check_scenarios_load_checkout.py and test_run_molecule_scenarios.py, which skip without it.
molecule==26.11.1 molecule==26.11.1
molecule-plugins[docker]==26.11.0
# proxmoxer: the controller-side library community.proxmox's modules import (they refuse anything below 2.3), # proxmoxer: the controller-side library community.proxmox's modules import (they refuse anything below 2.3),
# so lint runs where a consumer's controller would. # so lint and Molecule run where a consumer's controller would.
proxmoxer==2.3.0 proxmoxer==2.3.0
# apm-cli: for changing apm.yml (run apm install, commit the lock). Keep it at 0.36.1 or later (#252): # apm-cli: for changing apm.yml (run apm install, commit the lock). Keep it at 0.36.1 or later (#252):
# before 0.29.0, `apm audit --ci` compares the whole .claude/settings.json and fails on any hand-written key. # before 0.29.0, `apm audit --ci` compares the whole .claude/settings.json and fails on any hand-written key.
apm-cli==0.39.1 apm-cli==0.38.1
+2 -3
View File
@@ -2,9 +2,8 @@
# Collections the roles of this Collection call (the dependencies of galaxy.yml, pinned exactly). # Collections the roles of this Collection call (the dependencies of galaxy.yml, pinned exactly).
# galaxy.yml holds the lower bounds a consumer needs; this file holds the versions CI tests # galaxy.yml holds the lower bounds a consumer needs; this file holds the versions CI tests
# against. One file feeds every consumer, so they cannot drift apart: # against. One file feeds every consumer, so they cannot drift apart:
# - the ci image (images/ci/Dockerfile) bakes it into /opt/collections for Lint; # - the ci image (images/ci/Dockerfile) bakes it into /opt/collections for Lint and Molecule;
# - the molecule-controller image (images/molecule-controller/Dockerfile) bakes it for Molecule, # - the Molecule job (.gitea/workflows/molecule.yml) installs it itself when a pull request changes it;
# and scripts/run_molecule_in_controller.sh installs it itself when a pull request changes it;
# - scripts/dev-setup.sh installs it into .ansible/collections for local lint. # - scripts/dev-setup.sh installs it into .ansible/collections for local lint.
# Renovate (renovate.json, ansible-galaxy manager) bumps these pins. # Renovate (renovate.json, ansible-galaxy manager) bumps these pins.
collections: collections:
+4 -20
View File
@@ -15,7 +15,7 @@ The role targets Ubuntu guests (the `ubuntu_lxc` and `ubuntu_vm` profiles) and P
- Facts must be gathered (`gather_facts: true`); `reboot.yml` reads `ansible_facts['os_family']`. - Facts must be gathered (`gather_facts: true`); `reboot.yml` reads `ansible_facts['os_family']`.
- `system_baseline_system_type` is required and has no default (the role does not read a global such as `system_type`; map it in the inventory). Valid values: `ubuntu_lxc`, `ubuntu_vm` or `pve`. - `system_baseline_system_type` is required and has no default (the role does not read a global such as `system_type`; map it in the inventory). Valid values: `ubuntu_lxc`, `ubuntu_vm` or `pve`.
- Use it by its fully qualified name, `mortis.kamino.system_baseline`. - Use it by its fully qualified name, `mortis.kamino.system_baseline`.
- Collections: `community.general` (locale, timezone) and `ansible.posix` (mount). - Collections: `community.general` (locale, timezone) and `ansible.posix` (sysctl, mount).
- Run it after the roles that manage users and SSH, and before the roles that harden services and manage firewalls and jails. A firewall role that rewrites sysctl values (ufw re-applies its stock `/etc/ufw/sysctl.conf` when it is enabled) must run after this role and needs the same values as this role's `sysctl_hardening` to keep them. - Run it after the roles that manage users and SSH, and before the roles that harden services and manage firewalls and jails. A firewall role that rewrites sysctl values (ufw re-applies its stock `/etc/ufw/sysctl.conf` when it is enabled) must run after this role and needs the same values as this role's `sysctl_hardening` to keep them.
- Role dependencies: none. - Role dependencies: none.
@@ -43,8 +43,7 @@ templating error instead of the role's own message.
| `system_baseline_unattended_upgrade_settings` | from profile | no | Keys for `50unattended-upgrades` | | `system_baseline_unattended_upgrade_settings` | from profile | no | Keys for `50unattended-upgrades` |
| `system_baseline_unattended_upgrade_origins` | from profile | no | Pinned `Origins-Pattern` entries; `[]` keeps the distribution default (see below) | | `system_baseline_unattended_upgrade_origins` | from profile | no | Pinned `Origins-Pattern` entries; `[]` keeps the distribution default (see below) |
| `system_baseline_unattended_upgrade_package_blacklist` | `[]` | no | Packages unattended-upgrades must not touch, as regular expressions (see below) | | `system_baseline_unattended_upgrade_package_blacklist` | `[]` | no | Packages unattended-upgrades must not touch, as regular expressions (see below) |
| `system_baseline_sysctl_hardening` | from profile | no | List of `name` and `value` sysctl pairs; `*` in a name matches every interface (see "Sysctl hardening") | | `system_baseline_sysctl_hardening` | from profile | no | List of `name` and `value` sysctl pairs |
| `system_baseline_sysctl_file` | `/etc/sysctl.d/99-zz-system-baseline.conf` | no | Drop-in that persists the sysctl pairs: a `.conf` file directly under `/etc/sysctl.d` (see "Sysctl hardening") |
| `system_baseline_secure_tmp_mounts` | from profile | no | Paths remounted as tmpfs with `noexec,nosuid,nodev` | | `system_baseline_secure_tmp_mounts` | from profile | no | Paths remounted as tmpfs with `noexec,nosuid,nodev` |
| `system_baseline_journal_max_use` | `200M` | no | Upper bound of the persistent journal (journald `SystemMaxUse`): a number with an optional upper-case `B`, `K`, `M`, `G`, `T`, `P` or `E`, such as `1.5G`; a bare number is bytes. journald does not take `infinity`. Empty leaves the host alone and removes nothing a former run wrote (see "Leaving journald alone") | | `system_baseline_journal_max_use` | `200M` | no | Upper bound of the persistent journal (journald `SystemMaxUse`): a number with an optional upper-case `B`, `K`, `M`, `G`, `T`, `P` or `E`, such as `1.5G`; a bare number is bytes. journald does not take `infinity`. Empty leaves the host alone and removes nothing a former run wrote (see "Leaving journald alone") |
| `system_baseline_tmux_autostart` | `false` | no | Attach interactive SSH logins to a tmux session (`ubuntu_lxc` and `ubuntu_vm` only) | | `system_baseline_tmux_autostart` | `false` | no | Attach interactive SSH logins to a tmux session (`ubuntu_lxc` and `ubuntu_vm` only) |
@@ -130,19 +129,18 @@ The two task files besides `main` are a supported interface, for a caller that d
The scenario `molecule/default/` runs in CI only, on two platforms: `${MOLECULE_IMAGE}` (Ubuntu 24.04) and `${MOLECULE_IMAGE_2604}` (Ubuntu 26.04). It installs packages from the Ubuntu mirrors, so the runner needs outbound network. It runs `check` before the converge (a fresh host) and after it (a configured host). The scenario `molecule/default/` runs in CI only, on two platforms: `${MOLECULE_IMAGE}` (Ubuntu 24.04) and `${MOLECULE_IMAGE_2604}` (Ubuntu 26.04). It installs packages from the Ubuntu mirrors, so the runner needs outbound network. It runs `check` before the converge (a fresh host) and after it (a configured host).
- Verify first checks, on the controller, that the role refuses a bad input with its own message before any change: an unknown `system_baseline_system_type`, an unknown `system_baseline_apt_upgrade` (main flow and `update` entry point), a negative reboot throttle or a negative or boolean post-reboot delay (main flow and `reboot` entry point), a line break in `system_baseline_apt_daily_timeout`, a bad `system_baseline_journal_max_use` (`infinity`, a lower-case unit, a unit with a trailing `B`, a line break, a number), a bad `system_baseline_sysctl_file` (`/etc/sysctl.conf`, `99-sysctl.conf`, a path with `..`, a name without `.conf`, empty), and a bad package blacklist (a quote, a null item, a bare string). - Verify first checks, on the controller, that the role refuses a bad input with its own message before any change: an unknown `system_baseline_system_type`, an unknown `system_baseline_apt_upgrade` (main flow and `update` entry point), a negative reboot throttle or a negative or boolean post-reboot delay (main flow and `reboot` entry point), a line break in `system_baseline_apt_daily_timeout`, a bad `system_baseline_journal_max_use` (`infinity`, a lower-case unit, a unit with a trailing `B`, a line break, a number), and a bad package blacklist (a quote, a null item, a bare string).
- Converge applies the `ubuntu_lxc` profile, with tmux autostart and `system_baseline_apt_daily_timeout: 1h`. Verify only resolves the `pve` and `ubuntu_vm` profiles and a consumer override, on the controller, asserting the resolved inputs. - Converge applies the `ubuntu_lxc` profile, with tmux autostart and `system_baseline_apt_daily_timeout: 1h`. Verify only resolves the `pve` and `ubuntu_vm` profiles and a consumer override, on the controller, asserting the resolved inputs.
- Verify checks the installed and removed packages, the journal size cap, the apt settings in `20auto-upgrades` and `50unattended-upgrades`, the locale, and that systemd loaded the `apt-daily.service` timeout. - Verify checks the installed and removed packages, the journal size cap, the apt settings in `20auto-upgrades` and `50unattended-upgrades`, the locale, and that systemd loaded the `apt-daily.service` timeout.
- Verify checks the tmux snippet: root-owned, valid shell, the session and quoted window command, no effect without a terminal, a session name or window command ending in a newline refused, and the file removed when autostart is off. - Verify checks the tmux snippet: root-owned, valid shell, the session and quoted window command, no effect without a terminal, a session name or window command ending in a newline refused, and the file removed when autostart is off.
- Verify refuses bad items in `system_baseline_extra_packages` and `system_baseline_extra_remove_packages` (whitespace, a null, an empty string, a trailing minus, upper case, a bare string) and a package that one input installs and another purges; converge applies the `ubuntu_lxc` profile with `jq` as an extra package and `ed` as an extra removal; verify checks that `jq` is installed, `ed` is gone and the profile's packages are still there, and that an extra `tmux` installs the snippet where a flat list without it installs none. - Verify refuses bad items in `system_baseline_extra_packages` and `system_baseline_extra_remove_packages` (whitespace, a null, an empty string, a trailing minus, upper case, a bare string) and a package that one input installs and another purges; converge applies the `ubuntu_lxc` profile with `jq` as an extra package and `ed` as an extra removal; verify checks that `jq` is installed, `ed` is gone and the profile's packages are still there, and that an extra `tmux` installs the snippet where a flat list without it installs none.
- Verify also checks that a bad `system_baseline_apt_tmpdir` (under `/tmp` or `/var/tmp`, relative, with `..`, empty) is refused in the main flow and in the `update` entry point. It reads `tasks/update.yml` and checks that the scratch directory is created with mode `0700`, that both apt tasks set `TMPDIR` to it, that the connection is reset afterwards, and that the vzdump guard is imported before the upgrade, whose `when` reads the guard's fact: the scenario skips the `update` tag, so the upgrade itself never runs there. - Verify also checks that a bad `system_baseline_apt_tmpdir` (under `/tmp` or `/var/tmp`, relative, with `..`, empty) is refused in the main flow and in the `update` entry point. It reads `tasks/update.yml` and checks that the scratch directory is created with mode `0700`, that both apt tasks set `TMPDIR` to it, that the connection is reset afterwards, and that the vzdump guard is imported before the upgrade, whose `when` reads the guard's fact: the scenario skips the `update` tag, so the upgrade itself never runs there.
- Verify runs the vzdump guard in check mode on the Ubuntu container with `system_baseline_system_type: pve` and a `pvesh` stub, in seven cases (a running, a finished or no vzdump task, the input off, `ubuntu_lxc`); six run the guard's task file alone and the `ubuntu_lxc` case runs the whole `update` entry point. Each case asserts the fact that decides the upgrade and that `pvesh` was run, with `--source active`, only when it should be. It does not assert that the apt task itself was skipped. The stub stands for the real answer, which no CI image has. - Verify runs the vzdump guard in check mode on the Ubuntu container with `system_baseline_system_type: pve` and a `pvesh` stub, in seven cases (a running, a finished or no vzdump task, the input off, `ubuntu_lxc`); six run the guard's task file alone and the `ubuntu_lxc` case runs the whole `update` entry point. Each case asserts the fact that decides the upgrade and that `pvesh` was run, with `--source active`, only when it should be. It does not assert that the apt task itself was skipped. The stub stands for the real answer, which no CI image has.
- Prepare seeds `/etc/sysctl.conf` with keys of the role and other lines. Verify checks that the drop-in holds exactly the profile's keys, that only the role's keys left `/etc/sysctl.conf`, that a key removed from the list leaves the drop-in and that a missing `/etc/sysctl.conf` is not created. It runs the runtime apply on the container's read-only `/proc/sys`: no change for the live value, a reported change in check mode and a failure for a value that cannot be set, each for a plain key and for a `*`, and a failure for a `*` that matches no key.
- Verify ends by running the role once with `system_baseline_journal_max_use: ""` after removing the drop-in, and asserts that no drop-in is written and that `systemd-journald` was not restarted. - Verify ends by running the role once with `system_baseline_journal_max_use: ""` after removing the drop-in, and asserts that no drop-in is written and that `systemd-journald` was not restarted.
- Verify runs the `reboot` entry point with `system_baseline_reboot_if_required: false`, without and with `/var/run/reboot-required`, and checks the fact and that the host did not reboot. - Verify runs the `reboot` entry point with `system_baseline_reboot_if_required: false`, without and with `/var/run/reboot-required`, and checks the fact and that the host did not reboot.
- The `pve` origins pin is applied to the Ubuntu container and read back with `apt-config dump`, then removed again. The package blacklist is written, read back as a list, left alone by a second run and removed by an empty list. - The `pve` origins pin is applied to the Ubuntu container and read back with `apt-config dump`, then removed again. The package blacklist is written, read back as a list, left alone by a second run and removed by an empty list.
Not covered: Molecule skips the sysctl runtime apply in the role run, `secure_tmp`, `update` and `timezone` (no privileged container); see `molecule/default/molecule.yml`. So `system_baseline_update` is checked only for its default; the skip itself is not exercised by a test. No test writes a live sysctl value, runs without IPv6 or reboots to see `systemd-sysctl` load the drop-in. No host reboots, and the `pve` profile is not converged: Debian 13 is not verified by a test. Not covered: Molecule skips `sysctl`, `secure_tmp`, `update` and `timezone` (no privileged container); see `molecule/default/molecule.yml`. So `system_baseline_update` is checked only for its default; the skip itself is not exercised by a test. No host reboots, and the `pve` profile is not converged: Debian 13 is not verified by a test.
## Notes ## Notes
@@ -230,20 +228,6 @@ An upgrade of a Proxmox node can restart Proxmox services while a backup holds a
`system_baseline_journal_max_use: ""` skips the journald task: no drop-in directory, no `50-system-baseline.conf` and no restart of `systemd-journald`. Use it where another drop-in, role or policy owns the journal size. A file an earlier run wrote stays, as for an empty `system_baseline_apt_daily_timeout`; remove it by hand if the cap should go. A value that is not empty and not a size journald reads (`infinity`, `10m`, one with a line break) stops the run before any change, in the same way as the apt-daily value. `system_baseline_journal_max_use: ""` skips the journald task: no drop-in directory, no `50-system-baseline.conf` and no restart of `systemd-journald`. Use it where another drop-in, role or policy owns the journal size. A file an earlier run wrote stays, as for an empty `system_baseline_apt_daily_timeout`; remove it by hand if the cap should go. A value that is not empty and not a size journald reads (`infinity`, `10m`, one with a line break) stops the run before any change, in the same way as the apt-daily value.
### Sysctl hardening
The role sets each pair of `system_baseline_sysctl_hardening` on the running kernel when the live value differs, then writes the list to `system_baseline_sysctl_file`, which `systemd-sysctl` loads at boot. A value that cannot be set stops the run before the file is written. `--tags sysctl` does both.
- Every profile refuses ICMP redirects on every interface: `accept_redirects` is `0` for `all`, `default` and `*` (each interface that exists) over IPv4 and IPv6. `secure_redirects` is `0` for `all` and `default` over IPv4; the kernel reads it only for an interface that accepts redirects. An inventory that overrides the list or a profile's `sysctl_hardening` has to add these keys itself.
- A `*` sets every matching key except those with an entry of their own, so `net.ipv4.conf.eth1.accept_redirects` in the list keeps its value. At boot an entry in any other `sysctl.d` file also wins over a `*`. Write names with dots, and a dot in an interface name as a slash: `net.ipv4.conf.eth0/100.accept_redirects`. Use a `*` only for keys with a single-word value, and no two patterns that match the same key.
- Without IPv6 in the kernel the role skips the `net.ipv6` keys on the running kernel and still persists them. `systemd-sysctl` ignores them at boot; `sysctl -p` on the drop-in reports them as missing and exits 1.
- The role owns the whole drop-in: a key removed from the list leaves the file, and its live value stays until the next reboot. When the list repeats a key, the last entry wins.
- At boot the last file that sets a key wins, in the order of the file names. The default sorts after `99-sysctl.conf`, but a name that starts with a letter loads later: for example Proxmox VE's `/usr/lib/sysctl.d/pve-firewall.conf`, which sets `net.ipv4.conf.all.rp_filter`. To override such a file, choose a name that sorts after it.
- Changing `system_baseline_sysctl_file` does not remove the old file, which is still loaded at boot; remove it by hand.
- The keys of the list are removed from `/etc/sysctl.conf`, where earlier releases of the role wrote them. Other lines stay, including a key that had already been dropped from the list.
- ufw applies its own `/etc/ufw/sysctl.conf` when it starts and can override values such as `net.ipv4.conf.all.log_martians`. Set the same values there (`ufw_sysctl_overrides` of the `ufw` role).
- A container may not run `systemd-sysctl` at boot (the unit is skipped when `/proc/sys` is read-only). The values then apply only when the role runs.
### Apt scratch directory ### Apt scratch directory
The upgrade runs over the SSH connection Ansible uses. An `openssh-server` upgrade restarts `ssh.service`, and a unit with `PrivateTmp=yes` (the `systemd_hardening` role sets it) has its own `/tmp` and `/var/tmp`, which systemd deletes when the unit stops. The files apt staged there for the running upgrade then disappear and dpkg fails, leaving packages unpacked but not configured. So the `update` flow creates `system_baseline_apt_tmpdir` (root, mode `0700`), runs the upgrade and the autoremove with `TMPDIR` set to it, and opens a new connection afterwards, so that later tasks get a fresh private `/tmp`. The upgrade runs over the SSH connection Ansible uses. An `openssh-server` upgrade restarts `ssh.service`, and a unit with `PrivateTmp=yes` (the `systemd_hardening` role sets it) has its own `/tmp` and `/var/tmp`, which systemd deletes when the unit stops. The files apt staged there for the running upgrade then disappear and dpkg fails, leaving packages unpacked but not configured. So the `update` flow creates `system_baseline_apt_tmpdir` (root, mode `0700`), runs the upgrade and the autoremove with `TMPDIR` set to it, and opens a new connection afterwards, so that later tasks get a fresh private `/tmp`.
-25
View File
@@ -24,9 +24,6 @@ system_baseline_skip_upgrade_during_vzdump: false
# Upper bound of the persistent journal (journald SystemMaxUse); older archived files are removed above it. Empty leaves the host alone # Upper bound of the persistent journal (journald SystemMaxUse); older archived files are removed above it. Empty leaves the host alone
# (tasks/journald.yml is not run; a drop-in an earlier run wrote stays). # (tasks/journald.yml is not run; a drop-in an earlier run wrote stays).
system_baseline_journal_max_use: 200M system_baseline_journal_max_use: 200M
# Drop-in that persists the sysctl hardening (tasks/sysctl.yml). The last file that sets a key wins at boot, so the name sorts after
# 99-sysctl.conf. A file whose name starts with a letter still loads later.
system_baseline_sysctl_file: /etc/sysctl.d/99-zz-system-baseline.conf
# Attach an interactive SSH login to a tmux session (see tasks/tmux.yml). Off by default: it changes what every login does. # Attach an interactive SSH login to a tmux session (see tasks/tmux.yml). Off by default: it changes what every login does.
# Installed only when tmux is among the packages to install: the ubuntu_lxc and ubuntu_vm profiles have it, the pve profile has none unless # Installed only when tmux is among the packages to install: the ubuntu_lxc and ubuntu_vm profiles have it, the pve profile has none unless
# system_baseline_extra_packages adds it. # system_baseline_extra_packages adds it.
@@ -110,13 +107,7 @@ system_baseline_profiles:
- { name: "kernel.randomize_va_space", value: 2 } - { name: "kernel.randomize_va_space", value: 2 }
- { name: "net.ipv4.conf.all.accept_source_route", value: 0 } - { name: "net.ipv4.conf.all.accept_source_route", value: 0 }
- { name: "net.ipv4.conf.all.accept_redirects", value: 0 } - { name: "net.ipv4.conf.all.accept_redirects", value: 0 }
- { name: "net.ipv4.conf.default.accept_redirects", value: 0 }
- { name: "net.ipv4.conf.*.accept_redirects", value: 0 }
- { name: "net.ipv4.conf.all.secure_redirects", value: 0 } - { name: "net.ipv4.conf.all.secure_redirects", value: 0 }
- { name: "net.ipv4.conf.default.secure_redirects", value: 0 }
- { name: "net.ipv6.conf.all.accept_redirects", value: 0 }
- { name: "net.ipv6.conf.default.accept_redirects", value: 0 }
- { name: "net.ipv6.conf.*.accept_redirects", value: 0 }
- { name: "net.ipv4.icmp_echo_ignore_broadcasts", value: 1 } - { name: "net.ipv4.icmp_echo_ignore_broadcasts", value: 1 }
- { name: "net.ipv4.icmp_ignore_bogus_error_responses", value: 1 } - { name: "net.ipv4.icmp_ignore_bogus_error_responses", value: 1 }
- { name: "net.ipv4.conf.all.log_martians", value: 1 } - { name: "net.ipv4.conf.all.log_martians", value: 1 }
@@ -179,13 +170,7 @@ system_baseline_profiles:
- { name: "net.ipv4.tcp_syncookies", value: 1 } - { name: "net.ipv4.tcp_syncookies", value: 1 }
- { name: "net.ipv4.conf.all.accept_source_route", value: 0 } - { name: "net.ipv4.conf.all.accept_source_route", value: 0 }
- { name: "net.ipv4.conf.all.accept_redirects", value: 0 } - { name: "net.ipv4.conf.all.accept_redirects", value: 0 }
- { name: "net.ipv4.conf.default.accept_redirects", value: 0 }
- { name: "net.ipv4.conf.*.accept_redirects", value: 0 }
- { name: "net.ipv4.conf.all.secure_redirects", value: 0 } - { name: "net.ipv4.conf.all.secure_redirects", value: 0 }
- { name: "net.ipv4.conf.default.secure_redirects", value: 0 }
- { name: "net.ipv6.conf.all.accept_redirects", value: 0 }
- { name: "net.ipv6.conf.default.accept_redirects", value: 0 }
- { name: "net.ipv6.conf.*.accept_redirects", value: 0 }
- { name: "net.ipv4.icmp_echo_ignore_broadcasts", value: 1 } - { name: "net.ipv4.icmp_echo_ignore_broadcasts", value: 1 }
- { name: "net.ipv4.icmp_ignore_bogus_error_responses", value: 1 } - { name: "net.ipv4.icmp_ignore_bogus_error_responses", value: 1 }
@@ -246,13 +231,7 @@ system_baseline_profiles:
- { name: "kernel.randomize_va_space", value: 2 } - { name: "kernel.randomize_va_space", value: 2 }
- { name: "net.ipv4.conf.all.accept_source_route", value: 0 } - { name: "net.ipv4.conf.all.accept_source_route", value: 0 }
- { name: "net.ipv4.conf.all.accept_redirects", value: 0 } - { name: "net.ipv4.conf.all.accept_redirects", value: 0 }
- { name: "net.ipv4.conf.default.accept_redirects", value: 0 }
- { name: "net.ipv4.conf.*.accept_redirects", value: 0 }
- { name: "net.ipv4.conf.all.secure_redirects", value: 0 } - { name: "net.ipv4.conf.all.secure_redirects", value: 0 }
- { name: "net.ipv4.conf.default.secure_redirects", value: 0 }
- { name: "net.ipv6.conf.all.accept_redirects", value: 0 }
- { name: "net.ipv6.conf.default.accept_redirects", value: 0 }
- { name: "net.ipv6.conf.*.accept_redirects", value: 0 }
- { name: "net.ipv4.icmp_echo_ignore_broadcasts", value: 1 } - { name: "net.ipv4.icmp_echo_ignore_broadcasts", value: 1 }
- { name: "net.ipv4.icmp_ignore_bogus_error_responses", value: 1 } - { name: "net.ipv4.icmp_ignore_bogus_error_responses", value: 1 }
- { name: "net.ipv4.conf.all.log_martians", value: 1 } - { name: "net.ipv4.conf.all.log_martians", value: 1 }
@@ -297,8 +276,4 @@ system_baseline_unattended_upgrade_origins: "{{ system_baseline_profile.unattend
# package blacklist"). Entries are regular expressions matched against the package name. # package blacklist"). Entries are regular expressions matched against the package name.
system_baseline_unattended_upgrade_package_blacklist: [] system_baseline_unattended_upgrade_package_blacklist: []
system_baseline_sysctl_hardening: "{{ system_baseline_profile.sysctl_hardening }}" system_baseline_sysctl_hardening: "{{ system_baseline_profile.sysctl_hardening }}"
# What the role acts on, as {name: value}. Internal. The last entry of a repeated key wins, and a boolean word becomes the number sysctl takes.
__system_baseline_sysctl: >-
{{ dict(system_baseline_sysctl_hardening | map(attribute='name') | zip(system_baseline_sysctl_hardening | map(attribute='value') | map('string')
| map('regex_replace', '(?i)^(y|yes|on|t|true)$', '1') | map('regex_replace', '(?i)^(n|no|off|f|false)$', '0'))) }}
system_baseline_secure_tmp_mounts: "{{ system_baseline_profile.secure_tmp_mounts }}" system_baseline_secure_tmp_mounts: "{{ system_baseline_profile.secure_tmp_mounts }}"
@@ -60,15 +60,6 @@ argument_specs:
is bytes); anything else (C(infinity), a lower-case unit, a line break) is refused before any change. Empty leaves the host is bytes); anything else (C(infinity), a lower-case unit, a line break) is refused before any change. Empty leaves the host
alone: no drop-in is written and journald is not restarted. alone: no drop-in is written and journald is not restarted.
Clearing the value later does not remove a file already written. Clearing the value later does not remove a file already written.
system_baseline_sysctl_file:
type: str
default: /etc/sysctl.d/99-zz-system-baseline.conf
description:
- >-
Drop-in that persists C(system_baseline_sysctl_hardening) across reboots. The role owns the whole file. It must be a C(.conf)
file directly under C(/etc/sysctl.d), other than C(99-sysctl.conf); anything else is refused before any change.
- The last file that sets a key wins at boot, in the order of the file names; a name that starts with a letter sorts after the default.
- Changing the value later does not remove the old file.
system_baseline_tmux_autostart: system_baseline_tmux_autostart:
type: bool type: bool
default: false default: false
@@ -45,9 +45,9 @@ platforms:
provisioner: provisioner:
name: ansible name: ansible
options: options:
# Applying sysctls (molecule-notest) and tmpfs mounts need a privileged container; a full upgrade # sysctl and tmpfs mounts need a privileged container; a full upgrade adds only
# adds only time; the timezone needs timedatectl. The rest of the role runs for real. # time; the timezone needs timedatectl. The rest of the role runs for real.
skip-tags: molecule-notest,notest,secure_tmp,update,timezone skip-tags: molecule-notest,notest,sysctl,secure_tmp,update,timezone
verifier: verifier:
name: ansible name: ansible
scenario: scenario:
@@ -1,15 +1,14 @@
--- ---
# A package the role must remove, and the locales tool the role assumes exists # A package the role must remove, and the locales tool the role assumes exists
# (it does on a stock Ubuntu host). jq (system_baseline_extra_packages) must be absent, so that the role is what installs it, and ed # (it does on a stock Ubuntu host). jq (system_baseline_extra_packages) must be absent, so that the role is what installs it, and ed
# (system_baseline_extra_remove_packages, on no profile list) must be present, so that the role is what purges it. procps has the sysctl # (system_baseline_extra_remove_packages, on no profile list) must be present, so that the role is what purges it.
# command verify needs.
- name: Prepare - name: Prepare
hosts: all hosts: all
gather_facts: false gather_facts: false
tasks: tasks:
- name: Install packages the role removes and tools it assumes - name: Install a package on the role's remove list and locale-gen
ansible.builtin.apt: ansible.builtin.apt:
name: [telnet, locales, ed, procps] name: [telnet, locales, ed]
state: present state: present
update_cache: true update_cache: true
@@ -17,13 +16,3 @@
ansible.builtin.apt: ansible.builtin.apt:
name: jq name: jq
state: absent state: absent
- name: Seed /etc/sysctl.conf with keys of the role and lines it must leave alone
ansible.builtin.copy:
dest: /etc/sysctl.conf
mode: "0644"
content: |
# net.ipv4.tcp_syncookies=1
net.ipv4.tcp_syncookies=1
vm.max_map_count = 262144
net.ipv4.conf.all.accept_redirects = 0
@@ -1,18 +0,0 @@
---
# One refusal: the role must stop on validation, before it changes anything, with a message that names the variable.
- name: Run the role with a bad system_baseline_sysctl_file
block:
- name: Include system_baseline
ansible.builtin.include_role:
name: mortis.kamino.system_baseline
vars:
system_baseline_system_type: ubuntu_lxc
system_baseline_sysctl_file: "{{ system_baseline_refused_sysctl_file }}"
- name: Unreachable when validation works
ansible.builtin.fail:
msg: system_baseline ran with an invalid system_baseline_sysctl_file
rescue:
- name: The validation stopped the play
ansible.builtin.assert:
that: "'system_baseline_sysctl_file must be' in ansible_failed_result.msg | default('')"
quiet: true
@@ -151,25 +151,6 @@
- "200M\nStorage=none" - "200M\nStorage=none"
- 300 - 300
# The role overwrites the whole drop-in: /etc/sysctl.conf, the link to it, another directory and a name systemd-sysctl does not read
# each stop the run before any change.
- name: A bad sysctl drop-in path is refused
hosts: localhost
connection: local
check_mode: true
gather_facts: false
tasks:
- name: Refuse each bad value
ansible.builtin.include_tasks: tasks/refuse_sysctl_file.yml
vars:
system_baseline_refused_sysctl_file: "{{ item }}"
loop:
- /etc/sysctl.conf
- /etc/sysctl.d/99-sysctl.conf
- /etc/sysctl.d/../sysctl.conf
- /etc/sysctl.d/baseline
- ""
# A quote, a null item and a bare string (not a list) each stop the run: the bare string would otherwise be split into one-character # A quote, a null item and a bare string (not a list) each stop the run: the bare string would otherwise be split into one-character
# patterns, and the null item would become an empty pattern that matches every package. # patterns, and the null item would become an empty pattern that matches every package.
- name: A bad package blacklist is refused - name: A bad package blacklist is refused
@@ -837,208 +818,6 @@
- {type: pve, input: false, running: false, asked: false, answer: [{type: vzdump, upid: a, starttime: 1}]} - {type: pve, input: false, running: false, asked: false, answer: [{type: vzdump, upid: a, starttime: 1}]}
- {type: ubuntu_lxc, input: true, running: false, asked: false, answer: [{type: vzdump, upid: a, starttime: 1}], tasks_from: update} - {type: ubuntu_lxc, input: true, running: false, asked: false, answer: [{type: vzdump, upid: a, starttime: 1}], tasks_from: update}
# The converge persisted the ubuntu_lxc list and cleaned /etc/sysctl.conf. The rest runs the task files directly: persisting a shorter list
# without /etc/sysctl.conf, then the runtime apply against the container's read-only /proc/sys.
- name: The sysctl hardening is persisted in its own drop-in
hosts: all
gather_facts: false
vars:
system_baseline_system_type: ubuntu_lxc
tasks:
- name: Read the drop-in and /etc/sysctl.conf
ansible.builtin.command:
argv: [cat, "{{ item }}"]
loop:
- /etc/sysctl.d/99-zz-system-baseline.conf
- /etc/sysctl.conf
register: system_baseline_verify_sysctl
changed_when: false
- name: The drop-in holds the profile's keys and only they left /etc/sysctl.conf
ansible.builtin.assert:
that:
- system_baseline_verify_sysctl.results[0].stdout_lines | reject('match', '#') | list == system_baseline_verify_sysctl_expected
- system_baseline_verify_sysctl.results[1].stdout_lines == ['# net.ipv4.tcp_syncookies=1', 'vm.max_map_count = 262144']
quiet: true
vars:
system_baseline_verify_sysctl_expected:
- net.ipv4.tcp_syncookies=1
- net.ipv4.conf.all.accept_source_route=0
- net.ipv4.conf.all.accept_redirects=0
- net.ipv4.conf.default.accept_redirects=0
- net.ipv4.conf.*.accept_redirects=0
- net.ipv4.conf.all.secure_redirects=0
- net.ipv4.conf.default.secure_redirects=0
- net.ipv6.conf.all.accept_redirects=0
- net.ipv6.conf.default.accept_redirects=0
- net.ipv6.conf.*.accept_redirects=0
- net.ipv4.icmp_echo_ignore_broadcasts=1
- net.ipv4.icmp_ignore_bogus_error_responses=1
- name: Remove /etc/sysctl.conf
ansible.builtin.file:
path: /etc/sysctl.conf
state: absent
- name: Persist a list that repeats one key
ansible.builtin.include_role:
name: mortis.kamino.system_baseline
tasks_from: sysctl
vars:
system_baseline_sysctl_hardening:
- { name: net.ipv4.tcp_syncookies, value: 0 }
- { name: net.ipv4.tcp_syncookies, value: "yes" }
- name: Read the drop-in again
ansible.builtin.command:
argv: [cat, /etc/sysctl.d/99-zz-system-baseline.conf]
register: system_baseline_verify_sysctl_short
changed_when: false
- name: Stat /etc/sysctl.conf
ansible.builtin.stat:
path: /etc/sysctl.conf
register: system_baseline_verify_sysctl_conf
- name: Only the last entry is left and /etc/sysctl.conf was not created
ansible.builtin.assert:
that:
- system_baseline_verify_sysctl_short.stdout_lines | reject('match', '#') | list == ['net.ipv4.tcp_syncookies=1']
- not system_baseline_verify_sysctl_conf.stat.exists
quiet: true
- name: Read a live value
ansible.builtin.command:
argv: [cat, /proc/sys/net/ipv4/tcp_syncookies]
register: system_baseline_verify_sysctl_live
changed_when: false
- name: Apply the value the kernel already has
ansible.builtin.include_role:
name: mortis.kamino.system_baseline
tasks_from: sysctl_apply
vars:
system_baseline_sysctl_hardening:
- { name: net.ipv4.tcp_syncookies, value: "{{ system_baseline_verify_sysctl_live.stdout }}" }
- name: Nothing was applied
ansible.builtin.assert:
that: __system_baseline_sysctl_apply is not changed
quiet: true
- name: Preview a different value in check mode
check_mode: true
block:
- name: Include system_baseline, tasks_from sysctl_apply
ansible.builtin.include_role:
name: mortis.kamino.system_baseline
tasks_from: sysctl_apply
vars:
system_baseline_sysctl_hardening:
- { name: net.ipv4.tcp_syncookies, value: "{{ 1 - system_baseline_verify_sysctl_live.stdout | int }}" }
- name: The pending change is reported
ansible.builtin.assert:
that: __system_baseline_sysctl_apply is changed
quiet: true
- name: Apply a value that cannot be set
block:
- name: Include system_baseline, tasks_from sysctl_apply
ansible.builtin.include_role:
name: mortis.kamino.system_baseline
tasks_from: sysctl_apply
vars:
system_baseline_sysctl_hardening:
- { name: net.ipv4.tcp_syncookies, value: "{{ 1 - system_baseline_verify_sysctl_live.stdout | int }}" }
- name: Unreachable when a refused value fails
ansible.builtin.fail:
msg: system_baseline ignored a sysctl that could not be set
rescue:
- name: The refused write stopped the play
ansible.builtin.assert:
that: ansible_failed_task.name is search('Apply the sysctl hardening settings')
quiet: true
# The container can inherit the runner host's values. The interfaces share the value of `default`; `all` has its own.
- name: Read the live arp_accept values
ansible.builtin.command:
argv: [cat, /proc/sys/net/ipv4/conf/all/arp_accept, /proc/sys/net/ipv4/conf/default/arp_accept]
register: system_baseline_verify_sysctl_arp
changed_when: false
- name: Apply a wildcard value that every interface already has
ansible.builtin.include_role:
name: mortis.kamino.system_baseline
tasks_from: sysctl_apply
vars:
system_baseline_sysctl_hardening:
- { name: net.ipv4.conf.all.arp_accept, value: "{{ system_baseline_verify_sysctl_arp.stdout_lines[0] }}" }
- { name: "net.ipv4.conf.*.arp_accept", value: "{{ system_baseline_verify_sysctl_arp.stdout_lines[1] }}" }
- name: No interface was changed
ansible.builtin.assert:
that: __system_baseline_sysctl_wildcard_apply is not changed
quiet: true
- name: Preview a different wildcard value in check mode
check_mode: true
block:
- name: Include system_baseline, tasks_from sysctl_apply
ansible.builtin.include_role:
name: mortis.kamino.system_baseline
tasks_from: sysctl_apply
vars:
system_baseline_sysctl_hardening:
- { name: net.ipv4.conf.all.arp_accept, value: "{{ system_baseline_verify_sysctl_arp.stdout_lines[0] }}" }
- { name: "net.ipv4.conf.*.arp_accept", value: "{{ (system_baseline_verify_sysctl_arp.stdout_lines[1] == '0') | ternary(1, 0) }}" }
- name: The pending change covers the interfaces and not the key with its own entry
ansible.builtin.assert:
that:
- __system_baseline_sysctl_wildcard_apply is changed
- system_baseline_verify_sysctl_cmd is search('net.ipv4.conf.lo.arp_accept=')
- system_baseline_verify_sysctl_cmd is not search('net.ipv4.conf.all.arp_accept=')
quiet: true
vars:
system_baseline_verify_sysctl_cmd: "{{ __system_baseline_sysctl_wildcard_apply.results[0].cmd | join(' ') }}"
- name: Apply a wildcard value that cannot be set
block:
- name: Include system_baseline, tasks_from sysctl_apply
ansible.builtin.include_role:
name: mortis.kamino.system_baseline
tasks_from: sysctl_apply
vars:
system_baseline_sysctl_hardening:
- { name: "net.ipv4.conf.*.arp_accept", value: "{{ (system_baseline_verify_sysctl_arp.stdout_lines[1] == '0') | ternary(1, 0) }}" }
- name: Unreachable when a refused wildcard value fails
ansible.builtin.fail:
msg: system_baseline ignored a sysctl wildcard that could not be set
rescue:
- name: The refused wildcard write stopped the play
ansible.builtin.assert:
that: ansible_failed_task.name is search('Apply the sysctl wildcards')
quiet: true
- name: Apply a wildcard that matches no key
block:
- name: Include system_baseline, tasks_from sysctl_apply
ansible.builtin.include_role:
name: mortis.kamino.system_baseline
tasks_from: sysctl_apply
vars:
system_baseline_sysctl_hardening:
- { name: "net.ipv4.conf.*.accept_redirect", value: 0 }
- name: Unreachable when a wildcard without a match fails
ansible.builtin.fail:
msg: system_baseline ignored a sysctl wildcard that matches no key
rescue:
- name: The wildcard without a match stopped the play
ansible.builtin.assert:
that: ansible_failed_task.name is search('Read the live values a wildcard matches')
quiet: true
# An empty system_baseline_journal_max_use leaves journald alone: with the drop-in gone, the role neither writes it again nor restarts # An empty system_baseline_journal_max_use leaves journald alone: with the drop-in gone, the role neither writes it again nor restarts
# systemd-journald. It runs last, because it applies the role with its defaults (the converge's tmux autostart and apt-daily timeout are # systemd-journald. It runs last, because it applies the role with its defaults (the converge's tmux autostart and apt-daily timeout are
# not set here) and the checks above read what the converge wrote. # not set here) and the checks above read what the converge wrote.
+1 -6
View File
@@ -38,12 +38,7 @@
when: system_baseline_apt_daily_timeout | length > 0 when: system_baseline_apt_daily_timeout | length > 0
tags: apt-daily-timeout tags: apt-daily-timeout
# Applied first, so a value the kernel refuses stops the run before it is persisted. molecule's containers have a read-only /proc/sys. - name: Harden sysctl
- name: Apply the sysctl hardening
ansible.builtin.import_tasks: sysctl_apply.yml
tags: [sysctl, molecule-notest]
- name: Persist the sysctl hardening
ansible.builtin.import_tasks: sysctl.yml ansible.builtin.import_tasks: sysctl.yml
tags: sysctl tags: sysctl
+7 -17
View File
@@ -1,19 +1,9 @@
--- ---
# Values persist in the role's own drop-in: systemd-sysctl does not read /etc/sysctl.conf on every supported release. - name: Apply sysctl hardening settings
- name: Persist the sysctl hardening settings ansible.posix.sysctl:
ansible.builtin.template: name: "{{ item.name }}"
src: sysctl.conf.j2 value: "{{ item.value }}"
dest: "{{ system_baseline_sysctl_file }}" sysctl_set: true
owner: root reload: true
group: root loop: "{{ system_baseline_sysctl_hardening }}"
mode: "0644"
become: true
# Not ansible.posix.sysctl, which rewrites every other line of the file. A missing file is left missing.
- name: Remove the role's keys from /etc/sysctl.conf
ansible.builtin.lineinfile:
path: /etc/sysctl.conf
regexp: '^\s*{{ item | regex_escape }}\s*='
state: absent
loop: "{{ __system_baseline_sysctl.keys() | list }}"
become: true become: true
@@ -1,73 +0,0 @@
---
# Not ansible.posix.sysctl, which always manages a file too. The absolute path is for a PATH without the sbin directories.
# A key that cannot be read (unknown or write-only) counts as different, so the write below decides.
- name: Read the live sysctl values
ansible.builtin.command:
argv: [/usr/sbin/sysctl, -e, -n, "{{ item.key }}"]
loop: "{{ __system_baseline_sysctl | dict2items | rejectattr('key', 'search', '[*]') }}"
register: __system_baseline_sysctl_live
changed_when: false
failed_when: false
check_mode: false
become: true
# The directory is missing when the kernel runs without IPv6; a mistyped IPv6 key still fails when it exists.
- name: Check that the kernel has IPv6
ansible.builtin.stat:
path: /proc/sys/net/ipv6/conf
register: __system_baseline_sysctl_ipv6
# `removes` names a path that always exists: with it, check mode reports the pending write as changed instead of skipping the command.
# sysctl exits 0 for a read-only key and only warns (`setting key ...`), so stderr counts too.
- name: Apply the sysctl hardening settings
ansible.builtin.command:
argv: [/usr/sbin/sysctl, -w, "{{ item.item.key }}={{ item.item.value }}"]
removes: /proc/sys
environment:
LC_ALL: C
loop: "{{ __system_baseline_sysctl_live.results }}"
loop_control:
label: "{{ item.item.key }}={{ item.item.value }}"
when:
- item.stdout | default('') | split != item.item.value | split
- __system_baseline_sysctl_ipv6.stat.exists or item.item.key is not match('net[.]ipv6[.]')
register: __system_baseline_sysctl_apply
failed_when: >-
__system_baseline_sysctl_apply.rc | default(0) != 0
or __system_baseline_sysctl_apply.stderr | default('') is search('setting key')
become: true
# After the plain keys: an interface created from here on inherits the new `default`. A wildcard without a match is a typo, as
# an unknown plain key is, unless the kernel has no IPv6. sysctl exits 0 when an interface disappears while it lists them.
- name: Read the live values a wildcard matches
ansible.builtin.command:
argv: [/usr/sbin/sysctl, -a, -e, -r, "^{{ item.key | replace('.', '[.]') | replace('*', '[^.]*') }}$"]
loop: "{{ __system_baseline_sysctl | dict2items | selectattr('key', 'search', '[*]') }}"
register: __system_baseline_sysctl_wildcard
changed_when: false
failed_when: >-
__system_baseline_sysctl_wildcard.rc != 0
or (__system_baseline_sysctl_wildcard.stdout | length == 0
and (__system_baseline_sysctl_ipv6.stat.exists or item.key is not match('net[.]ipv6[.]')))
check_mode: false
become: true
# A key with its own entry keeps that value, as at boot. -e skips an interface that is gone, unless it goes during the write itself.
- name: Apply the sysctl wildcards
ansible.builtin.command:
argv: "{{ ['/usr/sbin/sysctl', '-e', '-w'] + (__system_baseline_sysctl_pending | product([item.item.value]) | map('join', '=')) }}"
removes: /proc/sys
environment:
LC_ALL: C
vars:
__system_baseline_sysctl_pending: >-
{{ item.stdout_lines | reject('search', ' = ' ~ (item.item.value | regex_escape) ~ '$')
| map('regex_replace', ' = .*', '') | difference(__system_baseline_sysctl.keys() | list) }}
loop: "{{ __system_baseline_sysctl_wildcard.results }}"
loop_control:
label: "{{ item.item.key }}={{ item.item.value }}"
when: __system_baseline_sysctl_pending | length > 0
register: __system_baseline_sysctl_wildcard_apply
failed_when: >-
__system_baseline_sysctl_wildcard_apply.stderr_lines | default([]) | reject('search', 'No such file or directory') | length > 0
become: true
-12
View File
@@ -62,18 +62,6 @@
quiet: true quiet: true
tags: always tags: always
# The role owns the whole file, and systemd-sysctl reads only *.conf. 99-sysctl.conf can be the distribution's link to /etc/sysctl.conf.
- name: Validate the sysctl drop-in path
ansible.builtin.assert:
that:
- system_baseline_sysctl_file is match('^/etc/sysctl\.d/[A-Za-z0-9_][A-Za-z0-9._-]*\.conf\Z')
- system_baseline_sysctl_file != '/etc/sysctl.d/99-sysctl.conf'
fail_msg: >-
system_baseline_sysctl_file must be a .conf file directly under /etc/sysctl.d (letters, digits, . _ and - in the name), other than
99-sysctl.conf.
quiet: true
tags: always
# The value is written into a unit file: one line, starting with a digit, so no line break can add a second directive. systemd itself # The value is written into a unit file: one line, starting with a digit, so no line break can add a second directive. systemd itself
# refuses a value it cannot parse (it ignores the setting and logs it). # refuses a value it cannot parse (it ignores the setting and logs it).
- name: Validate the apt-daily start timeout - name: Validate the apt-daily start timeout
@@ -1,4 +0,0 @@
# Managed by Ansible (mortis.kamino.system_baseline, tasks/sysctl.yml). Do not edit: the next run overwrites it.
{% for name, value in __system_baseline_sysctl.items() %}
{{ name }}={{ value }}
{% endfor %}
+1 -1
View File
@@ -45,7 +45,7 @@ There is no discovery by variable name, and a variable that looks like one fails
### `service_rules` ### `service_rules`
A service role that owns firewall rules calls the role with `include_role` and `tasks_from: service_rules` after the main entry has run, with `apply: {tags: [...]}` so `--tags <role>` reaches these tasks. The entry point installs nothing and touches no default policy, no `before.rules` and no base rule. Outside check mode (`--check` or the `check_mode` keyword; the role detects it with a probe command that does not run there, not `ansible_check_mode`) it fails when ufw is not installed and active. In check mode it skips the reconcile only when `ufw status` fails (ufw not installed yet, the main entry may not have reached the host); a host with ufw installed but inactive is reconciled as usual. A service role that owns firewall rules calls the role with `include_role` and `tasks_from: service_rules` after the main entry has run, with `apply: {tags: [...]}` so `--tags <role>` reaches these tasks. The entry point installs nothing and touches no default policy, no `before.rules` and no base rule. Outside check mode (`--check` or the `check_mode` keyword; the role detects it with a skipped probe task, not `ansible_check_mode`) it fails when ufw is not installed and active. In check mode it skips the reconcile only when `ufw status` fails (ufw not installed yet, the main entry may not have reached the host); a host with ufw installed but inactive is reconciled as usual.
| Variable | Default | Required | Description | | Variable | Default | Required | Description |
|---|---|---|---| |---|---|---|---|
+1 -1
View File
@@ -68,7 +68,7 @@
# svc_o2 that looks like the SSH rule, and a rule of svc_m. The managed owners below are # svc_o2 that looks like the SSH rule, and a rule of svc_m. The managed owners below are
# the ones used above plus svc_m (listed but never called), so svc_o1 and svc_o2 are # the ones used above plus svc_m (listed but never called), so svc_o1 and svc_o2 are
# orphans. The cases that must change nothing run first and the purge last, so the # orphans. The cases that must change nothing run first and the purge last, so the
# idempotence run finds nothing left to delete. Under --check the role's own check-mode probe # idempotence run finds nothing left to delete. Under --check the role's own skipped probe
# keeps the purge from deleting, and orphan_check.yml skips its counts. # keeps the purge from deleting, and orphan_check.yml skips its counts.
- name: Report and purge the rules of unmanaged owners - name: Report and purge the rules of unmanaged owners
hosts: all hosts: all
+2 -2
View File
@@ -474,8 +474,8 @@
# apply of community.general.ufw reports changed for the would-be rule, so molecule's # apply of community.general.ufw reports changed for the would-be rule, so molecule's
# idempotence run (a second converge) would fail on it. Verify runs once, outside that count. # idempotence run (a second converge) would fail on it. Verify runs once, outside that count.
# The play runs under the check_mode keyword, which does not set ansible_check_mode in the # The play runs under the check_mode keyword, which does not set ansible_check_mode in the
# included role; the role detects check mode with a probe task instead (a command does # included role; the role detects check mode with a probe task instead (a command task is
# not run under the keyword). A present call that would add a rule and an absent call for an # skipped under the keyword). A present call that would add a rule and an absent call for an
# owner that holds rules must change nothing. The two reads of the rule list are forced to # owner that holds rules must change nothing. The two reads of the rule list are forced to
# run (check_mode: false) and compared as a whole. # run (check_mode: false) and compared as a whole.
- name: Check mode of service_rules changes nothing - name: Check mode of service_rules changes nothing
+4 -4
View File
@@ -6,10 +6,10 @@
state: present state: present
register: __ufw_install register: __ufw_install
# Not ansible_check_mode, which the play-level `check_mode: true` keyword does not set in include_role # ansible_check_mode is not used: the play-level `check_mode: true` keyword does not set it inside
# tasks, nor `is skipped`, which ansible-core 2.25 drops: the probe's stdout is empty in check mode. # include_role tasks. A command task is skipped in both forms, the same probe as tasks/sysctl.yml.
- name: Probe whether the run is in check mode - name: Probe whether the run is in check mode
ansible.builtin.command: echo ran ansible.builtin.command: "true"
register: __ufw_install_probe register: __ufw_install_probe
changed_when: false changed_when: false
@@ -17,4 +17,4 @@
# Undefined when this file's tags are skipped; the guards then default it to true. # Undefined when this file's tags are skipped; the guards then default it to true.
- name: Remember whether ufw can be configured - name: Remember whether ufw can be configured
ansible.builtin.set_fact: ansible.builtin.set_fact:
__ufw_can_configure: "{{ __ufw_install is not changed or __ufw_install_probe.stdout == 'ran' }}" __ufw_can_configure: "{{ __ufw_install is not changed or __ufw_install_probe is not skipped }}"
+5 -4
View File
@@ -63,16 +63,17 @@
the rule tags): {{ ufw_managed_owners }} the rule tags): {{ ufw_managed_owners }}
quiet: true quiet: true
# Not ansible_check_mode, which the play-level `check_mode: true` keyword does not set in include_role # ansible_check_mode is not used: the play-level `check_mode: true` keyword does not set
# tasks, nor `is skipped`, which ansible-core 2.25 drops: the probe's stdout is empty in check mode. # that magic variable inside include_role tasks (only --check does). A command task is
# skipped in both forms and its result says so, which is the one signal that holds for both.
- name: Probe whether the run is in check mode - name: Probe whether the run is in check mode
ansible.builtin.command: echo ran ansible.builtin.command: "true"
register: ufw_oa_probe register: ufw_oa_probe
changed_when: false changed_when: false
- name: Remember whether the run is in check mode - name: Remember whether the run is in check mode
ansible.builtin.set_fact: ansible.builtin.set_fact:
ufw_oa_check: "{{ ufw_oa_probe.stdout != 'ran' }}" ufw_oa_check: "{{ ufw_oa_probe is skipped }}"
- name: Read the firewall status - name: Read the firewall status
become: true become: true
+5 -4
View File
@@ -121,16 +121,17 @@
- ufw_manage_rules - ufw_manage_rules
tags: [ufw, ufw_service_rules] tags: [ufw, ufw_service_rules]
block: block:
# Not ansible_check_mode, which the play-level `check_mode: true` keyword does not set in include_role # ansible_check_mode is not used: the play-level `check_mode: true` keyword does not set
# tasks, nor `is skipped`, which ansible-core 2.25 drops: the probe's stdout is empty in check mode. # that magic variable inside include_role tasks (only --check does). A command task is
# skipped in both forms and its result says so, which is the one signal that holds for both.
- name: Probe whether the run is in check mode - name: Probe whether the run is in check mode
ansible.builtin.command: echo ran ansible.builtin.command: "true"
register: ufw_sr_probe register: ufw_sr_probe
changed_when: false changed_when: false
- name: Remember whether the run is in check mode - name: Remember whether the run is in check mode
ansible.builtin.set_fact: ansible.builtin.set_fact:
ufw_sr_check: "{{ ufw_sr_probe.stdout != 'ran' }}" ufw_sr_check: "{{ ufw_sr_probe is skipped }}"
- name: Read the firewall status - name: Read the firewall status
become: true become: true
+5 -4
View File
@@ -7,17 +7,18 @@
check_mode: false check_mode: false
when: ufw_enabled and ufw_sysctl_overrides | length > 0 when: ufw_enabled and ufw_sysctl_overrides | length > 0
# Not ansible_check_mode, which the play-level `check_mode: true` keyword does not set in include_role # ansible_check_mode is not used: the play-level `check_mode: true` keyword does not set that
# tasks, nor `is skipped`, which ansible-core 2.25 drops: the probe's stdout is empty in check mode. # magic variable inside include_role tasks (only --check does). A command task
# is skipped in both forms and its result says so, the same probe as tasks/service_rules.yml.
- name: Probe whether the run is in check mode - name: Probe whether the run is in check mode
ansible.builtin.command: echo ran ansible.builtin.command: "true"
register: ufw_sysctl_probe register: ufw_sysctl_probe
changed_when: false changed_when: false
when: ufw_enabled and ufw_sysctl_overrides | length > 0 when: ufw_enabled and ufw_sysctl_overrides | length > 0
- name: Remember whether the run is in check mode - name: Remember whether the run is in check mode
ansible.builtin.set_fact: ansible.builtin.set_fact:
ufw_sysctl_check: "{{ ufw_sysctl_probe.stdout != 'ran' }}" ufw_sysctl_check: "{{ ufw_sysctl_probe is skipped }}"
when: ufw_enabled and ufw_sysctl_overrides | length > 0 when: ufw_enabled and ufw_sysctl_overrides | length > 0
# In check mode on a fresh host ufw is not installed yet, so the file is absent. # In check mode on a fresh host ufw is not installed yet, so the file is absent.
+4 -16
View File
@@ -70,18 +70,9 @@ USER_AGENT = "kamino-next-image-version"
class RegistryError(Exception): class RegistryError(Exception):
def __init__(self, url, status, text, challenge="", codes=()): def __init__(self, url, status, text, challenge=""):
super().__init__(f"GET {url}: HTTP {status}: {text}") super().__init__(f"GET {url}: HTTP {status}: {text}")
self.status, self.challenge, self.codes = status, challenge, codes self.status, self.challenge = status, challenge
def _error_codes(raw):
"""The OCI error codes of an error body (`{"errors": [{"code": ...}]}`), or () for any other body."""
try:
errors = json.loads(raw).get("errors") or []
return tuple(e.get("code") for e in errors if isinstance(e, dict))
except (ValueError, AttributeError, TypeError):
return ()
def _readable(raw): def _readable(raw):
@@ -101,9 +92,7 @@ def _fetch(url, headers):
except urllib.error.HTTPError as exc: except urllib.error.HTTPError as exc:
raw = exc.read(20000).decode("utf-8", errors="replace") raw = exc.read(20000).decode("utf-8", errors="replace")
challenge = exc.headers.get("WWW-Authenticate", "") challenge = exc.headers.get("WWW-Authenticate", "")
raise RegistryError( raise RegistryError(url, exc.code, _readable(raw), challenge) from exc
url, exc.code, _readable(raw), challenge, _error_codes(raw)
) from exc
class Registry: class Registry:
@@ -150,8 +139,7 @@ class Registry:
body, headers = self._get(path) body, headers = self._get(path)
except RegistryError as exc: except RegistryError as exc:
# A repository not pushed yet is 404 NAME_UNKNOWN (OCI distribution spec): no tags. # A repository not pushed yet is 404 NAME_UNKNOWN (OCI distribution spec): no tags.
# Any other 404, such as a wrong registry path, must fail rather than restart at .0. if exc.status == 404 and not tags:
if exc.status == 404 and "NAME_UNKNOWN" in exc.codes and not tags:
return [] return []
raise raise
tags += body.get("tags") or [] tags += body.get("tags") or []
@@ -7,7 +7,7 @@
# writable for the runner user) and put them first, then check that the scenarios on stdin load this # writable for the runner user) and put them first, then check that the scenarios on stdin load this
# checkout and run them. CI_BASE_PYTHON is a test seam. # checkout and run them. CI_BASE_PYTHON is a test seam.
# #
# AC_ROOT=<dir holding ansible_collections> scripts/run_molecule_in_controller.sh < scenario-dirs # AC_ROOT=<dir holding ansible_collections> scripts/run_molecule_in_ci_image.sh < scenario-dirs
set -euo pipefail set -euo pipefail
selected="$(cat)" selected="$(cat)"
+2 -3
View File
@@ -511,12 +511,11 @@ class PureTest(unittest.TestCase):
) )
self.assertEqual(civ.dockerfile_labels('FROM c\nLABEL a="unbalanced\n'), {}) self.assertEqual(civ.dockerfile_labels('FROM c\nLABEL a="unbalanced\n'), {})
def test_the_molecule_collections_are_not_an_input_of_the_ci_image(self): def test_the_molecule_collections_are_an_input_of_the_ci_image(self):
# Lint uses no collection of them, so their bump must not publish a ci version.
root = pathlib.Path(__file__).resolve().parents[2] root = pathlib.Path(__file__).resolve().parents[2]
entry = civ.matrix_of((root / civ.MATRIX_FILE).read_text())["ci"] entry = civ.matrix_of((root / civ.MATRIX_FILE).read_text())["ci"]
files = civ.inputs_of(entry, (root / entry["dockerfile"]).read_text())[1] files = civ.inputs_of(entry, (root / entry["dockerfile"]).read_text())[1]
self.assertNotIn("extensions/molecule/requirements.yml", files) self.assertIn("extensions/molecule/requirements.yml", files)
def test_the_controller_pins_are_inputs_of_the_controller_image(self): def test_the_controller_pins_are_inputs_of_the_controller_image(self):
root = pathlib.Path(__file__).resolve().parents[2] root = pathlib.Path(__file__).resolve().parents[2]
-15
View File
@@ -105,7 +105,6 @@ class FakeRegistry(http.server.BaseHTTPRequestHandler):
no_realm = False no_realm = False
empty_token = False empty_token = False
unknown = False # the repository does not exist yet unknown = False # the repository does not exist yet
not_found = None # a 404 body without NAME_UNKNOWN
agents = None # a fresh list per test, set in setUp agents = None # a fresh list per test, set in setUp
def do_GET(self): def do_GET(self):
@@ -129,8 +128,6 @@ class FakeRegistry(http.server.BaseHTTPRequestHandler):
b"{}", b"{}",
extra={"WWW-Authenticate": f'Bearer realm="{realm}",service="reg"'}, extra={"WWW-Authenticate": f'Bearer realm="{realm}",service="reg"'},
) )
elif self.not_found is not None:
self.reply(404, self.not_found, "text/plain")
elif self.unknown: elif self.unknown:
body = {"errors": [{"code": "NAME_UNKNOWN", "message": "unknown"}]} body = {"errors": [{"code": "NAME_UNKNOWN", "message": "unknown"}]}
self.reply(404, json.dumps(body).encode()) self.reply(404, json.dumps(body).encode())
@@ -158,7 +155,6 @@ class RegistryClient(unittest.TestCase):
def setUp(self): def setUp(self):
FakeRegistry.refuse = FakeRegistry.refuse_token = FakeRegistry.no_realm = False FakeRegistry.refuse = FakeRegistry.refuse_token = FakeRegistry.no_realm = False
FakeRegistry.empty_token = FakeRegistry.unknown = False FakeRegistry.empty_token = FakeRegistry.unknown = False
FakeRegistry.not_found = None
FakeRegistry.agents = [] FakeRegistry.agents = []
server = QuietServer(("127.0.0.1", 0), FakeRegistry) server = QuietServer(("127.0.0.1", 0), FakeRegistry)
threading.Thread(target=server.serve_forever, daemon=True).start() threading.Thread(target=server.serve_forever, daemon=True).start()
@@ -180,17 +176,6 @@ class RegistryClient(unittest.TestCase):
niv.next_version("0.1", self.registry.tags(), "c", no_label), "0.1.0" niv.next_version("0.1", self.registry.tags(), "c", no_label), "0.1.0"
) )
def test_a_404_without_name_unknown_is_a_registry_error(self):
for body in (
b"404 page not found",
b'{"errors":[{"code":"NOT_FOUND","message":"no such route"}]}',
):
with self.subTest(body=body):
FakeRegistry.not_found = body
with self.assertRaises(niv.RegistryError) as caught:
self.registry.tags()
self.assertEqual(caught.exception.status, 404)
def test_a_missing_manifest_is_still_a_registry_error(self): def test_a_missing_manifest_is_still_a_registry_error(self):
FakeRegistry.unknown = True FakeRegistry.unknown = True
with self.assertRaises(niv.RegistryError) as caught: with self.assertRaises(niv.RegistryError) as caught:
@@ -1,6 +1,6 @@
# SPDX-FileCopyrightText: Defame1297 and contributors # SPDX-FileCopyrightText: Defame1297 and contributors
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
"""Tests for scripts/run_molecule_in_controller.sh with stub tools in place of the molecule-controller """Tests for scripts/run_molecule_in_ci_image.sh with stub tools in place of the molecule-controller
image's. image's.
Run with: python3 -m unittest discover -s tests/scripts Run with: python3 -m unittest discover -s tests/scripts
@@ -14,7 +14,7 @@ import tempfile
import unittest import unittest
REPO = pathlib.Path(__file__).resolve().parents[2] REPO = pathlib.Path(__file__).resolve().parents[2]
SCRIPT = REPO / "scripts" / "run_molecule_in_controller.sh" SCRIPT = REPO / "scripts" / "run_molecule_in_ci_image.sh"
# Each stub appends its name, arguments and the paths it saw to STUB_LOG; STUB_FAIL_<name> fails it. # Each stub appends its name, arguments and the paths it saw to STUB_LOG; STUB_FAIL_<name> fails it.
STUB = """#!/usr/bin/env bash STUB = """#!/usr/bin/env bash
@@ -50,7 +50,7 @@ echo "runner args=$* path=$PATH acp=$ANSIBLE_COLLECTIONS_PATH" \\
@unittest.skipUnless(shutil.which("bash"), "bash is required") @unittest.skipUnless(shutil.which("bash"), "bash is required")
class RunMoleculeInControllerTest(unittest.TestCase): class RunMoleculeInCiImageTest(unittest.TestCase):
def setUp(self): def setUp(self):
self.tmp = pathlib.Path(tempfile.mkdtemp(prefix="kamino-runci-")).resolve() self.tmp = pathlib.Path(tempfile.mkdtemp(prefix="kamino-runci-")).resolve()
self.addCleanup(shutil.rmtree, self.tmp, True) self.addCleanup(shutil.rmtree, self.tmp, True)
+3 -121
View File
@@ -355,7 +355,7 @@ class RunMoleculeScenariosTest(unittest.TestCase):
def test_the_default_time_limit_is_inside_the_job_timeout(self): def test_the_default_time_limit_is_inside_the_job_timeout(self):
# a limit past the job's own would let a hang take the job and every log with it # a limit past the job's own would let a hang take the job and every log with it
timeout = yaml.safe_load(WORKFLOW.read_text())["jobs"]["scenarios"][ timeout = yaml.safe_load(WORKFLOW.read_text())["jobs"]["molecule"][
"timeout-minutes" "timeout-minutes"
] ]
limit = re.findall(r"MOLECULE_SCENARIO_TIMEOUT:-(\d+)\}", SCRIPT.read_text()) limit = re.findall(r"MOLECULE_SCENARIO_TIMEOUT:-(\d+)\}", SCRIPT.read_text())
@@ -502,7 +502,7 @@ class ScenarioPlatformsTest(unittest.TestCase):
def test_the_sweep_spares_containers_younger_than_the_job_timeout(self): def test_the_sweep_spares_containers_younger_than_the_job_timeout(self):
# a shorter bound would remove the containers of a run still going # a shorter bound would remove the containers of a run still going
timeout = yaml.safe_load(WORKFLOW.read_text())["jobs"]["scenarios"][ timeout = yaml.safe_load(WORKFLOW.read_text())["jobs"]["molecule"][
"timeout-minutes" "timeout-minutes"
] ]
run = step_run("Remove the containers earlier runs left") run = step_run("Remove the containers earlier runs left")
@@ -519,130 +519,12 @@ class LanesInputTest(unittest.TestCase):
# yaml reads the `on:` key as True # yaml reads the `on:` key as True
lanes = workflow[True]["workflow_dispatch"]["inputs"]["lanes"] lanes = workflow[True]["workflow_dispatch"]["inputs"]["lanes"]
self.assertEqual((lanes["type"], lanes["default"]), ("string", "")) self.assertEqual((lanes["type"], lanes["default"]), ("string", ""))
steps = workflow["jobs"]["scenarios"]["steps"] steps = workflow["jobs"]["molecule"]["steps"]
step = next(s for s in steps if s.get("name") == "Run the scenarios") step = next(s for s in steps if s.get("name") == "Run the scenarios")
self.assertEqual(step["env"]["MOLECULE_LANES"], "${{ inputs.lanes }}") self.assertEqual(step["env"]["MOLECULE_LANES"], "${{ inputs.lanes }}")
self.assertRegex(step["run"], r"docker run [^<]*-e MOLECULE_LANES\b") self.assertRegex(step["run"], r"docker run [^<]*-e MOLECULE_LANES\b")
class WorkflowJobsTest(unittest.TestCase):
"""A pull request that selects no scenario takes no Molecule runner slot."""
JOBS = yaml.safe_load(WORKFLOW.read_text())["jobs"]
def result(self, select, scenarios, selected):
"""The exit code of the result job's check for those needs results and that selection."""
(step,) = self.JOBS["result"]["steps"]
env = dict(
os.environ,
SELECT_RESULT=select,
SCENARIOS_RESULT=scenarios,
SELECTED=selected,
)
return subprocess.run(
# act runs a job container's step with sh when the step sets no shell
["sh", "-e", "-c", step["run"]],
check=False,
env=env,
capture_output=True,
).returncode
def written_output(self, selected):
"""The `scenarios` output select's run step writes for that selector output."""
step = next(s for s in self.JOBS["select"]["steps"] if s.get("id") == "select")
block = step["run"].split("|| exit 1\n", 1)[1]
with tempfile.TemporaryDirectory() as tmp:
out = pathlib.Path(tmp, "output")
subprocess.run(
["sh", "-e", "-c", 'selected="$1"\n' + block, "sh", selected],
check=True,
env=dict(os.environ, GITHUB_OUTPUT=str(out)),
)
lines = out.read_text().splitlines()
# GITHUB_OUTPUT's `name<<delimiter` form: the value is every line up to the delimiter
name, delim = lines[0].split("<<", 1)
self.assertEqual((name, lines[-1]), ("scenarios", delim))
self.assertNotIn(delim, lines[1:-1])
return "\n".join(lines[1:-1])
def test_select_writes_none_for_an_empty_selection(self):
self.assertEqual(self.written_output(""), "none")
def test_select_writes_the_selection_one_directory_per_line(self):
selected = "extensions/molecule/image-smoke\nroles/a/molecule/default"
self.assertEqual(self.written_output(selected), selected)
def test_three_jobs_each_on_its_runner(self):
self.assertEqual(
{name: job["runs-on"] for name, job in self.JOBS.items()},
{
"select": "kamino-docker",
"scenarios": ["kamino-molecule"],
"result": "kamino-docker",
},
)
def test_only_the_scenarios_job_runs_on_the_host(self):
# select and result need no Docker daemon, so they take no Molecule runner slot
self.assertIn("container", self.JOBS["select"])
self.assertIn("container", self.JOBS["result"])
self.assertNotIn("container", self.JOBS["scenarios"])
def test_every_job_has_the_fork_guard(self):
guard = (
"github.repository == 'mortis/kamino' && "
"(github.event_name != 'pull_request' || "
"github.event.pull_request.head.repo.full_name == github.repository)"
)
self.assertEqual(self.JOBS["select"]["if"], guard)
for name, job in self.JOBS.items():
self.assertTrue(job["if"].endswith(guard), name)
def test_the_scenarios_run_only_for_a_selection(self):
job = self.JOBS["scenarios"]
self.assertEqual(job["needs"], "select")
# false for `none` and for an empty or missing output alike
self.assertTrue(
job["if"].startswith(
"needs.select.outputs.scenarios != 'none' && "
"needs.select.outputs.scenarios != '' &&"
)
)
self.assertEqual(
self.JOBS["select"]["outputs"]["scenarios"],
"${{ steps.select.outputs.scenarios }}",
)
step = next(s for s in job["steps"] if s.get("name") == "Run the scenarios")
self.assertEqual(
step["env"]["SELECTED"], "${{ needs.select.outputs.scenarios }}"
)
self.assertIn('run_molecule_in_controller.sh <<< "$SELECTED"', step["run"])
def test_the_result_runs_whatever_the_others_ended_as(self):
job = self.JOBS["result"]
self.assertEqual(job["needs"], ["select", "scenarios"])
self.assertTrue(job["if"].startswith("always() &&"))
def test_the_result_passes_a_run_or_a_none_selection_only(self):
self.assertEqual(
self.result("success", "success", "roles/a/molecule/default"), 0
)
self.assertEqual(self.result("success", "skipped", "none"), 0)
# an empty output was lost, not an empty selection
self.assertNotEqual(self.result("success", "skipped", ""), 0)
self.assertNotEqual(
self.result("success", "skipped", "roles/a/molecule/default"), 0
)
self.assertNotEqual(
self.result("success", "failure", "roles/a/molecule/default"), 0
)
self.assertNotEqual(
self.result("success", "cancelled", "roles/a/molecule/default"), 0
)
self.assertNotEqual(self.result("failure", "skipped", "none"), 0)
self.assertNotEqual(self.result("skipped", "skipped", "none"), 0)
class ScenarioSequenceTest(unittest.TestCase): class ScenarioSequenceTest(unittest.TestCase):
"""A role scenario previews the fresh host and the configured host with molecule's check step.""" """A role scenario previews the fresh host and the configured host with molecule's check step."""
@@ -678,31 +678,13 @@ class WorkflowPinsTest(unittest.TestCase):
def test_the_workflow_has_each_pin_where_the_selector_looks(self): def test_the_workflow_has_each_pin_where_the_selector_looks(self):
for key in ("CONTROLLER_IMAGE", "MOLECULE_IMAGE", "MOLECULE_IMAGE_2604"): for key in ("CONTROLLER_IMAGE", "MOLECULE_IMAGE", "MOLECULE_IMAGE_2604"):
old, new = ( self.assertEqual(self.edited(self.pin(key), self.bumped(key)), {key}, key)
f"{key}: >-\n {v}" for v in (self.pin(key), self.bumped(key))
)
self.assertEqual(self.edited(old, new), {key}, key)
def test_the_workflow_runs_in_the_controller_image_not_ci(self): def test_the_workflow_runs_in_the_controller_image_not_ci(self):
# A ci pin bump must touch only Lint and Build, which IGNORED lists (ADR 0003). # A ci pin bump must touch only Lint and Build, which IGNORED lists (ADR 0003).
self.assertIn("/mortis/molecule-controller:", self.pin("CONTROLLER_IMAGE")) self.assertIn("/mortis/molecule-controller:", self.pin("CONTROLLER_IMAGE"))
self.assertNotIn("/mortis/ci:", self.WORKFLOW) self.assertNotIn("/mortis/ci:", self.WORKFLOW)
def test_every_controller_pin_is_the_same(self):
# container.image cannot read env, so the select and result jobs repeat CONTROLLER_IMAGE
jobs = yaml.safe_load(self.WORKFLOW)["jobs"]
pins = [
jobs["select"]["container"]["image"],
self.pin("CONTROLLER_IMAGE"),
jobs["result"]["container"]["image"],
]
self.assertEqual(len(set(pins)), 1, pins)
self.assertEqual(self.WORKFLOW.count("/mortis/molecule-controller:"), len(pins))
# Renovate moves all three, which the selector reads as "any other change": every
# scenario, as for CONTROLLER_IMAGE alone.
bumped = self.WORKFLOW.replace(pins[0], self.bumped("CONTROLLER_IMAGE"))
self.assertIsNone(sel.pin_changes(self.WORKFLOW, bumped))
def test_comments_and_blank_lines_change_nothing(self): def test_comments_and_blank_lines_change_nothing(self):
self.assertEqual(self.edited("# Behavioural tests", "# Other words"), set()) self.assertEqual(self.edited("# Behavioural tests", "# Other words"), set())
self.assertEqual(self.edited("\njobs:\n", "\n\n\njobs:\n"), set()) self.assertEqual(self.edited("\njobs:\n", "\n\n\njobs:\n"), set())