Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ab0ce421cc |
No files matched your search
@@ -28,7 +28,7 @@ jobs:
|
||||
timeout-minutes: 30
|
||||
# The ci image (images/ci, built by image.yml): tag for the release, digest enforced.
|
||||
container:
|
||||
image: git.rkdr.net/mortis/ci:0.2.48@sha256:d1c6653255abf366462c0265d9372626d5b59095084fe74ae95b9ebe7414007d
|
||||
image: git.rkdr.net/mortis/ci:0.2.46@sha256:a03015cc2177bdd6ef7f348f245a89f361893c7c64edc1264d9f9c1387d9defc
|
||||
env:
|
||||
PIP_DISABLE_PIP_VERSION_CHECK: "1"
|
||||
steps:
|
||||
|
||||
@@ -44,7 +44,7 @@ jobs:
|
||||
# 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.
|
||||
container:
|
||||
image: git.rkdr.net/mortis/ci:0.2.48@sha256:d1c6653255abf366462c0265d9372626d5b59095084fe74ae95b9ebe7414007d
|
||||
image: git.rkdr.net/mortis/ci:0.2.46@sha256:a03015cc2177bdd6ef7f348f245a89f361893c7c64edc1264d9f9c1387d9defc
|
||||
steps:
|
||||
# The container has no Node, so JavaScript actions such as actions/checkout
|
||||
# cannot run; clone with git and the job token.
|
||||
|
||||
@@ -31,7 +31,7 @@ jobs:
|
||||
# The tag says which release, the digest is what is enforced (bump both together
|
||||
# when image.yml publishes a new version).
|
||||
container:
|
||||
image: git.rkdr.net/mortis/ci:0.2.48@sha256:d1c6653255abf366462c0265d9372626d5b59095084fe74ae95b9ebe7414007d
|
||||
image: git.rkdr.net/mortis/ci:0.2.46@sha256:a03015cc2177bdd6ef7f348f245a89f361893c7c64edc1264d9f9c1387d9defc
|
||||
env:
|
||||
PIP_DISABLE_PIP_VERSION_CHECK: "1"
|
||||
PRE_COMMIT_HOME: /opt/pre-commit
|
||||
|
||||
@@ -53,7 +53,7 @@ jobs:
|
||||
env:
|
||||
# The tools and collections molecule runs with: the image Lint and Build use.
|
||||
CI_IMAGE: >-
|
||||
git.rkdr.net/mortis/ci:0.2.48@sha256:d1c6653255abf366462c0265d9372626d5b59095084fe74ae95b9ebe7414007d
|
||||
git.rkdr.net/mortis/ci:0.2.46@sha256:a03015cc2177bdd6ef7f348f245a89f361893c7c64edc1264d9f9c1387d9defc
|
||||
# Used by the scenarios as `image: ${MOLECULE_IMAGE}`; set it the same way to run
|
||||
# one locally.
|
||||
MOLECULE_IMAGE: >-
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
minor_changes:
|
||||
- >-
|
||||
traefik - New input ``traefik_release_url`` sets where the release archive and checksums are
|
||||
downloaded from, for a mirror (default: the GitHub releases, as before).
|
||||
@@ -12,7 +12,6 @@ and pin updates. The choice is hard to undo once every workflow pins an image.
|
||||
|
||||
- **We build our own images:** a `ci` image, and one Dockerfile per molecule image (one per Ubuntu
|
||||
release, and later the Debian 13 one).
|
||||
Molecule's controller image is added by [ADR 0003](0003-molecule-controller-image.md).
|
||||
- **The molecule images bake in everything except what a role installs itself.** The test
|
||||
fixtures a scenario's `prepare.yml` needs are baked in. Packages a role installs are still
|
||||
downloaded, because that install path is what the test exercises. A converge is not kept off
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
# 0003. Molecule runs in its own controller image, not the `ci` image
|
||||
|
||||
Status: accepted
|
||||
|
||||
## Context
|
||||
|
||||
[ADR 0002](0002-self-built-ci-and-molecule-images.md) built one `ci` image that bakes every CI
|
||||
tool, and Lint, Build and Molecule all pin it. A change to a tool only Lint uses (apm-cli,
|
||||
antsibull-changelog, a pre-commit hook environment) publishes a new `ci` version, and its pin
|
||||
pull request moves `CI_IMAGE` in `molecule.yml`. The scenario selector cannot tell what changed
|
||||
inside an image, so it runs every scenario. 9 of 18 `ci` pin pull requests over two weeks
|
||||
were Lint-only. Images are built only on push to `main`, so a bump and its pin never share a pull
|
||||
request.
|
||||
|
||||
## Decision
|
||||
|
||||
- **Molecule runs in a `molecule-controller` image**, separate from `ci`. It bakes only what
|
||||
Molecule needs: ansible-core, molecule, molecule-plugins, the Python packages of the Docker
|
||||
connection, and the collections of `requirements.yml` and
|
||||
`extensions/molecule/requirements.yml`.
|
||||
- **Its Python packages come from a requirements file and hash-pinned lock of its own.**
|
||||
- **`molecule.yml` pins it instead of `ci`**; Lint and Build keep `ci`.
|
||||
- **It follows ADR 0002 otherwise:** built by `image.yml`, versioned by CI, pinned by
|
||||
`<version>@sha256:<digest>`, moved by Renovate. This adds to ADR 0002's set of images; the
|
||||
rest of ADR 0002 stands.
|
||||
|
||||
## Reason
|
||||
|
||||
A `ci` pin pull request then touches only paths the selector ignores and runs no scenario. A
|
||||
`molecule-controller` pin pull request still runs every scenario, which is right: it changes
|
||||
Molecule's tools.
|
||||
|
||||
The cost: one more image and lock to maintain, its layers to estimate against the 100 MB limit,
|
||||
a hand-made first pin, and ansible-core pinned in two locks that must stay equal. A collection
|
||||
bump is an input of both images, so it publishes two versions and two pin pull requests.
|
||||
|
||||
The controller's requirements file and lock must not be on the selector's IGNORED list, so a
|
||||
bump of ansible-core or molecule there runs every scenario before it merges. Today
|
||||
`requirements-dev.txt` and `requirements-dev.lock` are on IGNORED, so such a bump selects no
|
||||
scenario unless it edits `meta/runtime.yml`; this decision does not change that list.
|
||||
|
||||
The implementation updates: `image.yml` (matrix, and its push `paths` unless the new files live
|
||||
under `images/`), `molecule.yml`,
|
||||
`scripts/run_molecule_in_ci_image.sh` (its pin comparison reads the `ci` image's checksums),
|
||||
`scripts/check_image_versions.py`, `scripts/check_bot_pr_diff.py` and
|
||||
`scripts/lock-requirements.sh` (they know only `requirements-dev.lock`), their tests, the
|
||||
`pip-compile` patterns in `renovate.json`, `images/AGENTS.md` (the consumer list, and "each
|
||||
molecule image is one Ubuntu release"), the Molecule rules in `.gitea/workflows/AGENTS.md`,
|
||||
`docs/images/` (a new page, and `ci.md`, which names Molecule as a consumer), the `ci`
|
||||
Dockerfile's description label, `docs/contributing/setup.md` if the clone's tools change, and the
|
||||
[Accepted risks](../../SECURITY.md#accepted-risks) entry "Pin bumps first behaviour-tested after
|
||||
they merge", which counts on the `ci` pin pull request running every scenario.
|
||||
|
||||
## Not done
|
||||
|
||||
- **The selector classifies the packages a lock change moves, to decide whether a `CI_IMAGE`
|
||||
bump matters:** a heuristic package list inside a script that judges pull requests.
|
||||
- **Status quo:** every Lint-only tool change keeps costing a full Molecule run.
|
||||
- **Grouping pin pull requests only:** adopted separately; it lowers the number of full runs
|
||||
but not the cause.
|
||||
@@ -15,23 +15,10 @@ trailers, are in [ai-assistance.md](ai-assistance.md).
|
||||
*Reason:* every change reaches `main` through the Lint and Build checks and a reviewer.
|
||||
*Held by:* control: branch protection on `main`.
|
||||
- **Do not push to someone else's branch or to a bot's branch; put your change in a pull request of
|
||||
your own.** Updating a branch from `main` with Gitea's update button is allowed under the next
|
||||
two rules.
|
||||
your own.** Updating a branch from `main` with Gitea's update button is allowed.
|
||||
*Reason:* a push changes a head its author already reviewed or scheduled to merge, and a hand-made
|
||||
commit on a `renovate/` branch makes Renovate stop rebasing it.
|
||||
*Held by:* aspirational.
|
||||
- **Update a pull request's branch from `main` only when it is next to merge: reviewed, green on its
|
||||
previous head, and the only branch being updated. After updating your own pull request, give it a
|
||||
scheduled merge; merge anyone else's as [reviewing.md](reviewing.md) says.**
|
||||
*Reason:* `main` blocks an outdated branch, so every update re-runs Lint, Build and Molecule, and
|
||||
a new head cancels the run in progress; an update made while another pull request merges first is
|
||||
wasted.
|
||||
*Held by:* aspirational.
|
||||
- **Never press the update button on a `renovate/` branch. When a Renovate pull request is next to
|
||||
merge and behind `main`, tick the rebase/retry checkbox in its description; Renovate rebases it at
|
||||
its next run.**
|
||||
*Reason:* the update button adds a hand-made commit, and Renovate stops rebasing that branch.
|
||||
*Held by:* aspirational.
|
||||
- **File an issue or open a pull request with the headings of the matching template in `.gitea/`,
|
||||
also when you file through the API, `tea` or an MCP server.**
|
||||
*Reason:* those routes skip the templates, and an agent's built-in body leaves out what review needs.
|
||||
|
||||
+9
-48
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"description": "Run by .gitea/workflows/renovate.yml on this repository's own runner. Policy: automerge minor and patch, majors by hand. Every bot pull request must pass scripts/check_bot_pr_diff.py (lint workflow), which allows only version, tag, digest and pin lines. Image versions are assigned by the Images workflow when an image's inputs change, so a bot pull request needs no version edit. Updates open on Mondays (UTC), so any Monday run can act; the own image pins and vulnerability fixes found on osv.dev open at any time. The weekly window and the groups bound the volume, so there is no hourly pull request limit. Vulnerability fixes skip the release-age wait, so they are never automerged: a person checks a fix that had no time to be pulled as a compromised release. Base-image bumps are manual: every Dockerfile is FROM ubuntu, grouped with the job containers.",
|
||||
"description": "Run by .gitea/workflows/renovate.yml on this repository's own runner. Policy: automerge minor and patch, majors by hand. Every bot pull request must pass scripts/check_bot_pr_diff.py (lint workflow), which allows only version, tag, digest and pin lines. Image versions are assigned by the Images workflow when an image's inputs change, so a bot pull request needs no version edit.",
|
||||
"extends": [
|
||||
"config:recommended",
|
||||
":enablePreCommit"
|
||||
@@ -19,7 +19,7 @@
|
||||
],
|
||||
"automerge": true,
|
||||
"automergeType": "pr",
|
||||
"prHourlyLimit": 0,
|
||||
"prHourlyLimit": 5,
|
||||
"minimumReleaseAge": "3 days",
|
||||
"minimumReleaseAgeBehaviour": "timestamp-optional",
|
||||
"timezone": "UTC",
|
||||
@@ -90,7 +90,7 @@
|
||||
],
|
||||
"packageRules": [
|
||||
{
|
||||
"description": "Dockerfile base-image tag and digest bumps (images/*/Dockerfile) MAY automerge. Kamino is the untrusted side and the bump pull request's own CI exercises the new image before the merge. Placed first so the major-version rule below still turns automerge off. The merge publishes a new image version. Today every Dockerfile is FROM ubuntu, whose bumps join the manual ubuntu base images group below; this rule is the safety net for a future base image of another kind.",
|
||||
"description": "Dockerfile base-image tag and digest bumps (images/*/Dockerfile) MAY automerge. Kamino is the untrusted side and the bump pull request's own CI exercises the new image before the merge. Placed first so the major-version rule below still turns automerge off. The merge publishes a new image version.",
|
||||
"matchManagers": [
|
||||
"dockerfile"
|
||||
],
|
||||
@@ -145,18 +145,12 @@
|
||||
"allowedVersions": "<=26.10.1"
|
||||
},
|
||||
{
|
||||
"description": "The job containers of image.yml (matrix job_image, ubuntu by digest) hold the org registry push credential while the image job runs: never automerged. Their ubuntu bumps share one branch with the Dockerfile FROM bumps (ubuntu base images rule below), so that pull request is manual too: a group automerges only if every update in it does.",
|
||||
"description": "The job containers of image.yml (matrix job_image, ubuntu by digest) hold the org registry push credential while the image job runs: never automerged, and kept in their own branch so the Dockerfile base-image bumps are not held back with them.",
|
||||
"matchFileNames": [
|
||||
".gitea/workflows/image.yml"
|
||||
],
|
||||
"automerge": false
|
||||
},
|
||||
{
|
||||
"description": "The Dockerfile FROM digests and the image.yml job_image digests of one Ubuntu update move in one pull request, so the release pair stays in step and one Images run covers both.",
|
||||
"matchPackageNames": [
|
||||
"ubuntu"
|
||||
],
|
||||
"groupName": "ubuntu base images"
|
||||
"automerge": false,
|
||||
"additionalBranchPrefix": "job-container-"
|
||||
},
|
||||
{
|
||||
"description": "Safety net only: kaniko is pinned by layer digests in image.yml and no Renovate manager reads them, so it is updated by hand. If a manager ever starts to read it, its bumps are not automerged.",
|
||||
@@ -166,15 +160,11 @@
|
||||
"automerge": false
|
||||
},
|
||||
{
|
||||
"description": "Pin follow-up for our own images (git.rkdr.net/mortis/*): moves the image:<version>@sha256:<digest> pins of lint.yml, build.yml, molecule.yml and gitea-release-key.yml to the newest published version and its digest, and automerges. The Images workflow's completion starts a Renovate run, so this pull request opens minutes after a new version is pushed. The pull request's own Lint and Build run in the new image before the merge, and scripts/check_bot_pr_diff.py allows only these pin lines. The registry lists tags and digests anonymously, so no hostRules are needed. A major version stays manual (rule above). One pull request moves every image an Images run published (ci and both molecule images), so one Molecule run tests them together. Exempt from the weekly schedule, so the pins on main catch up with a new image within minutes.",
|
||||
"description": "Pin follow-up for our own images (git.rkdr.net/mortis/*): moves the image:<version>@sha256:<digest> pins of lint.yml, build.yml, molecule.yml and gitea-release-key.yml to the newest published version and its digest, and automerges. The Images workflow's completion starts a Renovate run, so this pull request opens minutes after a new version is pushed. The pull request's own Lint and Build run in the new image before the merge, and scripts/check_bot_pr_diff.py allows only these pin lines. The registry lists tags and digests anonymously, so no hostRules are needed. A major version stays manual (rule above).",
|
||||
"matchPackageNames": [
|
||||
"git.rkdr.net/mortis/**"
|
||||
],
|
||||
"automerge": true,
|
||||
"groupName": "own CI images",
|
||||
"schedule": [
|
||||
"at any time"
|
||||
]
|
||||
"automerge": true
|
||||
},
|
||||
{
|
||||
"description": "Look the pre-commit hook repositories up with git ls-remote (git-tags) instead of the GitHub API. This run has no GitHub token, and the github-tags datasource then either skips every hook (skipReason github-token-required, dry run 3880) or is refused at once with 403 rate limit (githubTokenWarn off, local run). git-tags needs no API and no credential, and it uses the dereferenced hash of an annotated tag, so the new rev is the commit, as pre-commit needs. The `# frozen:` form is kept by the manager's own replace template. It works only together with RENOVATE_GITHUB_TOKEN_WARN=false in renovate.yml: the token check runs after extraction and skips every github-tags dependency before a package rule can change its datasource (local run, Renovate 44.161.0). git-tags has no release timestamps, so minimumReleaseAge cannot delay a hook bump: hook bumps are never automerged, a person reviews each one.",
|
||||
@@ -187,45 +177,16 @@
|
||||
"overrideDatasource": "git-tags",
|
||||
"overridePackageName": "https://github.com/{{{depName}}}",
|
||||
"automerge": false
|
||||
},
|
||||
{
|
||||
"description": "Lint and build tooling in one weekly pull request across requirements-dev.lock and the ci image's uv pin, so one ci image build instead of one per tool.",
|
||||
"matchDatasources": [
|
||||
"pypi"
|
||||
],
|
||||
"matchPackageNames": [
|
||||
"apm-cli",
|
||||
"antsibull-changelog",
|
||||
"galaxy-importer",
|
||||
"reuse",
|
||||
"pre-commit",
|
||||
"uv"
|
||||
],
|
||||
"groupName": "lint tooling"
|
||||
},
|
||||
{
|
||||
"description": "The pre-commit hooks in one weekly pull request; never automerged (rule above).",
|
||||
"matchManagers": [
|
||||
"pre-commit"
|
||||
],
|
||||
"groupName": "pre-commit hooks"
|
||||
}
|
||||
],
|
||||
"lockFileMaintenance": {
|
||||
"enabled": true,
|
||||
"schedule": [
|
||||
"on monday"
|
||||
"before 6am on monday"
|
||||
],
|
||||
"automerge": false,
|
||||
"labels": [
|
||||
"lock-file-maintenance"
|
||||
]
|
||||
},
|
||||
"schedule": [
|
||||
"on monday"
|
||||
],
|
||||
"osvVulnerabilityAlerts": true,
|
||||
"vulnerabilityAlerts": {
|
||||
"automerge": false
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,7 @@ The role targets Ubuntu hosts that run the reverse proxy, not Proxmox nodes, so
|
||||
| `traefik_version` | pinned in `defaults/main.yml` | no | Release tag to install. |
|
||||
| `traefik_arch` | `amd64` | no | Archive architecture. |
|
||||
| `traefik_os` | `linux` | no | Archive OS. |
|
||||
| `traefik_release_url` | github.com release directory of `traefik_version` | no | Directory URL of the archive and its checksums file, no trailing slash (templated). |
|
||||
| `traefik_archive_name` | `traefik_<version>_<os>_<arch>.tar.gz` | no | Archive file name (templated). |
|
||||
| `traefik_local_archive` | `/tmp/traefik.tar.gz` | no | Download destination, removed after extraction. |
|
||||
| `traefik_bin_path` | `/usr/local/bin/traefik` | no | Binary path used by the unit and version checks; only the `traefik` file of the archive is extracted into its directory, so the file name must stay `traefik`. Only the `traefik` file is extracted, so the archive's `CHANGELOG.md` and `LICENSE.md` never land there. |
|
||||
@@ -79,14 +80,14 @@ Update or remove: pass `-e traefik_update=true`, or `-e "traefik_remove=true tra
|
||||
|
||||
## Tests
|
||||
|
||||
The `default` molecule scenario runs in CI only, on two platforms: `${MOLECULE_IMAGE}` (Ubuntu 24.04) and `${MOLECULE_IMAGE_2604}` (Ubuntu 26.04). It needs outbound network: the role installs packages with apt and downloads real Traefik releases from GitHub. Converge runs `mortis.kamino.ufw`, then the role. It runs `check` before the converge (on a fresh host) and after it (on the configured host). Verify covers:
|
||||
The `default` molecule scenario runs in CI only, on two platforms: `${MOLECULE_IMAGE}` (Ubuntu 24.04) and `${MOLECULE_IMAGE_2604}` (Ubuntu 26.04). It needs outbound network: the role installs packages with apt and the converge downloads the real Traefik release from GitHub. Converge runs `mortis.kamino.ufw`, then the role. It runs `check` before the converge (on a fresh host) and after it (on the configured host). Verify covers:
|
||||
|
||||
- The input guards, first: one play expects the failure message containing `unauthenticated Traefik dashboard` (the dashboard guard: enabled without valid `user:hash` users); the next expects `collides with the middleware`, raised by the dashboard-auth collision assert, which runs whenever users are set, also with the dashboard off.
|
||||
- The install: the pinned version runs, and only the binary is left from the archive.
|
||||
- Files: `traefik.env` mode 0600 owned by root, `dynamic.yml` mode 0600 owned by `traefik`, `traefik.yml` mode 0600, the binary mode 0755; the logrotate configuration, which `logrotate --debug` parses.
|
||||
- Rendering: the ACME resolvers render when set and are absent when empty; the dashboard is off by default with the extra app routed, and renders behind basicAuth when enabled (a template render, not a running dashboard).
|
||||
- The service: running and enabled with `NoNewPrivileges`, `MemoryDenyWriteExecute` and `CAP_NET_BIND_SERVICE`, listening on 80 and 443 and redirecting http to https; ufw allows 80 and 443 next to SSH, with the traefik owner tag, in order.
|
||||
- The update path: it updates to another release and back with `traefik_update` (a real download, checksum check and swap) and asserts the version, an active unit and no leftovers.
|
||||
- The update path: it updates to another release and back with `traefik_update` (download from local `file://` stand-in releases, checksum check and swap) and asserts the version, an active unit and no leftovers. It leaves the stand-in stub installed, so nothing after it asserts real Traefik behaviour.
|
||||
- The remove path, last: unit and binary are deleted, the service is no longer active, and only the traefik ufw rules are removed.
|
||||
|
||||
The scenario disables the namespace-based sandboxing and the `User=` switch with a drop-in because its container is unprivileged, so that sandboxing is not covered by CI. Certificate issuance is not covered: the Cloudflare credentials are dummies.
|
||||
|
||||
@@ -9,6 +9,8 @@ traefik_version: "v3.7.19"
|
||||
traefik_arch: "amd64"
|
||||
traefik_os: "linux"
|
||||
|
||||
# Directory URL holding the release archive and its checksums file.
|
||||
traefik_release_url: "https://github.com/traefik/traefik/releases/download/{{ traefik_version }}"
|
||||
traefik_archive_name: "traefik_{{ traefik_version }}_{{ traefik_os }}_{{ traefik_arch }}.tar.gz"
|
||||
traefik_local_archive: "/tmp/traefik.tar.gz"
|
||||
|
||||
|
||||
@@ -63,6 +63,14 @@ argument_specs:
|
||||
default: linux
|
||||
description:
|
||||
- Operating system part of the release archive name.
|
||||
traefik_release_url:
|
||||
type: raw
|
||||
description:
|
||||
- >-
|
||||
URL of the directory holding the release archive and C(traefik_<traefik_version>_checksums.txt),
|
||||
without a trailing slash. The role default is the Jinja expression
|
||||
C(https://github.com/traefik/traefik/releases/download/<traefik_version>); point it at a mirror
|
||||
for a host without access to github.com.
|
||||
traefik_archive_name:
|
||||
type: raw
|
||||
description:
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404
|
||||
# (MOLECULE_IMAGE) and molecule-ubuntu2604 (MOLECULE_IMAGE_2604) images, pinned in
|
||||
# .gitea/workflows/molecule.yml. Needs outbound network, unlike most scenarios: the role installs
|
||||
# packages with apt and downloads Traefik releases from GitHub. No privileged mode: systemd needs a
|
||||
# writable cgroup and the firewall tools need NET_ADMIN.
|
||||
# packages with apt and the converge downloads the Traefik release from GitHub (verify's update
|
||||
# path uses file:// stand-ins built by prepare.yml). No privileged mode: systemd needs a writable
|
||||
# cgroup and the firewall tools need NET_ADMIN.
|
||||
driver:
|
||||
name: docker
|
||||
platforms:
|
||||
@@ -54,6 +55,9 @@ provisioner:
|
||||
traefik_cloudflare_email: [email protected]
|
||||
traefik_cloudflare_api_token: molecule-not-a-token
|
||||
traefik_domain: example.test
|
||||
# Any release other than the role default: verify's update path goes there and back,
|
||||
# from the stand-ins prepare.yml builds.
|
||||
traefik_verify_other_version: v3.7.18
|
||||
ufw_rules:
|
||||
- {rule: allow, port: 22, proto: tcp, comment: ssh}
|
||||
# TEST-NET-1 address: nothing answers, the value only has to render
|
||||
|
||||
@@ -40,3 +40,55 @@
|
||||
ProtectKernelTunables=no
|
||||
ReadWritePaths=
|
||||
User=
|
||||
|
||||
# Stand-in releases for verify's update path, behind file:// URLs: the role's download, checksum
|
||||
# check and swap run unchanged, without fetching two more real releases per host. The converge
|
||||
# still downloads the real role default from GitHub.
|
||||
- name: Prepare the stand-in releases
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
vars_files:
|
||||
- ../../defaults/main.yml
|
||||
tasks:
|
||||
- name: Create a directory per stand-in release
|
||||
ansible.builtin.file:
|
||||
path: "/opt/molecule-download/{{ traefik_test_release }}"
|
||||
state: directory
|
||||
mode: "0755"
|
||||
loop: ["{{ traefik_verify_other_version }}", "{{ traefik_version }}"]
|
||||
loop_control:
|
||||
loop_var: traefik_test_release
|
||||
|
||||
# Answers `version` like Traefik and otherwise stays up like the service.
|
||||
- name: Write the stand-in binaries
|
||||
ansible.builtin.copy:
|
||||
dest: "/opt/molecule-download/{{ traefik_test_release }}/traefik"
|
||||
mode: "0755"
|
||||
content: |
|
||||
#!/bin/sh
|
||||
case "$1" in
|
||||
version) echo "Version: {{ traefik_test_release | regex_replace('^v', '') }}" ;;
|
||||
*) exec sleep infinity ;;
|
||||
esac
|
||||
loop: ["{{ traefik_verify_other_version }}", "{{ traefik_version }}"]
|
||||
loop_control:
|
||||
loop_var: traefik_test_release
|
||||
|
||||
- name: Pack the stand-in archives
|
||||
ansible.builtin.command:
|
||||
argv: [tar, -czf, "{{ traefik_test_archive }}", -C, "/opt/molecule-download/{{ traefik_test_release }}", traefik]
|
||||
creates: "{{ traefik_test_archive }}"
|
||||
vars:
|
||||
traefik_test_archive: "/opt/molecule-download/{{ traefik_test_release }}/traefik_{{ traefik_test_release }}_{{ traefik_os }}_{{ traefik_arch }}.tar.gz"
|
||||
loop: ["{{ traefik_verify_other_version }}", "{{ traefik_version }}"]
|
||||
loop_control:
|
||||
loop_var: traefik_test_release
|
||||
|
||||
- name: Write the checksums files in the release format
|
||||
ansible.builtin.shell:
|
||||
cmd: sha256sum traefik_*.tar.gz > traefik_{{ traefik_test_release }}_checksums.txt
|
||||
chdir: "/opt/molecule-download/{{ traefik_test_release }}"
|
||||
creates: "traefik_{{ traefik_test_release }}_checksums.txt"
|
||||
loop: ["{{ traefik_verify_other_version }}", "{{ traefik_version }}"]
|
||||
loop_control:
|
||||
loop_var: traefik_test_release
|
||||
@@ -5,6 +5,7 @@
|
||||
vars:
|
||||
traefik_update: true
|
||||
traefik_version: "{{ traefik_verify_target }}"
|
||||
traefik_release_url: "file:///opt/molecule-download/{{ traefik_verify_target }}"
|
||||
|
||||
- name: Read the Traefik version after the update to {{ traefik_verify_target }}
|
||||
ansible.builtin.command: /usr/local/bin/traefik version
|
||||
|
||||
@@ -107,13 +107,40 @@
|
||||
name: traefik
|
||||
register: traefik_unit
|
||||
|
||||
- name: Let the ACME failures against the dummy credentials play out
|
||||
ansible.builtin.pause:
|
||||
seconds: 15
|
||||
# The dummy credentials make the ACME request fail, logged as "Unable to obtain ACME certificate
|
||||
# for domain(s)". The log keeps the lines of the process converge restarted, so only a line
|
||||
# stamped (RFC 3339, first field) since the running process started counts.
|
||||
- name: Wait until the running Traefik has logged the ACME failure
|
||||
ansible.builtin.shell:
|
||||
executable: /bin/bash
|
||||
cmd: |
|
||||
set -euo pipefail
|
||||
started=$(systemctl show --timestamp=unix -P ExecMainStartTimestamp traefik)
|
||||
if [[ ! $started =~ ^@[0-9]+$ ]]; then
|
||||
echo "no start time for traefik: '${started}'" >&2
|
||||
exit 1
|
||||
fi
|
||||
last=$(grep 'Unable to obtain ACME certificate' /etc/traefik/logs/traefik.log | tail -n 1 | cut -d ' ' -f 1) || true
|
||||
# Fails closed: a missing line, an unparseable stamp or an older one all end in exit 1.
|
||||
if [ -n "$last" ] && stamp=$(date -d "$last" +%s) && [ "$stamp" -ge "${started#@}" ]; then
|
||||
exit 0
|
||||
fi
|
||||
echo "no ACME failure logged since Traefik started at ${started} (last: ${last:-none})" >&2
|
||||
exit 1
|
||||
register: traefik_acme_failure
|
||||
changed_when: false
|
||||
until: traefik_acme_failure.rc == 0
|
||||
retries: 30
|
||||
delay: 2
|
||||
|
||||
- name: Read the service state after the wait
|
||||
- name: Read the service state after the ACME failure
|
||||
ansible.builtin.service_facts:
|
||||
|
||||
- name: Read the restart count after the ACME failure
|
||||
ansible.builtin.systemd:
|
||||
name: traefik
|
||||
register: traefik_unit_after_acme
|
||||
|
||||
- name: The pinned version is installed
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
@@ -224,6 +251,8 @@
|
||||
that:
|
||||
- ansible_facts.services['traefik.service'].state == 'running'
|
||||
- ansible_facts.services['traefik.service'].status == 'enabled'
|
||||
# Restart=always would hide a crash on the ACME failure from the state above.
|
||||
- traefik_unit_after_acme.status.NRestarts == '0'
|
||||
- traefik_unit.status.NoNewPrivileges == 'yes'
|
||||
- traefik_unit.status.MemoryDenyWriteExecute == 'yes'
|
||||
- "'cap_net_bind_service' in traefik_unit.status.AmbientCapabilities | lower"
|
||||
@@ -264,17 +293,15 @@
|
||||
traefik_ufw_key_443: "{{ ('allow|443|||||in' | hash('sha1'))[:10] }}"
|
||||
traefik_ufw_tagged: "{{ traefik_ufw_added.stdout_lines | select('match', '^ufw ') | select('search', 'ansible-ufw') | list }}"
|
||||
|
||||
# A real version bump through the update path and mortis.kamino._binary_update: down to another
|
||||
# release and back to the role default, both with traefik_update. After the idempotence step,
|
||||
# because each run changes the binary, and before the remove path, which deletes it.
|
||||
- name: Verify the update path with real Traefik releases
|
||||
# A version bump through the update path and mortis.kamino._binary_update: down to another
|
||||
# release and back to the role default, both with traefik_update, from prepare.yml's stand-ins.
|
||||
# After the idempotence step, because each run changes the binary, and before the remove path.
|
||||
# It leaves the stand-in stub installed, so nothing after it may assert real Traefik behaviour.
|
||||
- name: Verify the update path with stand-in releases
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
vars_files:
|
||||
- ../../defaults/main.yml
|
||||
vars:
|
||||
# Any published release other than the role default, with a checksum file.
|
||||
traefik_verify_other_version: v3.7.18
|
||||
tasks:
|
||||
- name: The other release differs from the role default
|
||||
ansible.builtin.assert:
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
# would otherwise be kept and then fail the checksum check.
|
||||
- name: Download Traefik archive
|
||||
ansible.builtin.get_url:
|
||||
url: "https://github.com/traefik/traefik/releases/download/{{ traefik_version }}/{{ traefik_archive_name }}"
|
||||
url: "{{ traefik_release_url }}/{{ traefik_archive_name }}"
|
||||
dest: "{{ traefik_local_archive }}"
|
||||
mode: "0644"
|
||||
force: true
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
- name: Download Traefik checksums
|
||||
ansible.builtin.get_url:
|
||||
url: "https://github.com/traefik/traefik/releases/download/{{ traefik_version }}/traefik_{{ traefik_version }}_checksums.txt"
|
||||
url: "{{ traefik_release_url }}/traefik_{{ traefik_version }}_checksums.txt"
|
||||
dest: /tmp/traefik_checksums.txt
|
||||
mode: "0644"
|
||||
force: true
|
||||
|
||||
Reference in new issue
Block a user