Compare commits
31
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ab0ce421cc | ||
|
|
6e3ea4521b | ||
|
|
7433a37697 | ||
|
|
0b8c45a19c | ||
|
|
2d4d44b871 | ||
|
|
d862097b9c | ||
|
|
6670ab664f | ||
|
|
1372c257c2 | ||
|
|
18475ea0a5 | ||
|
|
e2df672be7 | ||
|
|
2e92b11cbc | ||
|
|
7311a27e43 | ||
|
|
19449f7e93 | ||
|
|
84ad29b18b | ||
|
|
6d505c0db7 | ||
|
|
3bf9ae0efe | ||
|
|
fbc8b1b6d7 | ||
|
|
7c068c2b47 | ||
|
|
c51fa998b9 | ||
|
|
2eb7da3563 | ||
|
|
3a5040aae8 | ||
|
|
6a2060bd31 | ||
|
|
11fec7c8fc | ||
|
|
40e3b39990 | ||
|
|
4d5042a31f | ||
|
|
d5a91520df | ||
|
|
7c148e858d | ||
|
|
f7fde63f7d | ||
|
|
464cc5848b | ||
|
|
d1b4501c2b | ||
|
|
26b6e37a09 |
No files matched your search
@@ -57,6 +57,14 @@ issue.
|
|||||||
`.pre-commit-config.yaml` takes the slow path, 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
|
||||||
|
set to a dead local port and `no_proxy` empty, for every later step except "Test the repository
|
||||||
|
scripts", which unsets them for its fake registry on loopback; the slow path keeps network.
|
||||||
|
*Why:* a runtime download is a bake-in defect and must fail the job, not silently slow it.
|
||||||
|
*Held:* control, set by the "Check the baked tooling against the pins" step, for pip, curl, git
|
||||||
|
over HTTPS and Python's urllib or requests (anything honouring `PIP_NO_INDEX` or the proxy
|
||||||
|
variables); review for a raw socket or a tool that ignores the proxy variables, and for the
|
||||||
|
script tests.
|
||||||
- **Triggers:** both run on pull requests to `main` and on manual dispatch; Build also runs on
|
- **Triggers:** both run on pull requests to `main` and on manual dispatch; Build also runs on
|
||||||
`v*` tags, where it checks the tag against `galaxy.yml`. *Why:* the tag is what consumers
|
`v*` tags, where it checks the tag against `galaxy.yml`. *Why:* the tag is what consumers
|
||||||
install. *Held:* review.
|
install. *Held:* review.
|
||||||
|
|||||||
@@ -60,6 +60,11 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
if sha256sum --quiet -c /opt/ci-pins.sha256; then
|
if sha256sum --quiet -c /opt/ci-pins.sha256; then
|
||||||
echo "The pin files match the ci image; using the baked tools."
|
echo "The pin files match the ci image; using the baked tools."
|
||||||
|
# A job container may not unshare, so the network is cut by environment: pip, curl,
|
||||||
|
# git over HTTPS and Python's urllib fail; a raw socket is not caught.
|
||||||
|
printf '%s\n' PIP_NO_INDEX=1 http_proxy=http://127.0.0.1:9 https_proxy=http://127.0.0.1:9 \
|
||||||
|
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)."
|
||||||
else
|
else
|
||||||
echo "::warning::requirements-dev.txt, requirements-dev.lock, requirements.yml," \
|
echo "::warning::requirements-dev.txt, requirements-dev.lock, requirements.yml," \
|
||||||
"extensions/molecule/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;" \
|
||||||
|
|||||||
@@ -62,7 +62,6 @@ jobs:
|
|||||||
github.event_name != 'pull_request' &&
|
github.event_name != 'pull_request' &&
|
||||||
github.ref == 'refs/heads/main'
|
github.ref == 'refs/heads/main'
|
||||||
runs-on: kamino-docker
|
runs-on: kamino-docker
|
||||||
timeout-minutes: 45
|
|
||||||
# max-parallel: 1 keeps the builds to one at a time. The runner takes two jobs, so a build
|
# max-parallel: 1 keeps the builds to one at a time. The runner takes two jobs, so a build
|
||||||
# may share it with one other job (Lint, Build or Molecule). An empty subpath means the
|
# may share it with one other job (Lint, Build or Molecule). An empty subpath means the
|
||||||
# repository root is the build context.
|
# repository root is the build context.
|
||||||
@@ -80,7 +79,7 @@ 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:9c7f200c07e3d4a03e7249d2c16bf66a51120fb876aa2242cf31451412543289
|
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
|
||||||
|
|||||||
@@ -59,6 +59,11 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
if sha256sum --quiet -c /opt/ci-pins.sha256; then
|
if sha256sum --quiet -c /opt/ci-pins.sha256; then
|
||||||
echo "The pin files match the ci image; using the baked tools."
|
echo "The pin files match the ci image; using the baked tools."
|
||||||
|
# A job container may not unshare, so the network is cut by environment: pip, curl,
|
||||||
|
# git over HTTPS and Python's urllib fail; a raw socket is not caught.
|
||||||
|
printf '%s\n' PIP_NO_INDEX=1 http_proxy=http://127.0.0.1:9 https_proxy=http://127.0.0.1:9 \
|
||||||
|
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)."
|
||||||
else
|
else
|
||||||
echo "::warning::requirements-dev.txt, requirements-dev.lock, requirements.yml," \
|
echo "::warning::requirements-dev.txt, requirements-dev.lock, requirements.yml," \
|
||||||
"extensions/molecule/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;" \
|
||||||
@@ -108,8 +113,10 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
python3 -E -s "$guard" "$HEAD_REF" "$BASE_REF"
|
python3 -E -s "$guard" "$HEAD_REF" "$BASE_REF"
|
||||||
|
|
||||||
|
# Without the guard: an empty no_proxy would send the fake registry on 127.0.0.1 to the dead proxy.
|
||||||
- name: Test the repository scripts
|
- name: Test the repository scripts
|
||||||
run: |
|
run: |
|
||||||
|
unset PIP_NO_INDEX http_proxy https_proxy HTTP_PROXY HTTPS_PROXY
|
||||||
export PATH="/opt/venv/bin:$PATH"
|
export PATH="/opt/venv/bin:$PATH"
|
||||||
python3 -m unittest discover -s tests/scripts
|
python3 -m unittest discover -s tests/scripts
|
||||||
|
|
||||||
|
|||||||
@@ -47,10 +47,9 @@ jobs:
|
|||||||
(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-molecule]
|
runs-on: [kamino-molecule]
|
||||||
# Two full runs sharing the runner (a nightly run and a dispatch) take more than 30 minutes.
|
# A full run under load takes about 45 minutes (PR #405: 44m53s), so 45 left no margin. Also the
|
||||||
# Also the age past which the sweep step removes a run's containers; a script test holds the
|
# age past which the sweep step removes a run's containers; a script test holds the two equal.
|
||||||
# two equal.
|
timeout-minutes: 90
|
||||||
timeout-minutes: 45
|
|
||||||
env:
|
env:
|
||||||
# The tools and collections molecule runs with: the image Lint and Build use.
|
# The tools and collections molecule runs with: the image Lint and Build use.
|
||||||
CI_IMAGE: >-
|
CI_IMAGE: >-
|
||||||
@@ -98,7 +97,7 @@ jobs:
|
|||||||
ids="$(docker ps -aq --filter 'label=net.rkdr.mortis.molecule-run')"
|
ids="$(docker ps -aq --filter 'label=net.rkdr.mortis.molecule-run')"
|
||||||
# The job's timeout-minutes (a script test holds them equal): a shorter bound would remove a
|
# The job's timeout-minutes (a script test holds them equal): a shorter bound would remove a
|
||||||
# live run's containers.
|
# live run's containers.
|
||||||
cutoff="$(date -d '45 minutes ago' +%s)"
|
cutoff="$(date -d '90 minutes ago' +%s)"
|
||||||
old=""
|
old=""
|
||||||
for id in $ids; do
|
for id in $ids; do
|
||||||
# a container removed since the listing, by its run or another run's sweep, is skipped
|
# a container removed since the listing, by its run or another run's sweep, is skipped
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
---
|
||||||
|
bugfixes:
|
||||||
|
- >-
|
||||||
|
docker - Read the distribution release through ``ansible_facts['distribution_release']`` for the APT
|
||||||
|
source line, so the role works with ``inject_facts_as_vars`` set to false and in the ansible-core
|
||||||
|
release that stops injecting facts as variables. The source line is unchanged.
|
||||||
|
- >-
|
||||||
|
gitea_runner - Read the timestamp of the forced re-registration backup through
|
||||||
|
``ansible_facts['date_time']``, so the role works with ``inject_facts_as_vars`` set to false and in
|
||||||
|
the ansible-core release that stops injecting facts as variables. The backup name is unchanged.
|
||||||
|
- >-
|
||||||
|
system_baseline - Read the OS family through ``ansible_facts['os_family']`` in the reboot check, so
|
||||||
|
the role (and its ``reboot`` entry point) works with ``inject_facts_as_vars`` set to false and in
|
||||||
|
the ansible-core release that stops injecting facts as variables. Before, the task failed with
|
||||||
|
``'ansible_os_family' is undefined`` there.
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
minor_changes:
|
||||||
|
- >-
|
||||||
|
system_baseline - Add ``system_baseline_extra_packages`` and ``system_baseline_extra_remove_packages`` (lists, default empty), which
|
||||||
|
append to the resolved package lists, where setting ``system_baseline_essential_packages`` or ``system_baseline_remove_packages``
|
||||||
|
replaces the profile's whole list. An extra ``tmux`` or ``unattended-upgrades`` enables the matching task like a profile package.
|
||||||
|
A package that one input installs and another purges stops the run before any change. With both inputs left at their default the
|
||||||
|
role behaves as before.
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
minor_changes:
|
||||||
|
- >-
|
||||||
|
system_baseline - ``system_baseline_journal_max_use`` can be empty to leave journald alone: the role then writes no drop-in and does not
|
||||||
|
restart ``systemd-journald``. The default stays ``200M``.
|
||||||
|
- >-
|
||||||
|
system_baseline - ``system_baseline_journal_max_use`` is checked before any change: it must be empty, ``infinity`` or a number followed by
|
||||||
|
``K``, ``M``, ``G`` or ``T``. A value in any other form, which the role used to write into the drop-in as it was (a bare number, ``1.5G``,
|
||||||
|
a typo, a line break), now stops the run; an empty value used to write an empty ``SystemMaxUse=``.
|
||||||
@@ -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).
|
||||||
+2
-1
@@ -66,7 +66,8 @@ Read `.gitea/workflows/molecule.yml` for the full command.
|
|||||||
|
|
||||||
`/opt/ci-pins.sha256` lists the five 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`, `extensions/molecule/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. When a pull request changes a pin the check fails and the job installs the pinned
|
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
|
||||||
tools and collections itself for that run
|
tools and collections itself for that run
|
||||||
(slower, same result), until the image is rebuilt from `main`. `lint.yml`, `build.yml`, `molecule.yml` and `gitea-release-key.yml`
|
(slower, same result), until the image is rebuilt from `main`. `lint.yml`, `build.yml`, `molecule.yml` and `gitea-release-key.yml`
|
||||||
are the real consumers.
|
are the real consumers.
|
||||||
|
|||||||
@@ -7,4 +7,4 @@
|
|||||||
# 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
|
||||||
version: 5.4.0
|
version: 5.4.1
|
||||||
+4
-2
@@ -61,8 +61,10 @@ it to this repository's organisation in the Gitea registry as `<version>` and `l
|
|||||||
|
|
||||||
- **Bake in:** every tool, collection, hook environment and package a CI job uses is in its
|
- **Bake in:** every tool, collection, hook environment and package a CI job uses is in its
|
||||||
image; a job downloads at run time only on the slow path (a pull request that changes a pin
|
image; a job downloads at run time only on the slow path (a pull request that changes a pin
|
||||||
file). *Why:* a run that downloads is slower and depends on the network. *Held:* review until
|
file). *Why:* a run that downloads is slower and depends on the network. *Held:* control: on
|
||||||
the network-off check (#168) lands.
|
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
|
||||||
|
network, and for Molecule.
|
||||||
- **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.
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
# 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-10-24 (24.04.5).
|
# ubuntu:24.04 index digest as of 2026-10-24 (24.04.5).
|
||||||
FROM ubuntu:24.04@sha256:9c7f200c07e3d4a03e7249d2c16bf66a51120fb876aa2242cf31451412543289
|
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 packages the roles manage (iptables, ufw, fail2ban, openssh-server) preinstalled, so a converge makes no network calls. 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 packages the roles manage (iptables, ufw, fail2ban, openssh-server) preinstalled, so a converge makes no network calls. Start it as a molecule platform (usage label); it carries throwaway SSH host keys and is a test target only, never to be exposed." \
|
||||||
|
|||||||
@@ -240,9 +240,9 @@ anyio==4.16.0 \
|
|||||||
# via
|
# via
|
||||||
# httpx2
|
# httpx2
|
||||||
# openai
|
# openai
|
||||||
apm-cli==0.38.0 \
|
apm-cli==0.38.1 \
|
||||||
--hash=sha256:6dfac2fdc8ab68586afb2b1a5a6db3c1b7ab569ff0edc525448aa85d0f92bd38 \
|
--hash=sha256:c2a0394643e54d3516efefcd78bb043509ac48b65cca1f40166023789b8eb89a \
|
||||||
--hash=sha256:aa51a98867ae6aef11e92143dd9ca2a994d3dd6cbd7224eae58fb7b8078fc3b1
|
--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 \
|
||||||
|
|||||||
@@ -19,4 +19,4 @@ molecule-plugins[docker]==26.11.0
|
|||||||
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.38.0
|
apm-cli==0.38.1
|
||||||
@@ -4,7 +4,7 @@ Installs Docker Engine from the upstream Docker APT repository, optionally updat
|
|||||||
|
|
||||||
## Supported platforms
|
## Supported platforms
|
||||||
|
|
||||||
Ubuntu 24.04 (noble) and 26.04 (resolute), the platforms the molecule scenario runs on. The key and repository URLs point at `download.docker.com/linux/ubuntu`, and the source line uses `ansible_distribution_release`. The apt architecture is derived from the host (`x86_64` gives `amd64`, `aarch64` gives `arm64`); any other architecture fails the play until `docker_apt_arch` is set. A limited molecule scenario covers the role's own logic (see [Tests](#tests)); the real Docker Engine is not tested.
|
Ubuntu 24.04 (noble) and 26.04 (resolute), the platforms the molecule scenario runs on. The key and repository URLs point at `download.docker.com/linux/ubuntu`, and the source line uses `ansible_facts['distribution_release']`. The apt architecture is derived from the host (`x86_64` gives `amd64`, `aarch64` gives `arm64`); any other architecture fails the play until `docker_apt_arch` is set. A limited molecule scenario covers the role's own logic (see [Tests](#tests)); the real Docker Engine is not tested.
|
||||||
|
|
||||||
The role targets Ubuntu hosts only: it installs from Docker's Ubuntu repository, so it does not cover Debian trixie (Proxmox hosts).
|
The role targets Ubuntu hosts only: it installs from Docker's Ubuntu repository, so it does not cover Debian trixie (Proxmox hosts).
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ With any of `docker_daemon_options`, `docker_live_restore`, `docker_log_driver`,
|
|||||||
What it shows, with the role's tasks running unchanged:
|
What it shows, with the role's tasks running unchanged:
|
||||||
|
|
||||||
- The key is fetched, stored at `docker_keyring_path` with mode `0644`, and apt really verifies the repository against it (an unsigned or wrongly signed repository would leave no install candidate).
|
- The key is fetched, stored at `docker_keyring_path` with mode `0644`, and apt really verifies the repository against it (an unsigned or wrongly signed repository would leave no install candidate).
|
||||||
- The source line has the architecture, the `signed-by` keyring and `ansible_distribution_release`.
|
- The source line has the architecture, the `signed-by` keyring and `ansible_facts['distribution_release']`.
|
||||||
- The packages are installed from that repository, the unit is enabled and active, and `docker_users` join `docker_group`.
|
- The packages are installed from that repository, the unit is enabled and active, and `docker_users` join `docker_group`.
|
||||||
- `docker_remove` with `docker_remove_data` removes the source line, the keyring, the packages, the unit and `/var/lib/docker`.
|
- `docker_remove` with `docker_remove_data` removes the source line, the keyring, the packages, the unit and `/var/lib/docker`.
|
||||||
- Both units are installed, enabled, ordered against `docker.service` as stated, the shutdown unit is active, a unit is removed when its input is `false`, and `docker_remove` removes both.
|
- Both units are installed, enabled, ordered against `docker.service` as stated, the shutdown unit is active, a unit is removed when its input is `false`, and `docker_remove` removes both.
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ argument_specs:
|
|||||||
- >-
|
- >-
|
||||||
Installs Docker Engine from the upstream APT repository, or removes it when C(docker_remove) is true. Optionally updates the packages to
|
Installs Docker Engine from the upstream APT repository, or removes it when C(docker_remove) is true. Optionally updates the packages to
|
||||||
the current candidate versions, then adds C(docker_users) to C(docker_group).
|
the current candidate versions, then adds C(docker_users) to C(docker_group).
|
||||||
- Needs gathered facts, because the APT source uses C(ansible_distribution_release).
|
- Needs gathered facts, because the APT source uses C(ansible_facts['distribution_release']).
|
||||||
options:
|
options:
|
||||||
docker_remove:
|
docker_remove:
|
||||||
type: bool
|
type: bool
|
||||||
@@ -53,7 +53,7 @@ argument_specs:
|
|||||||
type: str
|
type: str
|
||||||
default: https://download.docker.com/linux/ubuntu
|
default: https://download.docker.com/linux/ubuntu
|
||||||
description:
|
description:
|
||||||
- Base URL of the repository. The source line uses C(ansible_distribution_release) and the C(stable) component.
|
- Base URL of the repository. The source line uses C(ansible_facts['distribution_release']) and the C(stable) component.
|
||||||
docker_apt_arch:
|
docker_apt_arch:
|
||||||
type: str
|
type: str
|
||||||
default: ""
|
default: ""
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
dest: "{{ docker_apt_list_path }}"
|
dest: "{{ docker_apt_list_path }}"
|
||||||
content: |
|
content: |
|
||||||
deb [arch={{ __docker_apt_arch }} signed-by={{ docker_keyring_path }}] {{ docker_repo_base_url }} {{ ansible_distribution_release }} stable
|
deb [arch={{ __docker_apt_arch }} signed-by={{ docker_keyring_path }}] {{ docker_repo_base_url }} {{ ansible_facts['distribution_release'] }} stable
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
register: __docker_apt_source
|
register: __docker_apt_source
|
||||||
tags: [docker, install]
|
tags: [docker, install]
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ The role targets Ubuntu hosts that run CI jobs, not Proxmox nodes, so it does no
|
|||||||
- The registration token is generated on the fly, held in a `no_log` fact and passed to `gitea-runner register` through the `GITEA_RUNNER_REGISTRATION_TOKEN` environment variable, not argv. It is never written to a file by the role.
|
- The registration token is generated on the fly, held in a `no_log` fact and passed to `gitea-runner register` through the `GITEA_RUNNER_REGISTRATION_TOKEN` environment variable, not argv. It is never written to a file by the role.
|
||||||
- The role creates `gitea_runner_group` and `gitea_runner_user` when they are missing; an existing account (for example the SSH login user) is reused.
|
- The role creates `gitea_runner_group` and `gitea_runner_user` when they are missing; an existing account (for example the SSH login user) is reused.
|
||||||
- Docker is installed by this role (`tasks/docker.yml`) on first install, not by `mortis.kamino.docker`.
|
- Docker is installed by this role (`tasks/docker.yml`) on first install, not by `mortis.kamino.docker`.
|
||||||
- Fact gathering must be on for `gitea_runner_force_register`: the backup name uses `ansible_date_time`.
|
- Fact gathering must be on for `gitea_runner_force_register`: the backup name uses `ansible_facts['date_time']`.
|
||||||
- Updates: the update path stages the verified binary and hands the swap to `mortis.kamino._binary_update`, an internal role of this Collection.
|
- Updates: the update path stages the verified binary and hands the swap to `mortis.kamino._binary_update`, an internal role of this Collection.
|
||||||
- `gitea_runner_version` is asserted at role start to be a plain `X.Y.Z` release number, with no leading `v`. Pin it in inventory to move the runner independently of Collection releases; the role default changes only with a release.
|
- `gitea_runner_version` is asserted at role start to be a plain `X.Y.Z` release number, with no leading `v`. Pin it in inventory to move the runner independently of Collection releases; the role default changes only with a release.
|
||||||
- The executor and job image of a job come from its label's suffix (`:host` or `docker://<image>`); a label with no suffix runs its jobs on the host. `config.yaml` has no keys for them.
|
- The executor and job image of a job come from its label's suffix (`:host` or `docker://<image>`); a label with no suffix runs its jobs on the host. `config.yaml` has no keys for them.
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ argument_specs:
|
|||||||
C(gitea_runner_token_host), C(gitea_runner_instance_url) and C(gitea_runner_name) have empty role defaults and
|
C(gitea_runner_token_host), C(gitea_runner_instance_url) and C(gitea_runner_name) have empty role defaults and
|
||||||
are asserted only when registration runs, so a run that never registers is not blocked.
|
are asserted only when registration runs, so a run that never registers is not blocked.
|
||||||
- >-
|
- >-
|
||||||
Reads gathered facts (C(ansible_date_time), for the forced re-registration backup name) and
|
Reads gathered facts (C(ansible_facts['date_time']), for the forced re-registration backup name) and
|
||||||
C(ansible_check_mode).
|
C(ansible_check_mode).
|
||||||
options:
|
options:
|
||||||
gitea_runner_remove:
|
gitea_runner_remove:
|
||||||
|
|||||||
@@ -71,7 +71,7 @@
|
|||||||
become: true
|
become: true
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
src: "{{ gitea_runner_work_dir }}/.runner"
|
src: "{{ gitea_runner_work_dir }}/.runner"
|
||||||
dest: "{{ gitea_runner_work_dir }}/.runner.bak.{{ ansible_date_time.iso8601_basic_short }}"
|
dest: "{{ gitea_runner_work_dir }}/.runner.bak.{{ ansible_facts['date_time']['iso8601_basic_short'] }}"
|
||||||
remote_src: true
|
remote_src: true
|
||||||
owner: "{{ gitea_runner_state.stat.pw_name }}"
|
owner: "{{ gitea_runner_state.stat.pw_name }}"
|
||||||
group: "{{ gitea_runner_state.stat.gr_name }}"
|
group: "{{ gitea_runner_state.stat.gr_name }}"
|
||||||
|
|||||||
@@ -98,8 +98,8 @@
|
|||||||
- name: The user is a system account without a login shell
|
- name: The user is a system account without a login shell
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- getent_passwd.pihole[5] == '/usr/sbin/nologin'
|
- ansible_facts['getent_passwd'].pihole[5] == '/usr/sbin/nologin'
|
||||||
- getent_passwd.pihole[1] | int < 1000
|
- ansible_facts['getent_passwd'].pihole[1] | int < 1000
|
||||||
quiet: true
|
quiet: true
|
||||||
|
|
||||||
# Neither check run (before and after the converge) ran the installer or the handler.
|
# Neither check run (before and after the converge) ran the installer or the handler.
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ The role targets Ubuntu guests (the `ubuntu_lxc` and `ubuntu_vm` profiles) and P
|
|||||||
|
|
||||||
## Requirements and run order
|
## Requirements and run order
|
||||||
|
|
||||||
- Facts must be gathered (`gather_facts: true`); `reboot.yml` reads `ansible_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` (sysctl, mount).
|
- Collections: `community.general` (locale, timezone) and `ansible.posix` (sysctl, mount).
|
||||||
@@ -35,6 +35,8 @@ templating error instead of the role's own message.
|
|||||||
| `system_baseline_profile` | derived | no | Active profile after overrides |
|
| `system_baseline_profile` | derived | no | Active profile after overrides |
|
||||||
| `system_baseline_essential_packages` | from profile | no | Packages to install |
|
| `system_baseline_essential_packages` | from profile | no | Packages to install |
|
||||||
| `system_baseline_remove_packages` | from profile | no | Packages to purge when present |
|
| `system_baseline_remove_packages` | from profile | no | Packages to purge when present |
|
||||||
|
| `system_baseline_extra_packages` | `[]` | no | Packages to install in addition to the resolved list; appends, see "Adding packages to a profile" |
|
||||||
|
| `system_baseline_extra_remove_packages` | `[]` | no | Packages to purge in addition to the resolved list; appends |
|
||||||
| `system_baseline_apt_periodic_settings` | from profile | no | Keys for `20auto-upgrades` |
|
| `system_baseline_apt_periodic_settings` | from profile | no | Keys for `20auto-upgrades` |
|
||||||
| `system_baseline_apt_upgrade` | from profile | no | `safe` or `dist`: how the role upgrades packages (`pve`: `dist`, the Ubuntu profiles: `safe`); see "Apt upgrade mode" |
|
| `system_baseline_apt_upgrade` | from profile | no | `safe` or `dist`: how the role upgrades packages (`pve`: `dist`, the Ubuntu profiles: `safe`); see "Apt upgrade mode" |
|
||||||
| `system_baseline_unattended_upgrade_settings` | from profile | no | Keys for `50unattended-upgrades` |
|
| `system_baseline_unattended_upgrade_settings` | from profile | no | Keys for `50unattended-upgrades` |
|
||||||
@@ -42,7 +44,7 @@ templating error instead of the role's own message.
|
|||||||
| `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 |
|
| `system_baseline_sysctl_hardening` | from profile | no | List of `name` and `value` sysctl pairs |
|
||||||
| `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`). |
|
| `system_baseline_journal_max_use` | `200M` | no | Upper bound of the persistent journal (journald `SystemMaxUse`): a number and `K`, `M`, `G` or `T`, or `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) |
|
||||||
| `system_baseline_tmux_session` | `main` | no | Session name, `A-Za-z0-9_-`, up to 32 characters |
|
| `system_baseline_tmux_session` | `main` | no | Session name, `A-Za-z0-9_-`, up to 32 characters |
|
||||||
| `system_baseline_tmux_windows` | `[]` | no | `{name, command}` windows made when the session is created |
|
| `system_baseline_tmux_windows` | `[]` | no | `{name, command}` windows made when the session is created |
|
||||||
@@ -126,11 +128,13 @@ 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).
|
||||||
|
|
||||||
- Converge first checks 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`, and a bad package blacklist (a quote, a null item, a bare string).
|
- Converge first checks 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` (a bare number, a space, a line break, a number), and a bad package blacklist (a quote, a null item, a bare string).
|
||||||
- Converge then applies the `ubuntu_lxc` profile, with tmux autostart and `system_baseline_apt_daily_timeout: 1h`, and only resolves the `pve` and `ubuntu_vm` profiles and a consumer override, asserting the resolved inputs.
|
- Converge then applies the `ubuntu_lxc` profile, with tmux autostart and `system_baseline_apt_daily_timeout: 1h`, and only resolves the `pve` and `ubuntu_vm` profiles and a consumer override, 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.
|
||||||
|
- Converge 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, then 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.
|
||||||
- Converge 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. Verify reads `tasks/update.yml` and checks that the scratch directory is created with mode `0700`, that both apt tasks set `TMPDIR` to it, and that the connection is reset afterwards: the scenario skips the `update` tag, so the upgrade itself never runs there.
|
- Converge 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. Verify reads `tasks/update.yml` and checks that the scratch directory is created with mode `0700`, that both apt tasks set `TMPDIR` to it, and that the connection is reset afterwards: the scenario skips the `update` tag, so the upgrade itself never runs there.
|
||||||
|
- 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.
|
||||||
|
|
||||||
@@ -145,9 +149,22 @@ Not covered: Molecule skips `sysctl`, `secure_tmp`, `update` and `timezone` (no
|
|||||||
- Policy lives in defaults, not `vars/`, so group_vars and host_vars can override it.
|
- Policy lives in defaults, not `vars/`, so group_vars and host_vars can override it.
|
||||||
- `no_log` is not used: the role handles no secrets.
|
- `no_log` is not used: the role handles no secrets.
|
||||||
|
|
||||||
|
### Adding packages to a profile
|
||||||
|
|
||||||
|
`system_baseline_essential_packages` and `system_baseline_remove_packages` replace the profile's whole list, and so does a list inside `system_baseline_profile_overrides`. To add or drop a few packages and keep the profile's own, use the two extra lists, which append:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
system_baseline_extra_packages: [jq]
|
||||||
|
system_baseline_extra_remove_packages: [telnet]
|
||||||
|
```
|
||||||
|
|
||||||
|
- Each item is a Debian package name: lower-case letters, digits, `+`, `-` and `.`, two or more characters, starting with a letter or digit and not ending in `-` (apt reads a trailing minus as a removal). Anything else stops the run. Duplicates of the profile list are harmless.
|
||||||
|
- An extra counts wherever the role looks for a package in the list: an extra `tmux` enables the tmux snippet and an extra `unattended-upgrades` the unattended-upgrades tasks, as a profile package does.
|
||||||
|
- A package that one input installs and another purges stops the run before any change: `system_baseline_extra_packages` against `system_baseline_remove_packages` or `system_baseline_extra_remove_packages`, and `system_baseline_extra_remove_packages` against `system_baseline_essential_packages`. The resolved lists are not checked against each other, so a consumer's own overlap there behaves as before.
|
||||||
|
|
||||||
### tmux on SSH login
|
### tmux on SSH login
|
||||||
|
|
||||||
With `system_baseline_tmux_autostart: true` an interactive SSH login attaches to the session `system_baseline_tmux_session` (created when missing), so a dropped connection loses nothing. The `ubuntu_lxc` and `ubuntu_vm` profiles install `tmux`; `pve` never gets the snippet.
|
With `system_baseline_tmux_autostart: true` an interactive SSH login attaches to the session `system_baseline_tmux_session` (created when missing), so a dropped connection loses nothing. The `ubuntu_lxc` and `ubuntu_vm` profiles install `tmux`; the `pve` profile has none, so it gets the snippet only if `system_baseline_extra_packages` adds `tmux`.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
system_baseline_tmux_autostart: true
|
system_baseline_tmux_autostart: true
|
||||||
@@ -157,7 +174,7 @@ system_baseline_tmux_windows:
|
|||||||
```
|
```
|
||||||
|
|
||||||
- It is `/etc/profile.d/tmux-autostart.sh`. Every login shell reads that directory, so the snippet itself acts only for an interactive shell (`case $-`) with a terminal and an SSH connection, outside tmux, and without `~/.no-tmux`. `scp`, `sftp`, `ssh host command`, Ansible and `ssh -t host 'bash -lc cmd'` never trigger it. sshd's `ForceCommand` is not used: it applies to every session type and a broken tmux would lock all of them out. Users whose login shell is zsh or fish are not affected, because those shells do not read `/etc/profile.d`.
|
- It is `/etc/profile.d/tmux-autostart.sh`. Every login shell reads that directory, so the snippet itself acts only for an interactive shell (`case $-`) with a terminal and an SSH connection, outside tmux, and without `~/.no-tmux`. `scp`, `sftp`, `ssh host command`, Ansible and `ssh -t host 'bash -lc cmd'` never trigger it. sshd's `ForceCommand` is not used: it applies to every session type and a broken tmux would lock all of them out. Users whose login shell is zsh or fish are not affected, because those shells do not read `/etc/profile.d`.
|
||||||
- The snippet is installed when autostart is on and the resolved package list contains `tmux` (the `ubuntu_lxc` and `ubuntu_vm` profiles). If you override `system_baseline_essential_packages` without it, nothing is installed.
|
- The snippet is installed when autostart is on and the packages to install contain `tmux`: the `ubuntu_lxc` and `ubuntu_vm` profiles have it, and `system_baseline_extra_packages` can add it. If you override `system_baseline_essential_packages` without it and add no extra `tmux`, nothing is installed.
|
||||||
- A failed attach (for example a client `TERM` such as `xterm-kitty` or `wezterm` without a terminfo entry on the host) prints a line and leaves a plain shell. Detaching (`Ctrl-b d`) ends the SSH connection, as `exit` would.
|
- A failed attach (for example a client `TERM` such as `xterm-kitty` or `wezterm` without a terminfo entry on the host) prints a line and leaves a plain shell. Detaching (`Ctrl-b d`) ends the SSH connection, as `exit` would.
|
||||||
- Turn it off for one login with `ssh -t host bash` (a non-login shell does not read `/etc/profile.d`), for one user with `touch ~/.no-tmux`, and for the host by setting the variable to `false` and running the role (it removes the snippet).
|
- Turn it off for one login with `ssh -t host bash` (a non-login shell does not read `/etc/profile.d`), for one user with `touch ~/.no-tmux`, and for the host by setting the variable to `false` and running the role (it removes the snippet).
|
||||||
- The windows are made when the session is created; a login that re-attaches adds none, so a change applies from the next new session. A window closes when its command exits. A window command runs with `sh -c` from the tmux server of the first login, before `~/.profile` is read, so it does not see `~/.local/bin` and other additions made there: use absolute paths.
|
- The windows are made when the session is created; a login that re-attaches adds none, so a change applies from the next new session. A window closes when its command exits. A window command runs with `sh -c` from the tmux server of the first login, before `~/.profile` is read, so it does not see `~/.local/bin` and other additions made there: use absolute paths.
|
||||||
@@ -195,6 +212,10 @@ The profile key `apt_upgrade` (`safe` or `dist`, resolved to `system_baseline_ap
|
|||||||
- The `update` entry point follows the same input: it upgrades with `dist` when `system_baseline_system_type` is `pve`. Without a `system_baseline_system_type` (the entry point does not require one) it stays on `safe`.
|
- The `update` entry point follows the same input: it upgrades with `dist` when `system_baseline_system_type` is `pve`. Without a `system_baseline_system_type` (the entry point does not require one) it stays on `safe`.
|
||||||
- Only the apt upgrade changes. Autoremove and autoclean, the check-mode skip and unattended-upgrades are as before; the example blacklist below keeps unattended-upgrades away from the Proxmox packages.
|
- Only the apt upgrade changes. Autoremove and autoclean, the check-mode skip and unattended-upgrades are as before; the example blacklist below keeps unattended-upgrades away from the Proxmox packages.
|
||||||
|
|
||||||
|
### Leaving journald alone
|
||||||
|
|
||||||
|
`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 (`300`, `0`, `10 M`, one with a line break) stops the run before any change, in the same way as the apt-daily value.
|
||||||
|
|
||||||
### 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`.
|
||||||
|
|||||||
@@ -18,10 +18,12 @@ system_baseline_apt_tmpdir: /var/cache/system-baseline-apt-tmp
|
|||||||
# Run the package update (tasks/update.yml) in the main flow. false skips it, for hosts that are patched by a separate,
|
# Run the package update (tasks/update.yml) in the main flow. false skips it, for hosts that are patched by a separate,
|
||||||
# operator-run flow; the tasks_from: update entry point does not read it.
|
# operator-run flow; the tasks_from: update entry point does not read it.
|
||||||
system_baseline_update: true
|
system_baseline_update: true
|
||||||
# Upper bound of the persistent journal (journald SystemMaxUse); older archived files are removed above it.
|
# 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).
|
||||||
system_baseline_journal_max_use: 200M
|
system_baseline_journal_max_use: 200M
|
||||||
# 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.
|
||||||
# Only the ubuntu_lxc and ubuntu_vm profiles honour it; pve never installs the snippet.
|
# 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_tmux_autostart: false
|
system_baseline_tmux_autostart: false
|
||||||
# Name of the session an SSH login attaches to.
|
# Name of the session an SSH login attaches to.
|
||||||
system_baseline_tmux_session: main
|
system_baseline_tmux_session: main
|
||||||
@@ -246,6 +248,19 @@ system_baseline_profile: >-
|
|||||||
# Inputs the tasks read
|
# Inputs the tasks read
|
||||||
system_baseline_essential_packages: "{{ system_baseline_profile.essential_packages }}"
|
system_baseline_essential_packages: "{{ system_baseline_profile.essential_packages }}"
|
||||||
system_baseline_remove_packages: "{{ system_baseline_profile.remove_packages }}"
|
system_baseline_remove_packages: "{{ system_baseline_profile.remove_packages }}"
|
||||||
|
# Packages installed and purged in addition to the two resolved lists above. They append: a flat essential or remove input replaces its
|
||||||
|
# list, so adding one package that way means repeating the whole profile list.
|
||||||
|
system_baseline_extra_packages: []
|
||||||
|
system_baseline_extra_remove_packages: []
|
||||||
|
# What the role acts on: each resolved list plus its extras, without duplicates. Internal, read by tasks/packages.yml, tasks/tmux.yml and
|
||||||
|
# tasks/main.yml, so that an extra `tmux` or `unattended-upgrades` enables the matching task like a profile package does.
|
||||||
|
# A flat input that is a plain string (`system_baseline_essential_packages: vim`, which the package module accepts) counts as a one-item list.
|
||||||
|
__system_baseline_install_packages: >-
|
||||||
|
{{ (([system_baseline_essential_packages] if system_baseline_essential_packages is string else system_baseline_essential_packages)
|
||||||
|
+ system_baseline_extra_packages) | unique | list }}
|
||||||
|
__system_baseline_purge_packages: >-
|
||||||
|
{{ (([system_baseline_remove_packages] if system_baseline_remove_packages is string else system_baseline_remove_packages)
|
||||||
|
+ system_baseline_extra_remove_packages) | unique | list }}
|
||||||
system_baseline_apt_periodic_settings: "{{ system_baseline_profile.apt_periodic_settings }}"
|
system_baseline_apt_periodic_settings: "{{ system_baseline_profile.apt_periodic_settings }}"
|
||||||
# safe or dist (see the profiles). Guarded: the tasks_from: update entry point needs no system_baseline_system_type, and without one it
|
# safe or dist (see the profiles). Guarded: the tasks_from: update entry point needs no system_baseline_system_type, and without one it
|
||||||
# stays on a safe upgrade instead of failing on the profile lookup. default('safe'): a system_baseline_profiles written before this key
|
# stays on a safe upgrade instead of failing on the profile lookup. default('safe'): a system_baseline_profiles written before this key
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ argument_specs:
|
|||||||
Validates C(system_baseline_system_type) and, when C(system_baseline_tmux_autostart) is true, the tmux session name and
|
Validates C(system_baseline_system_type) and, when C(system_baseline_tmux_autostart) is true, the tmux session name and
|
||||||
windows, then runs the update (unless C(system_baseline_update) is false), packages, unattended-upgrades, locale, timezone,
|
windows, then runs the update (unless C(system_baseline_update) is false), packages, unattended-upgrades, locale, timezone,
|
||||||
journald, apt-daily timeout (when set), sysctl, tmpfs, tmux and reboot task files, in that order.
|
journald, apt-daily timeout (when set), sysctl, tmpfs, tmux and reboot task files, in that order.
|
||||||
- Needs gathered facts, because the reboot check reads C(ansible_os_family).
|
- Needs gathered facts, because the reboot check reads C(ansible_facts['os_family']).
|
||||||
- >-
|
- >-
|
||||||
The resolved inputs C(system_baseline_profile), C(system_baseline_essential_packages),
|
The resolved inputs C(system_baseline_profile), C(system_baseline_essential_packages),
|
||||||
C(system_baseline_remove_packages), C(system_baseline_apt_periodic_settings), C(system_baseline_apt_upgrade),
|
C(system_baseline_remove_packages), C(system_baseline_apt_periodic_settings), C(system_baseline_apt_upgrade),
|
||||||
@@ -55,6 +55,10 @@ argument_specs:
|
|||||||
description:
|
description:
|
||||||
- Upper bound of the persistent systemd journal (journald C(SystemMaxUse), for example C(200M)).
|
- Upper bound of the persistent systemd journal (journald C(SystemMaxUse), for example C(200M)).
|
||||||
- Written to a drop-in under C(/etc/systemd/journald.conf.d).
|
- Written to a drop-in under C(/etc/systemd/journald.conf.d).
|
||||||
|
- >-
|
||||||
|
A number and one of C(K), C(M), C(G), C(T), or C(infinity); anything else (a bare number, a space, a line break) is refused
|
||||||
|
before any change. Empty leaves the host alone: no drop-in is written and journald is not restarted.
|
||||||
|
Clearing the value later does not remove a file already written.
|
||||||
system_baseline_tmux_autostart:
|
system_baseline_tmux_autostart:
|
||||||
type: bool
|
type: bool
|
||||||
default: false
|
default: false
|
||||||
@@ -63,7 +67,8 @@ argument_specs:
|
|||||||
Attach an interactive SSH login to a tmux session, creating it when it does not exist. Installs C(/etc/profile.d/tmux-autostart.sh),
|
Attach an interactive SSH login to a tmux session, creating it when it does not exist. Installs C(/etc/profile.d/tmux-autostart.sh),
|
||||||
which acts only for an interactive login shell with a terminal, so scp, sftp, C(ssh host command) and automation are unaffected.
|
which acts only for an interactive login shell with a terminal, so scp, sftp, C(ssh host command) and automation are unaffected.
|
||||||
Shells that do not read C(/etc/profile.d) (zsh, fish) are unaffected too. A user opts out with C(~/.no-tmux). Installed only when
|
Shells that do not read C(/etc/profile.d) (zsh, fish) are unaffected too. A user opts out with C(~/.no-tmux). Installed only when
|
||||||
C(tmux) is in the resolved package list (the C(ubuntu_lxc) and C(ubuntu_vm) profiles); with false, or without tmux, the file is
|
C(tmux) is among the packages to install (the C(ubuntu_lxc) and C(ubuntu_vm) profiles have it, and C(system_baseline_extra_packages)
|
||||||
|
can add it to any profile, C(pve) included); with false, or without tmux, the file is
|
||||||
removed. A failed attach leaves a plain shell; detaching ends the SSH connection.
|
removed. A failed attach leaves a plain shell; detaching ends the SSH connection.
|
||||||
system_baseline_tmux_session:
|
system_baseline_tmux_session:
|
||||||
type: str
|
type: str
|
||||||
@@ -152,6 +157,27 @@ argument_specs:
|
|||||||
A non-empty list is written to C(/etc/apt/apt.conf.d/90unattended-upgrades-blacklist) as C(Unattended-Upgrade::Package-Blacklist).
|
A non-empty list is written to C(/etc/apt/apt.conf.d/90unattended-upgrades-blacklist) as C(Unattended-Upgrade::Package-Blacklist).
|
||||||
apt appends list entries across files, so these are added to those of C(50unattended-upgrades). An empty list removes the file.
|
apt appends list entries across files, so these are added to those of C(50unattended-upgrades). An empty list removes the file.
|
||||||
An entry may not hold a double quote, a backslash or a line break.
|
An entry may not hold a double quote, a backslash or a line break.
|
||||||
|
system_baseline_extra_packages:
|
||||||
|
type: list
|
||||||
|
elements: str
|
||||||
|
default: []
|
||||||
|
description:
|
||||||
|
- >-
|
||||||
|
Packages installed in addition to the resolved C(system_baseline_essential_packages). The list appends: setting
|
||||||
|
C(system_baseline_essential_packages) itself replaces the profile's list. A package named here also counts for the checks that read
|
||||||
|
the package list (C(tmux) for the tmux snippet, C(unattended-upgrades) for the unattended-upgrades tasks). Each item is a Debian
|
||||||
|
package name: lower-case letters, digits, C(+), C(-) and C(.), two or more characters, starting with a letter or digit and not
|
||||||
|
ending in C(-) (apt reads a trailing minus as a removal). A package that is also in C(system_baseline_remove_packages) or
|
||||||
|
C(system_baseline_extra_remove_packages) stops the run before any change.
|
||||||
|
system_baseline_extra_remove_packages:
|
||||||
|
type: list
|
||||||
|
elements: str
|
||||||
|
default: []
|
||||||
|
description:
|
||||||
|
- >-
|
||||||
|
Packages purged, when installed, in addition to the resolved C(system_baseline_remove_packages). The list appends. Each item is a
|
||||||
|
Debian package name, as for C(system_baseline_extra_packages). A package that is also in C(system_baseline_essential_packages)
|
||||||
|
stops the run before any change.
|
||||||
system_baseline_update:
|
system_baseline_update:
|
||||||
type: bool
|
type: bool
|
||||||
default: true
|
default: true
|
||||||
@@ -187,7 +213,7 @@ argument_specs:
|
|||||||
never reboots, so a caller can read C(system_baseline_reboot_required) (bool) and reboot on its own terms, for example after
|
never reboots, so a caller can read C(system_baseline_reboot_required) (bool) and reboot on its own terms, for example after
|
||||||
draining a node. The fact name and this behaviour are part of the role's interface.
|
draining a node. The fact name and this behaviour are part of the role's interface.
|
||||||
- On a non-Debian host the fact is not set; read it with C(default(false)).
|
- On a non-Debian host the fact is not set; read it with C(default(false)).
|
||||||
- Reads C(ansible_os_family), so facts must be gathered.
|
- Reads C(ansible_facts['os_family']), so facts must be gathered.
|
||||||
options:
|
options:
|
||||||
system_baseline_reboot_if_required:
|
system_baseline_reboot_if_required:
|
||||||
type: bool
|
type: bool
|
||||||
|
|||||||
@@ -118,6 +118,24 @@
|
|||||||
that: "'system_baseline_apt_daily_timeout must be' in ansible_failed_result.msg | default('')"
|
that: "'system_baseline_apt_daily_timeout must be' in ansible_failed_result.msg | default('')"
|
||||||
quiet: true
|
quiet: true
|
||||||
|
|
||||||
|
# The journal cap is a number and a unit letter, or empty: a bare number (journald would read bytes), a zero, a space, a line break, a
|
||||||
|
# lower-case unit and a number that is not a string each stop the run before any change.
|
||||||
|
- name: A bad journal size cap is refused
|
||||||
|
hosts: all
|
||||||
|
gather_facts: false
|
||||||
|
tasks:
|
||||||
|
- name: Refuse each bad value
|
||||||
|
ansible.builtin.include_tasks: tasks/refuse_journal_max_use.yml
|
||||||
|
vars:
|
||||||
|
system_baseline_refused_journal: "{{ item }}"
|
||||||
|
loop:
|
||||||
|
- "300"
|
||||||
|
- "0"
|
||||||
|
- 10 M
|
||||||
|
- "10m"
|
||||||
|
- "200M\nStorage=none"
|
||||||
|
- 300
|
||||||
|
|
||||||
# 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
|
||||||
@@ -133,11 +151,38 @@
|
|||||||
- [null]
|
- [null]
|
||||||
- linux-image-.*
|
- linux-image-.*
|
||||||
|
|
||||||
|
# Items that are not Debian package names (whitespace, null, empty, a trailing minus that apt reads as a removal, an option, upper case, a
|
||||||
|
# version pin), and a package that one input installs and another purges, each stop the run before any change.
|
||||||
|
# The overlaps are: an extra install against the profile's remove list (telnet), an extra install against an extra remove, and an extra
|
||||||
|
# remove against the profile's install list (tmux).
|
||||||
|
- name: A bad extra package list is refused
|
||||||
|
hosts: all
|
||||||
|
gather_facts: false
|
||||||
|
tasks:
|
||||||
|
- name: Refuse each bad value
|
||||||
|
ansible.builtin.include_tasks: tasks/refuse_extra_packages.yml
|
||||||
|
vars:
|
||||||
|
system_baseline_refused_case: "{{ item }}"
|
||||||
|
loop:
|
||||||
|
- { install: ['bad name'], expect: 'must be lists of package names' }
|
||||||
|
- { install: [null], expect: 'must be lists of package names' }
|
||||||
|
- { install: jq, expect: 'must be lists of package names' }
|
||||||
|
- { remove: [''], expect: 'must be lists of package names' }
|
||||||
|
- { install: ['jq-'], expect: 'must be lists of package names' }
|
||||||
|
- { install: ['-y'], expect: 'must be lists of package names' }
|
||||||
|
- { remove: ['Telnet'], expect: 'must be lists of package names' }
|
||||||
|
- { remove: ['ed=1.0'], expect: 'must be lists of package names' }
|
||||||
|
- { install: [telnet], expect: 'is both installed and purged' }
|
||||||
|
- { install: [jq], remove: [jq], expect: 'is both installed and purged' }
|
||||||
|
- { remove: [tmux], expect: 'is both installed and purged' }
|
||||||
|
|
||||||
- name: Converge the LXC profile
|
- name: Converge the LXC profile
|
||||||
hosts: all
|
hosts: all
|
||||||
gather_facts: true
|
gather_facts: true
|
||||||
vars:
|
vars:
|
||||||
system_baseline_system_type: ubuntu_lxc
|
system_baseline_system_type: ubuntu_lxc
|
||||||
|
system_baseline_extra_packages: [jq]
|
||||||
|
system_baseline_extra_remove_packages: [ed]
|
||||||
system_baseline_tmux_autostart: true
|
system_baseline_tmux_autostart: true
|
||||||
system_baseline_apt_daily_timeout: 1h
|
system_baseline_apt_daily_timeout: 1h
|
||||||
system_baseline_tmux_session: molecule
|
system_baseline_tmux_session: molecule
|
||||||
@@ -172,6 +217,8 @@
|
|||||||
- system_baseline_apt_upgrade == 'dist'
|
- system_baseline_apt_upgrade == 'dist'
|
||||||
- system_baseline_unattended_upgrade_origins | length == 3
|
- system_baseline_unattended_upgrade_origins | length == 3
|
||||||
- system_baseline_unattended_upgrade_origins | select('search', 'Proxmox') | list == []
|
- system_baseline_unattended_upgrade_origins | select('search', 'Proxmox') | list == []
|
||||||
|
- __system_baseline_install_packages == system_baseline_essential_packages
|
||||||
|
- __system_baseline_purge_packages == system_baseline_remove_packages
|
||||||
quiet: true
|
quiet: true
|
||||||
|
|
||||||
- name: The ubuntu_vm profile resolves
|
- name: The ubuntu_vm profile resolves
|
||||||
@@ -195,6 +242,8 @@
|
|||||||
- system_baseline_sysctl_hardening | selectattr('name', 'equalto', 'net.ipv4.conf.all.log_martians') | list | length == 1
|
- system_baseline_sysctl_hardening | selectattr('name', 'equalto', 'net.ipv4.conf.all.log_martians') | list | length == 1
|
||||||
- system_baseline_apt_upgrade == 'safe'
|
- system_baseline_apt_upgrade == 'safe'
|
||||||
- system_baseline_unattended_upgrade_origins == []
|
- system_baseline_unattended_upgrade_origins == []
|
||||||
|
- __system_baseline_install_packages == system_baseline_essential_packages
|
||||||
|
- __system_baseline_purge_packages == system_baseline_remove_packages
|
||||||
quiet: true
|
quiet: true
|
||||||
|
|
||||||
# Consumer play vars override the profile.
|
# Consumer play vars override the profile.
|
||||||
@@ -224,3 +273,47 @@
|
|||||||
- system_baseline_unattended_upgrade_settings['Unattended-Upgrade::Automatic-Reboot-Time'] == '04:00'
|
- system_baseline_unattended_upgrade_settings['Unattended-Upgrade::Automatic-Reboot-Time'] == '04:00'
|
||||||
- "'qemu-guest-agent' in system_baseline_essential_packages"
|
- "'qemu-guest-agent' in system_baseline_essential_packages"
|
||||||
quiet: true
|
quiet: true
|
||||||
|
|
||||||
|
# The extras append to the resolved lists, whether the profile's list or a flat input supplies them, and a name that is in both is listed once.
|
||||||
|
- name: Extra packages append to the resolved lists
|
||||||
|
hosts: all
|
||||||
|
gather_facts: false
|
||||||
|
vars:
|
||||||
|
system_baseline_system_type: ubuntu_lxc
|
||||||
|
system_baseline_essential_packages: [vim, curl]
|
||||||
|
system_baseline_extra_packages: [jq, vim, unattended-upgrades]
|
||||||
|
system_baseline_extra_remove_packages: [ed, telnet]
|
||||||
|
tasks:
|
||||||
|
- name: Load the role defaults
|
||||||
|
ansible.builtin.include_role:
|
||||||
|
name: mortis.kamino.system_baseline
|
||||||
|
tasks_from: validate.yml
|
||||||
|
public: true
|
||||||
|
- name: Assert the lists the role acts on
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- __system_baseline_install_packages == ['vim', 'curl', 'jq', 'unattended-upgrades']
|
||||||
|
- "'ed' in __system_baseline_purge_packages"
|
||||||
|
- __system_baseline_purge_packages | select('equalto', 'telnet') | list | length == 1
|
||||||
|
- system_baseline_remove_packages | difference(__system_baseline_purge_packages) | length == 0
|
||||||
|
quiet: true
|
||||||
|
|
||||||
|
# A flat input that is a plain string (the package module accepts one) still counts as a one-item list, with and without extras.
|
||||||
|
- name: A flat string package list still resolves
|
||||||
|
hosts: all
|
||||||
|
gather_facts: false
|
||||||
|
vars:
|
||||||
|
system_baseline_system_type: ubuntu_lxc
|
||||||
|
system_baseline_essential_packages: vim
|
||||||
|
system_baseline_extra_packages: [jq]
|
||||||
|
tasks:
|
||||||
|
- name: Load the role defaults
|
||||||
|
ansible.builtin.include_role:
|
||||||
|
name: mortis.kamino.system_baseline
|
||||||
|
tasks_from: validate.yml
|
||||||
|
public: true
|
||||||
|
- name: Assert the lists the role acts on
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- __system_baseline_install_packages == ['vim', 'jq']
|
||||||
|
quiet: true
|
||||||
@@ -1,12 +1,18 @@
|
|||||||
---
|
---
|
||||||
# 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).
|
# (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.
|
||||||
- name: Prepare
|
- name: Prepare
|
||||||
hosts: all
|
hosts: all
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
tasks:
|
tasks:
|
||||||
- name: Install a package on the role's remove list and locale-gen
|
- name: Install a package on the role's remove list and locale-gen
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
name: [telnet, locales]
|
name: [telnet, locales, ed]
|
||||||
state: present
|
state: present
|
||||||
update_cache: true
|
update_cache: true
|
||||||
|
|
||||||
|
- name: Make sure jq is not installed
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name: jq
|
||||||
|
state: absent
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
---
|
||||||
|
# One refusal per call: the role must stop on validation, before it changes anything, with a message that names the inputs.
|
||||||
|
# The case comes in as system_baseline_refused_case: {install, remove, expect}.
|
||||||
|
- name: Run the role with a bad extra package list
|
||||||
|
block:
|
||||||
|
- name: Include system_baseline
|
||||||
|
ansible.builtin.include_role:
|
||||||
|
name: mortis.kamino.system_baseline
|
||||||
|
vars:
|
||||||
|
system_baseline_system_type: ubuntu_lxc
|
||||||
|
system_baseline_extra_packages: "{{ system_baseline_refused_case.install | default([]) }}"
|
||||||
|
system_baseline_extra_remove_packages: "{{ system_baseline_refused_case.remove | default([]) }}"
|
||||||
|
- name: Unreachable when validation works
|
||||||
|
ansible.builtin.fail:
|
||||||
|
msg: system_baseline ran with a bad extra package list
|
||||||
|
rescue:
|
||||||
|
- name: The validation stopped the play with the expected message
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that: system_baseline_refused_case.expect in ansible_failed_result.msg | default('')
|
||||||
|
fail_msg: "Expected '{{ system_baseline_refused_case.expect }}', got: {{ ansible_failed_result.msg | default('') }}"
|
||||||
|
quiet: true
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
---
|
||||||
|
# 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_journal_max_use
|
||||||
|
block:
|
||||||
|
- name: Include system_baseline
|
||||||
|
ansible.builtin.include_role:
|
||||||
|
name: mortis.kamino.system_baseline
|
||||||
|
vars:
|
||||||
|
system_baseline_system_type: ubuntu_lxc
|
||||||
|
system_baseline_journal_max_use: "{{ system_baseline_refused_journal }}"
|
||||||
|
- name: Unreachable when validation works
|
||||||
|
ansible.builtin.fail:
|
||||||
|
msg: system_baseline ran with an invalid system_baseline_journal_max_use
|
||||||
|
rescue:
|
||||||
|
- name: The validation stopped the play
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that: "'system_baseline_journal_max_use must be' in ansible_failed_result.msg | default('')"
|
||||||
|
quiet: true
|
||||||
@@ -17,6 +17,16 @@
|
|||||||
- "'telnet' not in ansible_facts.packages"
|
- "'telnet' not in ansible_facts.packages"
|
||||||
quiet: true
|
quiet: true
|
||||||
|
|
||||||
|
# jq was absent before the role ran and is on no profile list: the extra list installed it, and the profile's own packages (tmux,
|
||||||
|
# curl above) are still there. ed was present and is on no profile list: the extra remove list purged it.
|
||||||
|
- name: The extra packages were installed and the extra removal purged
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- "'jq' in ansible_facts.packages"
|
||||||
|
- "'curl' in ansible_facts.packages"
|
||||||
|
- "'ed' not in ansible_facts.packages"
|
||||||
|
quiet: true
|
||||||
|
|
||||||
- name: Read the journald drop-in
|
- name: Read the journald drop-in
|
||||||
ansible.builtin.slurp:
|
ansible.builtin.slurp:
|
||||||
src: /etc/systemd/journald.conf.d/50-system-baseline.conf
|
src: /etc/systemd/journald.conf.d/50-system-baseline.conf
|
||||||
@@ -254,6 +264,51 @@
|
|||||||
that: not system_baseline_verify_removed.stat.exists
|
that: not system_baseline_verify_removed.stat.exists
|
||||||
quiet: true
|
quiet: true
|
||||||
|
|
||||||
|
# An extra tmux counts like a profile tmux: a flat package list without it installs no snippet, the same list plus the extra does.
|
||||||
|
- name: Run the tmux tasks with a flat package list that lacks tmux
|
||||||
|
ansible.builtin.include_role:
|
||||||
|
name: mortis.kamino.system_baseline
|
||||||
|
tasks_from: tmux
|
||||||
|
vars:
|
||||||
|
system_baseline_system_type: ubuntu_lxc
|
||||||
|
system_baseline_tmux_autostart: true
|
||||||
|
system_baseline_essential_packages: [vim]
|
||||||
|
|
||||||
|
- name: Stat the snippet without the extra
|
||||||
|
ansible.builtin.stat:
|
||||||
|
path: /etc/profile.d/tmux-autostart.sh
|
||||||
|
register: system_baseline_verify_no_extra
|
||||||
|
|
||||||
|
- name: Run the tmux tasks with tmux as an extra package
|
||||||
|
ansible.builtin.include_role:
|
||||||
|
name: mortis.kamino.system_baseline
|
||||||
|
tasks_from: tmux
|
||||||
|
vars:
|
||||||
|
system_baseline_system_type: ubuntu_lxc
|
||||||
|
system_baseline_tmux_autostart: true
|
||||||
|
system_baseline_essential_packages: [vim]
|
||||||
|
system_baseline_extra_packages: [tmux]
|
||||||
|
|
||||||
|
- name: Stat the snippet with the extra
|
||||||
|
ansible.builtin.stat:
|
||||||
|
path: /etc/profile.d/tmux-autostart.sh
|
||||||
|
register: system_baseline_verify_with_extra
|
||||||
|
|
||||||
|
- name: Only the extra tmux installs the snippet
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- not system_baseline_verify_no_extra.stat.exists
|
||||||
|
- system_baseline_verify_with_extra.stat.exists
|
||||||
|
quiet: true
|
||||||
|
|
||||||
|
- name: Remove the snippet again
|
||||||
|
ansible.builtin.include_role:
|
||||||
|
name: mortis.kamino.system_baseline
|
||||||
|
tasks_from: tmux
|
||||||
|
vars:
|
||||||
|
system_baseline_system_type: ubuntu_lxc
|
||||||
|
system_baseline_tmux_autostart: false
|
||||||
|
|
||||||
# The pve origins pin, run on this Ubuntu host: Ubuntu's 50unattended-upgrades sets Allowed-Origins, so the merged
|
# The pve origins pin, run on this Ubuntu host: Ubuntu's 50unattended-upgrades sets Allowed-Origins, so the merged
|
||||||
# configuration showing only the pinned patterns proves the drop-in clears the earlier lists instead of appending to them.
|
# configuration showing only the pinned patterns proves the drop-in clears the earlier lists instead of appending to them.
|
||||||
# The patterns match no Ubuntu origin, which only means nothing would be upgraded; the role's dry run still passes. Here
|
# The patterns match no Ubuntu origin, which only means nothing would be upgraded; the role's dry run still passes. Here
|
||||||
@@ -395,3 +450,48 @@
|
|||||||
- system_baseline_verify_blacklist_dump_removed.stdout_lines | select('match', 'Unattended-Upgrade::Package-Blacklist::\s') | list == []
|
- system_baseline_verify_blacklist_dump_removed.stdout_lines | select('match', 'Unattended-Upgrade::Package-Blacklist::\s') | list == []
|
||||||
quiet: true
|
quiet: true
|
||||||
tags: always
|
tags: always
|
||||||
|
|
||||||
|
# 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
|
||||||
|
# not set here) and the checks above read what the converge wrote.
|
||||||
|
# It removes what the converge wrote, so a second `molecule verify` needs a converge first.
|
||||||
|
- name: An empty journal size cap leaves journald alone
|
||||||
|
hosts: all
|
||||||
|
gather_facts: true
|
||||||
|
tasks:
|
||||||
|
- name: Remove the drop-in and its directory
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /etc/systemd/journald.conf.d
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: Note when journald last started
|
||||||
|
ansible.builtin.command:
|
||||||
|
argv: [systemctl, show, systemd-journald, --property=ActiveEnterTimestampMonotonic, --value]
|
||||||
|
register: system_baseline_verify_journald_before
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
- name: Run the role with an empty cap
|
||||||
|
ansible.builtin.include_role:
|
||||||
|
name: mortis.kamino.system_baseline
|
||||||
|
vars:
|
||||||
|
system_baseline_system_type: ubuntu_lxc
|
||||||
|
system_baseline_journal_max_use: ""
|
||||||
|
|
||||||
|
- name: Look for the drop-in directory
|
||||||
|
ansible.builtin.stat:
|
||||||
|
path: /etc/systemd/journald.conf.d
|
||||||
|
register: system_baseline_verify_journald_dir
|
||||||
|
|
||||||
|
- name: Note when journald last started, after the run
|
||||||
|
ansible.builtin.command:
|
||||||
|
argv: [systemctl, show, systemd-journald, --property=ActiveEnterTimestampMonotonic, --value]
|
||||||
|
register: system_baseline_verify_journald_after
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
- name: Nothing was written and journald was not restarted
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- not system_baseline_verify_journald_dir.stat.exists
|
||||||
|
- system_baseline_verify_journald_before.stdout | length > 0
|
||||||
|
- system_baseline_verify_journald_after.stdout == system_baseline_verify_journald_before.stdout
|
||||||
|
quiet: true
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
- name: Configure unattended-upgrades
|
- name: Configure unattended-upgrades
|
||||||
ansible.builtin.import_tasks: unattended_upgrades.yml
|
ansible.builtin.import_tasks: unattended_upgrades.yml
|
||||||
when: "'unattended-upgrades' in system_baseline_essential_packages"
|
when: "'unattended-upgrades' in __system_baseline_install_packages"
|
||||||
tags: unattended-upgrades
|
tags: unattended-upgrades
|
||||||
|
|
||||||
- name: Set locale
|
- name: Set locale
|
||||||
@@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
- name: Cap the journal size
|
- name: Cap the journal size
|
||||||
ansible.builtin.import_tasks: journald.yml
|
ansible.builtin.import_tasks: journald.yml
|
||||||
|
when: system_baseline_journal_max_use | length > 0
|
||||||
tags: journald
|
tags: journald
|
||||||
|
|
||||||
- name: Bound a hung apt-daily.service
|
- name: Bound a hung apt-daily.service
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
- name: Install essential packages
|
- name: Install essential packages
|
||||||
ansible.builtin.package:
|
ansible.builtin.package:
|
||||||
name: "{{ system_baseline_essential_packages }}"
|
name: "{{ __system_baseline_install_packages }}"
|
||||||
state: present
|
state: present
|
||||||
update_cache: true
|
update_cache: true
|
||||||
become: true
|
become: true
|
||||||
@@ -16,6 +16,6 @@
|
|||||||
name: "{{ item }}"
|
name: "{{ item }}"
|
||||||
state: absent
|
state: absent
|
||||||
purge: true
|
purge: true
|
||||||
loop: "{{ system_baseline_remove_packages }}"
|
loop: "{{ __system_baseline_purge_packages }}"
|
||||||
when: item in ansible_facts.packages
|
when: item in ansible_facts.packages
|
||||||
become: true
|
become: true
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
ansible.builtin.import_tasks: validate_reboot.yml
|
ansible.builtin.import_tasks: validate_reboot.yml
|
||||||
|
|
||||||
- name: Check if reboot required (Debian)
|
- name: Check if reboot required (Debian)
|
||||||
when: ansible_os_family == "Debian"
|
when: ansible_facts['os_family'] == "Debian"
|
||||||
block:
|
block:
|
||||||
- name: Check if reboot is required (Debian)
|
- name: Check if reboot is required (Debian)
|
||||||
ansible.builtin.stat:
|
ansible.builtin.stat:
|
||||||
|
|||||||
@@ -4,9 +4,10 @@
|
|||||||
# connection, so scp, sftp, `ssh host command` and automation never trigger it.
|
# connection, so scp, sftp, `ssh host command` and automation never trigger it.
|
||||||
# sshd's ForceCommand is deliberately not used: it applies to every session type and a broken tmux would lock out all of them.
|
# sshd's ForceCommand is deliberately not used: it applies to every session type and a broken tmux would lock out all of them.
|
||||||
#
|
#
|
||||||
# Installed when autostart is on and the resolved package list holds tmux (the ubuntu_lxc and ubuntu_vm profiles); the inputs are
|
# Installed when autostart is on and the packages to install hold tmux (the ubuntu_lxc and ubuntu_vm profiles, or
|
||||||
# checked in validate.yml. Security: the session name, window names and commands are role inputs (inventory), never read from a user
|
# system_baseline_extra_packages); the inputs are checked in validate.yml. Security: the session name, window names and commands are
|
||||||
# or a fact. They are validated and shell-quoted in the template. The script is root-owned and not writable by the users it runs for.
|
# role inputs (inventory), never read from a user or a fact. They are validated and shell-quoted in the template. The script is
|
||||||
|
# root-owned and not writable by the users it runs for.
|
||||||
# It is world-readable and the commands show in `ps`, so a command must hold no secret. Commands run as the user who logs in.
|
# It is world-readable and the commands show in `ps`, so a command must hold no secret. Commands run as the user who logs in.
|
||||||
- name: Install the tmux auto-start snippet
|
- name: Install the tmux auto-start snippet
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
@@ -16,12 +17,12 @@
|
|||||||
group: root
|
group: root
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
validate: /bin/sh -n %s
|
validate: /bin/sh -n %s
|
||||||
when: system_baseline_tmux_autostart | bool and 'tmux' in system_baseline_essential_packages
|
when: system_baseline_tmux_autostart | bool and 'tmux' in __system_baseline_install_packages
|
||||||
become: true
|
become: true
|
||||||
|
|
||||||
- name: Remove the tmux auto-start snippet
|
- name: Remove the tmux auto-start snippet
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: /etc/profile.d/tmux-autostart.sh
|
path: /etc/profile.d/tmux-autostart.sh
|
||||||
state: absent
|
state: absent
|
||||||
when: not (system_baseline_tmux_autostart | bool and 'tmux' in system_baseline_essential_packages)
|
when: not (system_baseline_tmux_autostart | bool and 'tmux' in __system_baseline_install_packages)
|
||||||
become: true
|
become: true
|
||||||
@@ -47,6 +47,19 @@
|
|||||||
ansible.builtin.import_tasks: validate_reboot.yml
|
ansible.builtin.import_tasks: validate_reboot.yml
|
||||||
tags: always
|
tags: always
|
||||||
|
|
||||||
|
# The value is written into a journald drop-in: a number and a unit letter, so a bare number (journald reads it as bytes), a space or a line
|
||||||
|
# break (a second directive) never reaches the file. Empty leaves the host alone, as for the apt-daily timeout.
|
||||||
|
- name: Validate the journal size cap
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- system_baseline_journal_max_use is string
|
||||||
|
- system_baseline_journal_max_use == '' or system_baseline_journal_max_use is match('^(infinity|[0-9]+[KMGT])\Z')
|
||||||
|
fail_msg: >-
|
||||||
|
system_baseline_journal_max_use must be empty (leave journald alone), infinity or a size such as 200M or 2G
|
||||||
|
(a number and one of K, M, G, T; a bare number is refused, journald would read it as bytes).
|
||||||
|
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
|
||||||
@@ -75,6 +88,43 @@
|
|||||||
quiet: true
|
quiet: true
|
||||||
tags: always
|
tags: always
|
||||||
|
|
||||||
|
# The extras are appended to the resolved lists. An item must be a Debian package name (policy: lower-case letters, digits, + - . , two or
|
||||||
|
# more characters, starting with a letter or digit), and not end in a minus: apt reads `jq-` as "remove jq", and a null item would become the
|
||||||
|
# package "None". A bare string is rejected here as it is for the blacklist. A package that one input installs and another purges would be
|
||||||
|
# installed and removed on every run, so it stops the run; only overlaps that involve an extra are checked, the resolved lists themselves
|
||||||
|
# are the consumer's.
|
||||||
|
- name: Validate the extra packages
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- system_baseline_extra_packages is sequence
|
||||||
|
- system_baseline_extra_packages is not string
|
||||||
|
- system_baseline_extra_packages is not mapping
|
||||||
|
- system_baseline_extra_packages | select('string') | select('match', '^[a-z0-9][a-z0-9+.-]*[a-z0-9+.]\Z') | list | length
|
||||||
|
== system_baseline_extra_packages | length
|
||||||
|
- system_baseline_extra_remove_packages is sequence
|
||||||
|
- system_baseline_extra_remove_packages is not string
|
||||||
|
- system_baseline_extra_remove_packages is not mapping
|
||||||
|
- system_baseline_extra_remove_packages | select('string') | select('match', '^[a-z0-9][a-z0-9+.-]*[a-z0-9+.]\Z') | list | length
|
||||||
|
== system_baseline_extra_remove_packages | length
|
||||||
|
fail_msg: >-
|
||||||
|
system_baseline_extra_packages and system_baseline_extra_remove_packages must be lists of package names: lower-case letters,
|
||||||
|
digits, + - . only, two or more characters, starting with a letter or digit and not ending in a minus.
|
||||||
|
quiet: true
|
||||||
|
tags: always
|
||||||
|
|
||||||
|
- name: Refuse a package that is both installed and purged
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- system_baseline_extra_packages | intersect(__system_baseline_purge_packages) | length == 0
|
||||||
|
- system_baseline_extra_remove_packages | intersect(__system_baseline_install_packages) | length == 0
|
||||||
|
fail_msg: >-
|
||||||
|
A package is both installed and purged. system_baseline_extra_packages must not name a package of system_baseline_remove_packages or
|
||||||
|
system_baseline_extra_remove_packages, and system_baseline_extra_remove_packages must not name a package of
|
||||||
|
system_baseline_essential_packages. Found: {{ (system_baseline_extra_packages | intersect(__system_baseline_purge_packages)) +
|
||||||
|
(system_baseline_extra_remove_packages | intersect(__system_baseline_install_packages)) }}.
|
||||||
|
quiet: true
|
||||||
|
tags: always
|
||||||
|
|
||||||
# Each origin is written inside a double-quoted apt.conf string: a quote or a line break would end it, a backslash could escape.
|
# Each origin is written inside a double-quoted apt.conf string: a quote or a line break would end it, a backslash could escape.
|
||||||
- name: Validate the unattended-upgrades origins
|
- name: Validate the unattended-upgrades origins
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
|
|||||||
@@ -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_version` | pinned in `defaults/main.yml` | no | Release tag to install. |
|
||||||
| `traefik_arch` | `amd64` | no | Archive architecture. |
|
| `traefik_arch` | `amd64` | no | Archive architecture. |
|
||||||
| `traefik_os` | `linux` | no | Archive OS. |
|
| `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_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_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. |
|
| `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
|
## 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 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.
|
- 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.
|
- 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).
|
- 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 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 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.
|
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_arch: "amd64"
|
||||||
traefik_os: "linux"
|
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_archive_name: "traefik_{{ traefik_version }}_{{ traefik_os }}_{{ traefik_arch }}.tar.gz"
|
||||||
traefik_local_archive: "/tmp/traefik.tar.gz"
|
traefik_local_archive: "/tmp/traefik.tar.gz"
|
||||||
|
|
||||||
|
|||||||
@@ -63,6 +63,14 @@ argument_specs:
|
|||||||
default: linux
|
default: linux
|
||||||
description:
|
description:
|
||||||
- Operating system part of the release archive name.
|
- 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:
|
traefik_archive_name:
|
||||||
type: raw
|
type: raw
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -2,8 +2,9 @@
|
|||||||
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404
|
# 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
|
# (MOLECULE_IMAGE) and molecule-ubuntu2604 (MOLECULE_IMAGE_2604) images, pinned in
|
||||||
# .gitea/workflows/molecule.yml. Needs outbound network, unlike most scenarios: the role installs
|
# .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
|
# packages with apt and the converge downloads the Traefik release from GitHub (verify's update
|
||||||
# writable cgroup and the firewall tools need NET_ADMIN.
|
# 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:
|
driver:
|
||||||
name: docker
|
name: docker
|
||||||
platforms:
|
platforms:
|
||||||
@@ -54,6 +55,9 @@ provisioner:
|
|||||||
traefik_cloudflare_email: [email protected]
|
traefik_cloudflare_email: [email protected]
|
||||||
traefik_cloudflare_api_token: molecule-not-a-token
|
traefik_cloudflare_api_token: molecule-not-a-token
|
||||||
traefik_domain: example.test
|
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:
|
ufw_rules:
|
||||||
- {rule: allow, port: 22, proto: tcp, comment: ssh}
|
- {rule: allow, port: 22, proto: tcp, comment: ssh}
|
||||||
# TEST-NET-1 address: nothing answers, the value only has to render
|
# TEST-NET-1 address: nothing answers, the value only has to render
|
||||||
|
|||||||
@@ -40,3 +40,55 @@
|
|||||||
ProtectKernelTunables=no
|
ProtectKernelTunables=no
|
||||||
ReadWritePaths=
|
ReadWritePaths=
|
||||||
User=
|
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:
|
vars:
|
||||||
traefik_update: true
|
traefik_update: true
|
||||||
traefik_version: "{{ traefik_verify_target }}"
|
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 }}
|
- name: Read the Traefik version after the update to {{ traefik_verify_target }}
|
||||||
ansible.builtin.command: /usr/local/bin/traefik version
|
ansible.builtin.command: /usr/local/bin/traefik version
|
||||||
|
|||||||
@@ -107,13 +107,40 @@
|
|||||||
name: traefik
|
name: traefik
|
||||||
register: traefik_unit
|
register: traefik_unit
|
||||||
|
|
||||||
- name: Let the ACME failures against the dummy credentials play out
|
# The dummy credentials make the ACME request fail, logged as "Unable to obtain ACME certificate
|
||||||
ansible.builtin.pause:
|
# for domain(s)". The log keeps the lines of the process converge restarted, so only a line
|
||||||
seconds: 15
|
# 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:
|
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
|
- name: The pinned version is installed
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
@@ -224,6 +251,8 @@
|
|||||||
that:
|
that:
|
||||||
- ansible_facts.services['traefik.service'].state == 'running'
|
- ansible_facts.services['traefik.service'].state == 'running'
|
||||||
- ansible_facts.services['traefik.service'].status == 'enabled'
|
- 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.NoNewPrivileges == 'yes'
|
||||||
- traefik_unit.status.MemoryDenyWriteExecute == 'yes'
|
- traefik_unit.status.MemoryDenyWriteExecute == 'yes'
|
||||||
- "'cap_net_bind_service' in traefik_unit.status.AmbientCapabilities | lower"
|
- "'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_key_443: "{{ ('allow|443|||||in' | hash('sha1'))[:10] }}"
|
||||||
traefik_ufw_tagged: "{{ traefik_ufw_added.stdout_lines | select('match', '^ufw ') | select('search', 'ansible-ufw') | list }}"
|
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
|
# 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. After the idempotence step,
|
# release and back to the role default, both with traefik_update, from prepare.yml's stand-ins.
|
||||||
# because each run changes the binary, and before the remove path, which deletes it.
|
# After the idempotence step, because each run changes the binary, and before the remove path.
|
||||||
- name: Verify the update path with real Traefik releases
|
# 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
|
hosts: all
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
vars_files:
|
vars_files:
|
||||||
- ../../defaults/main.yml
|
- ../../defaults/main.yml
|
||||||
vars:
|
|
||||||
# Any published release other than the role default, with a checksum file.
|
|
||||||
traefik_verify_other_version: v3.7.18
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: The other release differs from the role default
|
- name: The other release differs from the role default
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
# would otherwise be kept and then fail the checksum check.
|
# would otherwise be kept and then fail the checksum check.
|
||||||
- name: Download Traefik archive
|
- name: Download Traefik archive
|
||||||
ansible.builtin.get_url:
|
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 }}"
|
dest: "{{ traefik_local_archive }}"
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
force: true
|
force: true
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
- name: Download Traefik checksums
|
- name: Download Traefik checksums
|
||||||
ansible.builtin.get_url:
|
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
|
dest: /tmp/traefik_checksums.txt
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
force: true
|
force: true
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
- name: The removed user is gone
|
- name: The removed user is gone
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that: "'um-olduser' not in getent_passwd"
|
that: "'um-olduser' not in ansible_facts['getent_passwd']"
|
||||||
quiet: true
|
quiet: true
|
||||||
|
|
||||||
- name: Read group membership
|
- name: Read group membership
|
||||||
@@ -74,7 +74,7 @@
|
|||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- user_management_test_admin_key in (user_management_verify_keys.results[0].content | b64decode)
|
- user_management_test_admin_key in (user_management_verify_keys.results[0].content | b64decode)
|
||||||
- getent_passwd['um-admin'][5] != '/usr/sbin/nologin'
|
- ansible_facts['getent_passwd']['um-admin'][5] != '/usr/sbin/nologin'
|
||||||
quiet: true
|
quiet: true
|
||||||
|
|
||||||
- name: Read root's shadow entry
|
- name: Read root's shadow entry
|
||||||
@@ -86,7 +86,7 @@
|
|||||||
- name: Root's password is locked
|
- name: Root's password is locked
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- getent_shadow['root'][0] == '!'
|
- ansible_facts['getent_shadow']['root'][0] == '!'
|
||||||
quiet: true
|
quiet: true
|
||||||
|
|
||||||
- name: Read root's authorized_keys
|
- name: Read root's authorized_keys
|
||||||
@@ -98,5 +98,5 @@
|
|||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- (user_management_verify_root_keys.content | b64decode) is search('root-key$', multiline=true)
|
- (user_management_verify_root_keys.content | b64decode) is search('root-key$', multiline=true)
|
||||||
- getent_passwd['root'][5] == '/bin/bash'
|
- ansible_facts['getent_passwd']['root'][5] == '/bin/bash'
|
||||||
quiet: true
|
quiet: true
|
||||||
@@ -32,5 +32,8 @@ molecule --version
|
|||||||
# The collection under test first; molecule also installs it into each scenario's ANSIBLE_HOME,
|
# The collection under test first; molecule also installs it into each scenario's ANSIBLE_HOME,
|
||||||
# which the run script keeps in the job tree.
|
# which the run script keeps in the job tree.
|
||||||
export ANSIBLE_COLLECTIONS_PATH="$AC_ROOT:${extra_collections}/opt/collections"
|
export ANSIBLE_COLLECTIONS_PATH="$AC_ROOT:${extra_collections}/opt/collections"
|
||||||
|
# Facts are not injected as variables (deprecated in ansible-core 2.22, removal scheduled for 2.24, see #364), so a
|
||||||
|
# role that reads a bare `ansible_<fact>` fails its scenario here instead of in a consumer's inventory.
|
||||||
|
export ANSIBLE_INJECT_FACT_VARS=False
|
||||||
python3 -I scripts/check_scenarios_load_checkout.py <<< "$selected"
|
python3 -I scripts/check_scenarios_load_checkout.py <<< "$selected"
|
||||||
exec scripts/run_molecule_scenarios.sh "$AC_ROOT/molecule-runs" <<< "$selected"
|
exec scripts/run_molecule_scenarios.sh "$AC_ROOT/molecule-runs" <<< "$selected"
|
||||||
@@ -42,7 +42,7 @@ exit 0
|
|||||||
|
|
||||||
# The scenario runner: records its arguments, paths and stdin.
|
# The scenario runner: records its arguments, paths and stdin.
|
||||||
RUNNER_STUB = """#!/usr/bin/env bash
|
RUNNER_STUB = """#!/usr/bin/env bash
|
||||||
echo "runner args=$* path=$PATH acp=$ANSIBLE_COLLECTIONS_PATH stdin=[$(cat | tr '\\n' ' ')]" >> "$STUB_LOG"
|
echo "runner args=$* path=$PATH acp=$ANSIBLE_COLLECTIONS_PATH inject=${ANSIBLE_INJECT_FACT_VARS-unset} stdin=[$(cat | tr '\\n' ' ')]" >> "$STUB_LOG"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
@@ -112,6 +112,16 @@ class RunMoleculeInCiImageTest(unittest.TestCase):
|
|||||||
self.assertIn(f"acp={self.ac_root}:/opt/collections ", runner)
|
self.assertIn(f"acp={self.ac_root}:/opt/collections ", runner)
|
||||||
self.assertIn(f"args={self.ac_root}/molecule-runs ", runner)
|
self.assertIn(f"args={self.ac_root}/molecule-runs ", runner)
|
||||||
|
|
||||||
|
def test_scenarios_run_with_fact_injection_off(self):
|
||||||
|
# A role that reads a bare ansible_<fact> must fail its scenario here (#364), whichever way the pins went.
|
||||||
|
for fail in ("", "1"):
|
||||||
|
with self.subTest(pins_differ=bool(fail)):
|
||||||
|
self.log.write_text("")
|
||||||
|
result = self.run_script(STUB_FAIL_sha256sum=fail)
|
||||||
|
self.assertEqual(result.returncode, 0, result.stderr)
|
||||||
|
(runner,) = self.calls("runner")
|
||||||
|
self.assertIn(" inject=False ", runner)
|
||||||
|
|
||||||
def test_changed_pins_are_installed_and_put_first(self):
|
def test_changed_pins_are_installed_and_put_first(self):
|
||||||
result = self.run_script(STUB_FAIL_sha256sum="1")
|
result = self.run_script(STUB_FAIL_sha256sum="1")
|
||||||
self.assertEqual(result.returncode, 0, result.stderr)
|
self.assertEqual(result.returncode, 0, result.stderr)
|
||||||
|
|||||||
Reference in new issue
Block a user