Compare commits
65
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1048628cc4 | ||
|
|
6e3ea4521b | ||
|
|
7433a37697 | ||
|
|
0b8c45a19c | ||
|
|
2d4d44b871 | ||
|
|
d862097b9c | ||
|
|
6670ab664f | ||
|
|
1372c257c2 | ||
|
|
18475ea0a5 | ||
|
|
e2df672be7 | ||
|
|
2e92b11cbc | ||
|
|
7311a27e43 | ||
|
|
19449f7e93 | ||
|
|
84ad29b18b | ||
|
|
6d505c0db7 | ||
|
|
3bf9ae0efe | ||
|
|
fbc8b1b6d7 | ||
|
|
7c068c2b47 | ||
|
|
c51fa998b9 | ||
|
|
2eb7da3563 | ||
|
|
3a5040aae8 | ||
|
|
6a2060bd31 | ||
|
|
11fec7c8fc | ||
|
|
40e3b39990 | ||
|
|
e1a46fcdb1 | ||
|
|
4d5042a31f | ||
|
|
d5a91520df | ||
|
|
7c148e858d | ||
|
|
f7fde63f7d | ||
|
|
a659e83e6b | ||
|
|
464cc5848b | ||
|
|
1afce962a0 | ||
|
|
d1b4501c2b | ||
|
|
e3d5c35fcd | ||
|
|
aa4e8c68a7 | ||
|
|
26b6e37a09 | ||
|
|
4f9b96b2f4 | ||
|
|
87280a2f60 | ||
|
|
2b1301d838 | ||
|
|
288cea47a9 | ||
|
|
731bc022cd | ||
|
|
29165a610f | ||
|
|
9c415ee347 | ||
|
|
3b20a1b6c6 | ||
|
|
80c76b16ee | ||
|
|
31634c4eef | ||
|
|
6b99ac9ca0 | ||
|
|
9ce0fbd433 | ||
|
|
3afff00b9b | ||
|
|
824456ea65 | ||
|
|
cf2286b7a7 | ||
|
|
b8ad7fc0a6 | ||
|
|
51b38211e7 | ||
|
|
27c4ca14c4 | ||
|
|
ff13f2d3a4 | ||
|
|
7a4e9f161e | ||
|
|
11c5e1987f | ||
|
|
6fe3970f23 | ||
|
|
042c926058 | ||
|
|
6ab8b82fba | ||
|
|
a6b8bc150d | ||
|
|
5f936962e0 | ||
|
|
1f27f02f13 | ||
|
|
df06260b27 | ||
|
|
2e1ad033e4 |
No files matched your search
+5
-4
@@ -24,7 +24,8 @@ exclude_paths:
|
|||||||
supported_ansible_also:
|
supported_ansible_also:
|
||||||
- "2.22."
|
- "2.22."
|
||||||
|
|
||||||
skip_list:
|
# complexity runs at the default max_tasks (100) until the schema accepts the key (#139). An empty
|
||||||
# role-name requires ^[a-z][a-z0-9_]*$, which rejects the leading underscore that marks an
|
# warn_list makes experimental rules (complexity), jinja[spacing] and fqcn[deep] fail Lint.
|
||||||
# internal role (_binary_update), as in prometheus.prometheus (roles/_common).
|
enable_list:
|
||||||
- role-name
|
- complexity
|
||||||
|
warn_list: []
|
||||||
@@ -9,3 +9,6 @@ roles/_binary_update/molecule/check_mode/verify.yml var-naming[no-role-prefix]
|
|||||||
roles/_binary_update/molecule/default/verify.yml var-naming[no-role-prefix]
|
roles/_binary_update/molecule/default/verify.yml var-naming[no-role-prefix]
|
||||||
roles/_binary_update/molecule/default/tasks/assert_state.yml var-naming[no-role-prefix]
|
roles/_binary_update/molecule/default/tasks/assert_state.yml var-naming[no-role-prefix]
|
||||||
roles/_binary_update/molecule/resources/roles/binary_update_caller/tasks/main.yml var-naming[no-role-prefix]
|
roles/_binary_update/molecule/resources/roles/binary_update_caller/tasks/main.yml var-naming[no-role-prefix]
|
||||||
|
# role-name requires ^[a-z][a-z0-9_]*$, which rejects the leading underscore that marks an
|
||||||
|
# internal role (_binary_update), as in prometheus.prometheus (roles/_common).
|
||||||
|
roles/_binary_update role-name
|
||||||
@@ -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.
|
||||||
@@ -110,14 +118,16 @@ issue.
|
|||||||
*Why:* a pull request that raises the ansible-core floor must run its scenarios on the new core
|
*Why:* a pull request that raises the ansible-core floor must run its scenarios on the new core
|
||||||
before it automerges. *Held:* control: the pin comparison in `molecule.yml`.
|
before it automerges. *Held:* control: the pin comparison in `molecule.yml`.
|
||||||
- **Every scenario sets `scenario.test_sequence` to molecule's default minus both `destroy`
|
- **Every scenario sets `scenario.test_sequence` to molecule's default minus both `destroy`
|
||||||
steps, names each platform `${KAMINO_RUN_ID:-local}-<name>` and labels it
|
steps, with a role scenario's `check` right before and right after `converge`, names each
|
||||||
|
platform `${KAMINO_RUN_ID:-local}-<name>` and labels it
|
||||||
`net.rkdr.mortis.molecule-run: "${KAMINO_RUN_ID:-local}"` in its `molecule.yml`;** copy it into
|
`net.rkdr.mortis.molecule-run: "${KAMINO_RUN_ID:-local}"` in its `molecule.yml`;** copy it into
|
||||||
a new scenario. *Why:* the run script removes each scenario's containers by those names as soon
|
a new scenario. *Why:* the run script removes each scenario's containers by those names as soon
|
||||||
as it ends, which skips the driver's destroy wait, the workflow finds a run's containers by the
|
as it ends, which skips the driver's destroy wait, the workflow finds a run's containers by the
|
||||||
label, and the molecule state lives in each scenario's own `ANSIBLE_HOME` in the job tree, so a
|
label, and the molecule state lives in each scenario's own `ANSIBLE_HOME` in the job tree, so a
|
||||||
killed run leaves none behind. *Held:* control: `tests/scripts/test_run_molecule_scenarios.py`
|
killed run leaves none behind. *Held:* control: `tests/scripts/test_run_molecule_scenarios.py`
|
||||||
fails a `destroy` in a sequence, a platform name that is not unique or not per run, a missing
|
fails a `destroy` in a sequence, a role scenario's `converge` without a `check` on each side, a
|
||||||
label, and a workflow that does not filter by it.
|
platform name that is not unique or not per run, a missing label, and a workflow that does not
|
||||||
|
filter by it.
|
||||||
- **Scenarios live in `roles/*/molecule/*/` and `extensions/molecule/*/`.** A role scenario that
|
- **Scenarios live in `roles/*/molecule/*/` and `extensions/molecule/*/`.** A role scenario that
|
||||||
must pass on Ubuntu 24.04 and 26.04 takes `image: ${MOLECULE_IMAGE}` or
|
must pass on Ubuntu 24.04 and 26.04 takes `image: ${MOLECULE_IMAGE}` or
|
||||||
`${MOLECULE_IMAGE_2604}` per platform; the image-smoke scenarios are described in
|
`${MOLECULE_IMAGE_2604}` per platform; the image-smoke scenarios are described in
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ jobs:
|
|||||||
timeout-minutes: 30
|
timeout-minutes: 30
|
||||||
# The ci image (images/ci, built by image.yml): tag for the release, digest enforced.
|
# The ci image (images/ci, built by image.yml): tag for the release, digest enforced.
|
||||||
container:
|
container:
|
||||||
image: git.rkdr.net/mortis/ci:0.2.45@sha256:922febf5bdccbc773a4f7f52cf118498d029f27a7c56b33c9b6f43ac2b6c2d32
|
image: git.rkdr.net/mortis/ci:0.2.46@sha256:a03015cc2177bdd6ef7f348f245a89f361893c7c64edc1264d9f9c1387d9defc
|
||||||
env:
|
env:
|
||||||
PIP_DISABLE_PIP_VERSION_CHECK: "1"
|
PIP_DISABLE_PIP_VERSION_CHECK: "1"
|
||||||
steps:
|
steps:
|
||||||
@@ -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;" \
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ jobs:
|
|||||||
# The ci image (images/ci, built by image.yml), at the pin of lint.yml: tag for the
|
# The ci image (images/ci, built by image.yml), at the pin of lint.yml: tag for the
|
||||||
# release, digest enforced. Only its /opt/venv Python (with PyYAML) is used here.
|
# release, digest enforced. Only its /opt/venv Python (with PyYAML) is used here.
|
||||||
container:
|
container:
|
||||||
image: git.rkdr.net/mortis/ci:0.2.45@sha256:922febf5bdccbc773a4f7f52cf118498d029f27a7c56b33c9b6f43ac2b6c2d32
|
image: git.rkdr.net/mortis/ci:0.2.46@sha256:a03015cc2177bdd6ef7f348f245a89f361893c7c64edc1264d9f9c1387d9defc
|
||||||
steps:
|
steps:
|
||||||
# The container has no Node, so JavaScript actions such as actions/checkout
|
# The container has no Node, so JavaScript actions such as actions/checkout
|
||||||
# cannot run; clone with git and the job token.
|
# cannot run; clone with git and the job token.
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ jobs:
|
|||||||
# The tag says which release, the digest is what is enforced (bump both together
|
# The tag says which release, the digest is what is enforced (bump both together
|
||||||
# when image.yml publishes a new version).
|
# when image.yml publishes a new version).
|
||||||
container:
|
container:
|
||||||
image: git.rkdr.net/mortis/ci:0.2.45@sha256:922febf5bdccbc773a4f7f52cf118498d029f27a7c56b33c9b6f43ac2b6c2d32
|
image: git.rkdr.net/mortis/ci:0.2.46@sha256:a03015cc2177bdd6ef7f348f245a89f361893c7c64edc1264d9f9c1387d9defc
|
||||||
env:
|
env:
|
||||||
PIP_DISABLE_PIP_VERSION_CHECK: "1"
|
PIP_DISABLE_PIP_VERSION_CHECK: "1"
|
||||||
PRE_COMMIT_HOME: /opt/pre-commit
|
PRE_COMMIT_HOME: /opt/pre-commit
|
||||||
@@ -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,14 +47,13 @@ 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: >-
|
||||||
git.rkdr.net/mortis/ci:0.2.45@sha256:922febf5bdccbc773a4f7f52cf118498d029f27a7c56b33c9b6f43ac2b6c2d32
|
git.rkdr.net/mortis/ci:0.2.46@sha256:a03015cc2177bdd6ef7f348f245a89f361893c7c64edc1264d9f9c1387d9defc
|
||||||
# Used by the scenarios as `image: ${MOLECULE_IMAGE}`; set it the same way to run
|
# Used by the scenarios as `image: ${MOLECULE_IMAGE}`; set it the same way to run
|
||||||
# one locally.
|
# one locally.
|
||||||
MOLECULE_IMAGE: >-
|
MOLECULE_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
|
||||||
|
|||||||
@@ -4,6 +4,38 @@ mortis.kamino Release Notes
|
|||||||
|
|
||||||
.. contents:: Topics
|
.. contents:: Topics
|
||||||
|
|
||||||
|
v3.1.0
|
||||||
|
======
|
||||||
|
|
||||||
|
Minor Changes
|
||||||
|
-------------
|
||||||
|
|
||||||
|
- tailscale - New role. Installs Tailscale from the upstream APT repository with the keyring pinned by sha256, sets ``--tun=userspace-networking`` in the ``tailscaled`` flags when ``tailscale_userspace_networking`` is true, enables ``tailscaled`` and, with ``tailscale_up`` (default ``true``), runs ``tailscale up`` with ``tailscale_auth_key`` while the node is not Running; it can also update to the APT candidate version and remove or purge. Declares Ubuntu noble and resolute; the molecule scenario installs the real package but does not join a tailnet.
|
||||||
|
|
||||||
|
Bugfixes
|
||||||
|
--------
|
||||||
|
|
||||||
|
- cloudflared - Do not fail under ``--check`` on a host where the cloudflared account or systemd unit does not exist yet.
|
||||||
|
- docker - Do not fail under ``--check`` on a host where the Docker repository and packages are not installed yet.
|
||||||
|
- gitea - Do not fail under ``--check`` on a host where Gitea is not installed yet.
|
||||||
|
- gitea_runner - Do not fail under ``--check`` on a host where the runner account, Docker or the systemd unit does not exist yet.
|
||||||
|
- traefik - Do not fail under ``--check`` on a host where Traefik is not installed yet.
|
||||||
|
- user_management - Do not fail under ``--check`` when a managed user does not exist yet.
|
||||||
|
|
||||||
|
v3.0.0
|
||||||
|
======
|
||||||
|
|
||||||
|
Minor Changes
|
||||||
|
-------------
|
||||||
|
|
||||||
|
- cloudflared, docker, fail2ban, gitea, gitea_runner, pihole, sshd, system_baseline, systemd_hardening, traefik, ufw, user_management - Declare and are tested on Ubuntu 26.04 (``resolute``) next to 24.04 (``noble``).
|
||||||
|
|
||||||
|
Breaking Changes / Porting Guide
|
||||||
|
--------------------------------
|
||||||
|
|
||||||
|
- docker - Declares Ubuntu 24.04 (``noble``) and 26.04 (``resolute``) instead of every Ubuntu release (``all``).
|
||||||
|
- sshd, system_baseline, systemd_hardening, ufw, user_management - No longer declare Ubuntu 22.04 (``jammy``). A platform a role declares is one it passes Molecule on in CI.
|
||||||
|
|
||||||
v2.2.0
|
v2.2.0
|
||||||
======
|
======
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
An Ansible Collection of reusable, hardened roles for a self-hosted home lab:
|
An Ansible Collection of reusable, hardened roles for a self-hosted home lab:
|
||||||
`cloudflared`, `docker`, `fail2ban`, `gitea`, `gitea_runner`, `network_interfaces`,
|
`cloudflared`, `docker`, `fail2ban`, `gitea`, `gitea_runner`, `network_interfaces`,
|
||||||
`pihole`, `pve_lxc`, `sshd`, `system_baseline`, `systemd_hardening`, `traefik`, `ufw` and
|
`pihole`, `pve_lxc`, `sshd`, `system_baseline`, `systemd_hardening`, `tailscale`, `traefik`, `ufw` and
|
||||||
`user_management`, plus the internal `_binary_update`. Roles still to come are listed under [Roadmap](#roadmap).
|
`user_management`, plus the internal `_binary_update`. Roles still to come are listed under [Roadmap](#roadmap).
|
||||||
|
|
||||||
Status: roles arrive in waves. Release 2.2.0 holds the `cloudflared`, `docker`, `fail2ban`, `gitea`, `gitea_runner`, `network_interfaces`, `pihole`, `pve_lxc`, `sshd`, `system_baseline`, `systemd_hardening`, `traefik`, `ufw` and `user_management` roles (and the internal `_binary_update`, which `cloudflared`, `gitea`, `gitea_runner` and `traefik` call).
|
Status: roles arrive in waves. Release 3.1.0 holds the `cloudflared`, `docker`, `fail2ban`, `gitea`, `gitea_runner`, `network_interfaces`, `pihole`, `pve_lxc`, `sshd`, `system_baseline`, `systemd_hardening`, `tailscale`, `traefik`, `ufw` and `user_management` roles (and the internal `_binary_update`, which `cloudflared`, `gitea`, `gitea_runner` and `traefik` call).
|
||||||
|
|
||||||
## Consuming
|
## Consuming
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ name (FQCN) only, `mortis.kamino.<role>`:
|
|||||||
collections:
|
collections:
|
||||||
- name: https://git.rkdr.net/mortis/kamino.git
|
- name: https://git.rkdr.net/mortis/kamino.git
|
||||||
type: git
|
type: git
|
||||||
version: v2.2.0
|
version: v3.1.0
|
||||||
```
|
```
|
||||||
|
|
||||||
Its dependencies (`community.general`, `ansible.posix`, `community.proxmox`) are declared in `galaxy.yml`, so
|
Its dependencies (`community.general`, `ansible.posix`, `community.proxmox`) are declared in `galaxy.yml`, so
|
||||||
@@ -41,7 +41,7 @@ when its own prerequisites (tests, a safe cutover wherever the role already runs
|
|||||||
|
|
||||||
Still to come:
|
Still to come:
|
||||||
|
|
||||||
- Wave 2: `pve_vm`, `tailscale`.
|
- Wave 2: `pve_vm`.
|
||||||
- Wave 3: `rke2`, `proxmox_host`.
|
- Wave 3: `rke2`, `proxmox_host`.
|
||||||
- Later, wave not yet assigned: `opnsense`, `proxmox_firewall`.
|
- Later, wave not yet assigned: `opnsense`, `proxmox_firewall`.
|
||||||
|
|
||||||
|
|||||||
+25
@@ -98,3 +98,28 @@ reduction. A later decision that accepts a risk adds an entry here.
|
|||||||
already reaches every secret. There is no `renovate/*` push allowlist.
|
already reaches every secret. There is no `renovate/*` push allowlist.
|
||||||
- **Trigger:** a token that can push here but cannot reach the secrets.
|
- **Trigger:** a token that can push here but cannot reach the secrets.
|
||||||
- **Planned reduction:** none for now.
|
- **Planned reduction:** none for now.
|
||||||
|
|
||||||
|
### No Molecule run after a merge
|
||||||
|
|
||||||
|
- **Risk:** Molecule does not run on push to `main`
|
||||||
|
([ADR 0002](docs/adr/0002-self-built-ci-and-molecule-images.md)). Only the nightly full run
|
||||||
|
catches drift outside the tree (mirrors, images) or a scenario-selection mistake, and it is
|
||||||
|
the only run of the scenarios a pull request's diff did not select.
|
||||||
|
- **Why accepted:** "block on outdated branch" is on, so `main` only ever receives the tree its
|
||||||
|
pull request tested; no Molecule run on `main` failed after its pull request passed (3 to 17
|
||||||
|
November 2026).
|
||||||
|
- **Trigger:** a nightly run fails on a tree whose pull request passed.
|
||||||
|
- **Planned reduction:** none for now.
|
||||||
|
|
||||||
|
### Pin bumps first behaviour-tested after they merge
|
||||||
|
|
||||||
|
- **Risk:** Lint, Build and Molecule install a pull request's pins when they differ from the
|
||||||
|
image, so a pull request that changes an image input is tested on its own pins. But most pin
|
||||||
|
bumps select no Molecule scenario: every Python pin except an ansible-core minor bump, which
|
||||||
|
edits `meta/runtime.yml`. Such a bump is first behaviour-tested after it has merged, by the
|
||||||
|
pull request that moves the workflows to the new `ci` image.
|
||||||
|
- **Why accepted:** that pull request runs every scenario before the new image is used,
|
||||||
|
and running every scenario on every Python pin bump would cost about 10 minutes each.
|
||||||
|
- **Trigger:** the pull request that moves the workflows to a new `ci` image fails Molecule
|
||||||
|
because of a bumped pin.
|
||||||
|
- **Planned reduction:** none for now.
|
||||||
@@ -51,6 +51,10 @@ objects:
|
|||||||
description: Harden systemd for a system type
|
description: Harden systemd for a system type
|
||||||
name: systemd_hardening
|
name: systemd_hardening
|
||||||
version_added: null
|
version_added: null
|
||||||
|
tailscale:
|
||||||
|
description: Install Tailscale and bring the node up
|
||||||
|
name: tailscale
|
||||||
|
version_added: null
|
||||||
traefik:
|
traefik:
|
||||||
description: Install, configure, update or remove Traefik as a systemd binary
|
description: Install, configure, update or remove Traefik as a systemd binary
|
||||||
name: traefik
|
name: traefik
|
||||||
@@ -81,4 +85,4 @@ plugins:
|
|||||||
strategy: {}
|
strategy: {}
|
||||||
test: {}
|
test: {}
|
||||||
vars: {}
|
vars: {}
|
||||||
version: 2.2.0
|
version: 3.1.0
|
||||||
@@ -430,3 +430,47 @@ releases:
|
|||||||
- 386-community-proxmox-dependency.yml
|
- 386-community-proxmox-dependency.yml
|
||||||
- pve-lxc-role.yml
|
- pve-lxc-role.yml
|
||||||
release_date: '2026-11-25'
|
release_date: '2026-11-25'
|
||||||
|
3.0.0:
|
||||||
|
changes:
|
||||||
|
breaking_changes:
|
||||||
|
- docker - Declares Ubuntu 24.04 (``noble``) and 26.04 (``resolute``) instead
|
||||||
|
of every Ubuntu release (``all``).
|
||||||
|
- sshd, system_baseline, systemd_hardening, ufw, user_management - No longer
|
||||||
|
declare Ubuntu 22.04 (``jammy``). A platform a role declares is one it passes
|
||||||
|
Molecule on in CI.
|
||||||
|
minor_changes:
|
||||||
|
- cloudflared, docker, fail2ban, gitea, gitea_runner, pihole, sshd, system_baseline,
|
||||||
|
systemd_hardening, traefik, ufw, user_management - Declare and are tested
|
||||||
|
on Ubuntu 26.04 (``resolute``) next to 24.04 (``noble``).
|
||||||
|
fragments:
|
||||||
|
- 133-drop-jammy-and-ubuntu-all.yml
|
||||||
|
- 133-ubuntu-2604.yml
|
||||||
|
release_date: '2026-11-26'
|
||||||
|
3.1.0:
|
||||||
|
changes:
|
||||||
|
bugfixes:
|
||||||
|
- cloudflared - Do not fail under ``--check`` on a host where the cloudflared
|
||||||
|
account or systemd unit does not exist yet.
|
||||||
|
- docker - Do not fail under ``--check`` on a host where the Docker repository
|
||||||
|
and packages are not installed yet.
|
||||||
|
- gitea - Do not fail under ``--check`` on a host where Gitea is not installed
|
||||||
|
yet.
|
||||||
|
- gitea_runner - Do not fail under ``--check`` on a host where the runner account,
|
||||||
|
Docker or the systemd unit does not exist yet.
|
||||||
|
- traefik - Do not fail under ``--check`` on a host where Traefik is not installed
|
||||||
|
yet.
|
||||||
|
- user_management - Do not fail under ``--check`` when a managed user does not
|
||||||
|
exist yet.
|
||||||
|
minor_changes:
|
||||||
|
- tailscale - New role. Installs Tailscale from the upstream APT repository
|
||||||
|
with the keyring pinned by sha256, sets ``--tun=userspace-networking`` in
|
||||||
|
the ``tailscaled`` flags when ``tailscale_userspace_networking`` is true,
|
||||||
|
enables ``tailscaled`` and, with ``tailscale_up`` (default ``true``), runs
|
||||||
|
``tailscale up`` with ``tailscale_auth_key`` while the node is not Running;
|
||||||
|
it can also update to the APT candidate version and remove or purge. Declares
|
||||||
|
Ubuntu noble and resolute; the molecule scenario installs the real package
|
||||||
|
but does not join a tailnet.
|
||||||
|
fragments:
|
||||||
|
- 134-check-mode.yml
|
||||||
|
- tailscale-role.yml
|
||||||
|
release_date: '2026-11-26'
|
||||||
@@ -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,6 @@
|
|||||||
|
---
|
||||||
|
minor_changes:
|
||||||
|
- >-
|
||||||
|
cloudflared - New input ``cloudflared_tunnel_lookup_delay``, the seconds between the three
|
||||||
|
retries of a 404 from the tunnel lookup while a new tunnel may not be visible yet. The default
|
||||||
|
is 5, as before.
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
# 0002. Self-built CI and molecule images, versioned by CI, pinned by version and digest
|
||||||
|
|
||||||
|
Status: accepted
|
||||||
|
|
||||||
|
## Context
|
||||||
|
|
||||||
|
Every CI job runs on one shared runner. Installing the toolchain in each job is simple but slow.
|
||||||
|
Building our own images is faster but adds machinery: Dockerfiles, an image build, version tags
|
||||||
|
and pin updates. The choice is hard to undo once every workflow pins an image.
|
||||||
|
|
||||||
|
## Decision
|
||||||
|
|
||||||
|
- **We build our own images:** a `ci` image, and one Dockerfile per molecule image (one per Ubuntu
|
||||||
|
release, and later the Debian 13 one).
|
||||||
|
- **The molecule images bake in everything except what a role installs itself.** The test
|
||||||
|
fixtures a scenario's `prepare.yml` needs are baked in. Packages a role installs are still
|
||||||
|
downloaded, because that install path is what the test exercises. A converge is not kept off
|
||||||
|
the network.
|
||||||
|
- **Consumers pin `<version>@sha256:<digest>`.**
|
||||||
|
- **CI assigns the patch version from the image's inputs.** A published tag is never moved.
|
||||||
|
- **The pin follows each build through Renovate.**
|
||||||
|
- **Molecule runs are isolated per run:** per-run container names and labels, and no shared
|
||||||
|
concurrency group. Molecule does not run on push to `main`. Raising the runner's capacity is a
|
||||||
|
separate change.
|
||||||
|
|
||||||
|
## Reason
|
||||||
|
|
||||||
|
We chose speed over simplicity, and the measured saving shows the trade:
|
||||||
|
|
||||||
|
- With everything installed per run, Lint took about 82s and Build about 50s (24–25 October
|
||||||
|
2026). With the image, Lint takes about 33s and Build about 13s (3 to 17 November 2026).
|
||||||
|
- The cost: a `ci` image build takes about 4 minutes on the shared runner, and each new version
|
||||||
|
also costs a pin pull request's CI. `ci` went from 0.1.0 to 0.2.23 in three weeks, with 9
|
||||||
|
versions on 14–15 November.
|
||||||
|
|
||||||
|
Versions are assigned by CI, because a version a person has to remember to raise is one
|
||||||
|
somebody forgets. Pinning by digest means a consumer runs exactly the image a reviewer saw.
|
||||||
|
|
||||||
|
Molecule runs are isolated per run rather than queued in one concurrency group, because a
|
||||||
|
shared group cancels a waiting run and stalls the required check of that run's pull request.
|
||||||
|
|
||||||
|
The risks this leaves are in the [Accepted risks](../../SECURITY.md#accepted-risks) register:
|
||||||
|
no Molecule run after a merge, and pin bumps that are first behaviour-tested after they merge.
|
||||||
|
|
||||||
|
## Not done
|
||||||
|
|
||||||
|
- **One molecule Dockerfile with a release build argument:** it would need a matrix argument, a
|
||||||
|
Renovate regex manager for two digests and a pins check that reads build arguments, and the
|
||||||
|
Debian 13 image differs by more than a release tag anyway. Review keeps the files in step.
|
||||||
+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.
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
A disposable **Ubuntu 26.04** test target for the molecule scenarios of the
|
A disposable **Ubuntu 26.04** test target for the molecule scenarios of the
|
||||||
[`mortis.kamino`](https://git.rkdr.net/mortis/kamino) Ansible Collection: a container that behaves like a small
|
[`mortis.kamino`](https://git.rkdr.net/mortis/kamino) Ansible Collection: a container that behaves like a small
|
||||||
26.04 host (systemd as PID 1), so a role can be converged and verified in it without a VM.
|
26.04 host (systemd as PID 1), so a role can be converged and verified in it without a VM.
|
||||||
It is the release the hosts are moving to; the roles are tested on it next to 24.04.
|
It is the release the hosts are moving to; every role scenario whose role declares `resolute` runs on it next to 24.04.
|
||||||
|
|
||||||
## What is in it
|
## What is in it
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
- ufw
|
- ufw
|
||||||
- fail2ban
|
- fail2ban
|
||||||
- openssh-server
|
- openssh-server
|
||||||
|
- gnupg
|
||||||
|
|
||||||
- name: Query the units a role scenario relies on
|
- name: Query the units a role scenario relies on
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
@@ -56,3 +57,14 @@
|
|||||||
- name: NET_ADMIN is granted, so the firewall tools can work
|
- name: NET_ADMIN is granted, so the firewall tools can work
|
||||||
ansible.builtin.command: iptables -S
|
ansible.builtin.command: iptables -S
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
|
- name: Run a task with become, as the role scenarios do
|
||||||
|
ansible.builtin.command: id -u
|
||||||
|
become: true
|
||||||
|
changed_when: false
|
||||||
|
register: kamino_smoke_become
|
||||||
|
|
||||||
|
- name: Become reaches root
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that: kamino_smoke_become.stdout == '0'
|
||||||
|
quiet: true
|
||||||
@@ -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
|
||||||
+2
-2
@@ -1,14 +1,14 @@
|
|||||||
---
|
---
|
||||||
namespace: mortis
|
namespace: mortis
|
||||||
name: kamino
|
name: kamino
|
||||||
version: 2.2.0
|
version: 3.1.0
|
||||||
readme: README.md
|
readme: README.md
|
||||||
authors:
|
authors:
|
||||||
- Defame1297
|
- Defame1297
|
||||||
description: >-
|
description: >-
|
||||||
Reusable, hardened Ansible roles for a self-hosted home lab (cloudflared, docker, fail2ban,
|
Reusable, hardened Ansible roles for a self-hosted home lab (cloudflared, docker, fail2ban,
|
||||||
gitea, gitea_runner, network_interfaces, pihole, pve_lxc, sshd, system_baseline,
|
gitea, gitea_runner, network_interfaces, pihole, pve_lxc, sshd, system_baseline,
|
||||||
systemd_hardening, traefik, ufw, user_management; _binary_update is internal).
|
systemd_hardening, tailscale, traefik, ufw, user_management; _binary_update is internal).
|
||||||
license:
|
license:
|
||||||
- GPL-3.0-or-later
|
- GPL-3.0-or-later
|
||||||
tags:
|
tags:
|
||||||
|
|||||||
+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.37.0 \
|
apm-cli==0.38.1 \
|
||||||
--hash=sha256:1078dc4d5bd7d797f4924548f684daffd026df740b31f99b17fc13958e5da762 \
|
--hash=sha256:c2a0394643e54d3516efefcd78bb043509ac48b65cca1f40166023789b8eb89a \
|
||||||
--hash=sha256:87cbcb6a864aa8251ffea446fc34fd439caa6d01d51df1a9399669bed5fab576
|
--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.37.0
|
apm-cli==0.38.1
|
||||||
+15
-11
@@ -18,7 +18,7 @@ names a check that does not exist yet and its backlog issue.
|
|||||||
*Why:* a consumer finds the same thing in the same place. *Held:* review.
|
*Why:* a consumer finds the same thing in the same place. *Held:* review.
|
||||||
- **Complexity.** A task file stays within ansible-lint's `complexity` limit, `max_tasks` 100
|
- **Complexity.** A task file stays within ansible-lint's `complexity` limit, `max_tasks` 100
|
||||||
(40 once ansible-lint accepts the key). *Why:* a long task file is hard to review. *Held:*
|
(40 once ansible-lint accepts the key). *Why:* a long task file is hard to review. *Held:*
|
||||||
review until the Lint job enables `complexity` and fails on it (#138).
|
control, ansible-lint `complexity` in the Lint job.
|
||||||
- **Roadmap.** The pull request that adds a role removes it from the README "Roadmap" list, and
|
- **Roadmap.** The pull request that adds a role removes it from the README "Roadmap" list, and
|
||||||
the section goes when the list is empty. *Why:* the list is useful only if true. *Held:* review.
|
the section goes when the list is empty. *Why:* the list is useful only if true. *Held:* review.
|
||||||
|
|
||||||
@@ -76,9 +76,8 @@ names a check that does not exist yet and its backlog issue.
|
|||||||
|
|
||||||
- **Declared means tested.** A platform in `meta/main.yml` is one the role passes Molecule on in
|
- **Declared means tested.** A platform in `meta/main.yml` is one the role passes Molecule on in
|
||||||
CI; one used but untested goes only in a README "Untested platforms" line. Accepted until the
|
CI; one used but untested goes only in a README "Untested platforms" line. Accepted until the
|
||||||
Debian image (#226) and the platform cleanup (#133) land: `trixie` declared untested, and
|
Debian image (#226) lands: `trixie` declared untested, and Debian `all` in network_interfaces.
|
||||||
`jammy` or `all` still declared. *Why:* no tool reads the declaration, so it is worth something
|
*Why:* no tool reads the declaration, so it is worth something only if true. *Held:* review.
|
||||||
only if true. *Held:* review.
|
|
||||||
- **Platforms follow the target hosts.** Ubuntu-targeting roles declare exactly `noble` and
|
- **Platforms follow the target hosts.** Ubuntu-targeting roles declare exactly `noble` and
|
||||||
`resolute`; Proxmox-targeting roles declare Debian `trixie`; each is tested on its own OS.
|
`resolute`; Proxmox-targeting roles declare Debian `trixie`; each is tested on its own OS.
|
||||||
*Why:* testing on hosts a role never runs on proves nothing. *Held:* review.
|
*Why:* testing on hosts a role never runs on proves nothing. *Held:* review.
|
||||||
@@ -96,12 +95,16 @@ names a check that does not exist yet and its backlog issue.
|
|||||||
- **Negative tests.** Every validation has one in `verify.yml` (or a file it includes):
|
- **Negative tests.** Every validation has one in `verify.yml` (or a file it includes):
|
||||||
block/rescue/assert matching the expected error message, run last or failing before any
|
block/rescue/assert matching the expected error message, run last or failing before any
|
||||||
change. *Why:* a bare "it failed" passes for the wrong error. *Held:* review.
|
change. *Why:* a bare "it failed" passes for the wrong error. *Held:* review.
|
||||||
- **Check mode.** Every scenario runs `check` before and after converge. The only guards are
|
- **Check mode.** Every scenario runs `check` before and after converge. Guards:
|
||||||
`check_mode: false` on read-only probes and `when: not ansible_check_mode`; `--check` is the
|
`check_mode: false` on read-only probes, and `when: not ansible_check_mode`, alone or as
|
||||||
supported preview, and the README says a play-level `check_mode: true` is not supported. A role
|
`not ansible_check_mode or <condition>` where the condition shows the task can run (such as a
|
||||||
that cannot support check mode says why in README Notes and drops the step. *Why:* check-mode
|
registered result that is not changed). README: `--check` is the supported preview and a
|
||||||
breakage is a frequent fix, and one guard pattern is reviewable. *Held:* review until every
|
play-level `check_mode: true` is not supported; a role whose `--check` needs its package
|
||||||
scenario's `test_sequence` runs `check` (#134).
|
installed says so in Notes and keeps the step; a role that cannot support check mode at all
|
||||||
|
says why in Notes and drops the step, which also needs an exception in the test named below.
|
||||||
|
*Why:* check-mode breakage is a frequent fix, and one guard pattern is reviewable. *Held:*
|
||||||
|
Molecule for the run passing, `tests/scripts/test_run_molecule_scenarios.py` for the steps
|
||||||
|
being there; review for the guards.
|
||||||
|
|
||||||
## Roles calling roles
|
## Roles calling roles
|
||||||
|
|
||||||
@@ -122,4 +125,5 @@ names a check that does not exist yet and its backlog issue.
|
|||||||
review that each new internal role has it.
|
review that each new internal role has it.
|
||||||
- **`role-name` for internal roles.** An internal role is exempted from ansible-lint `role-name`
|
- **`role-name` for internal roles.** An internal role is exempted from ansible-lint `role-name`
|
||||||
by its own line in `.ansible-lint-ignore`. *Why:* a misnamed public role must still fail.
|
by its own line in `.ansible-lint-ignore`. *Why:* a misnamed public role must still fail.
|
||||||
*Held:* review; until #138 replaces it, `.ansible-lint` skips `role-name` repository-wide.
|
*Held:* control, ansible-lint `role-name` in the Lint job; review that each new internal role
|
||||||
|
has its line.
|
||||||
@@ -9,6 +9,9 @@ calling role does the download and the verification (a checksum, a signature, a
|
|||||||
each upstream differs) and stages the verified file next to the live binary before it includes
|
each upstream differs) and stages the verified file next to the live binary before it includes
|
||||||
this role, so a slow or failed download never stops the service.
|
this role, so a slow or failed download never stops the service.
|
||||||
|
|
||||||
|
It covers Ubuntu only: only the Collection's Ubuntu-targeting roles call it, so it does not
|
||||||
|
cover Debian trixie.
|
||||||
|
|
||||||
Variables and their types are defined in [`meta/argument_specs.yml`](meta/argument_specs.yml),
|
Variables and their types are defined in [`meta/argument_specs.yml`](meta/argument_specs.yml),
|
||||||
which is the source of truth.
|
which is the source of truth.
|
||||||
|
|
||||||
@@ -63,11 +66,13 @@ itself always stops and starts the service.
|
|||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
|
|
||||||
Two molecule scenarios run on Ubuntu 24.04 (noble) against stub binaries (shell scripts) under
|
Two molecule scenarios run in CI only, on two platforms: `${MOLECULE_IMAGE}` (Ubuntu 24.04) and
|
||||||
a stub unit, with no network: `default` covers a successful bump, its idempotence, a binary
|
`${MOLECULE_IMAGE_2604}` (Ubuntu 26.04). They run against stub binaries (shell scripts) under a
|
||||||
that cannot start, a binary that reports another version (both rolled back), a run with nothing
|
stub unit, with no network: `default` covers a successful bump, its idempotence, a binary that
|
||||||
|
cannot start, a binary that reports another version (both rolled back), a run with nothing
|
||||||
staged (the service is not stopped), a direct call from a play (refused) and a first install
|
staged (the service is not stopped), a direct call from a play (refused) and a first install
|
||||||
with nothing to back up. `check_mode` runs the bump under `--check` against a stopped service
|
with nothing to back up, and runs `check` before the converge (on a fresh host) and after it
|
||||||
|
(on the configured host). `check_mode` runs the bump under `--check` against a stopped service
|
||||||
and checks that nothing changed. The calling roles' own scenarios cover a real upstream binary.
|
and checks that nothing changed. The calling roles' own scenarios cover a real upstream binary.
|
||||||
|
|
||||||
Idempotent: yes.
|
Idempotent: yes.
|
||||||
@@ -11,6 +11,7 @@ galaxy_info:
|
|||||||
- name: Ubuntu
|
- name: Ubuntu
|
||||||
versions:
|
versions:
|
||||||
- noble
|
- noble
|
||||||
|
- resolute
|
||||||
galaxy_tags:
|
galaxy_tags:
|
||||||
- systemd
|
- systemd
|
||||||
- update
|
- update
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
---
|
---
|
||||||
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404 image
|
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404
|
||||||
# (MOLECULE_IMAGE, the pin in .gitea/workflows/molecule.yml). Needs no network: the "binaries"
|
# (MOLECULE_IMAGE) and molecule-ubuntu2604 (MOLECULE_IMAGE_2604) images, pinned in
|
||||||
# are stub shell scripts written by ../resources/prepare.yml, run by a stub systemd unit. The
|
# .gitea/workflows/molecule.yml. Needs no network: the "binaries" are stub shell scripts written by
|
||||||
# test caller role lives in ../resources/roles, because the role refuses a call from a play.
|
# ../resources/prepare.yml, run by a stub systemd unit. The test caller role lives in
|
||||||
|
# ../resources/roles, because the role refuses a call from a play.
|
||||||
driver:
|
driver:
|
||||||
name: docker
|
name: docker
|
||||||
platforms:
|
platforms:
|
||||||
@@ -21,6 +22,21 @@ platforms:
|
|||||||
- /run/lock
|
- /run/lock
|
||||||
security_opts:
|
security_opts:
|
||||||
- apparmor=unconfined
|
- apparmor=unconfined
|
||||||
|
- name: ${KAMINO_RUN_ID:-local}-binary-update-check-2604-instance
|
||||||
|
labels:
|
||||||
|
net.rkdr.mortis.molecule-run: "${KAMINO_RUN_ID:-local}"
|
||||||
|
image: ${MOLECULE_IMAGE_2604}
|
||||||
|
pre_build_image: true
|
||||||
|
pull: true
|
||||||
|
command: /sbin/init
|
||||||
|
cgroupns_mode: host
|
||||||
|
volumes:
|
||||||
|
- /sys/fs/cgroup:/sys/fs/cgroup:rw
|
||||||
|
tmpfs:
|
||||||
|
- /run
|
||||||
|
- /run/lock
|
||||||
|
security_opts:
|
||||||
|
- apparmor=unconfined
|
||||||
provisioner:
|
provisioner:
|
||||||
name: ansible
|
name: ansible
|
||||||
env:
|
env:
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
---
|
---
|
||||||
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404 image
|
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404
|
||||||
# (MOLECULE_IMAGE, the pin in .gitea/workflows/molecule.yml). Needs no network: the "binaries"
|
# (MOLECULE_IMAGE) and molecule-ubuntu2604 (MOLECULE_IMAGE_2604) images, pinned in
|
||||||
# are stub shell scripts written by ../resources/prepare.yml, run by a stub systemd unit. The
|
# .gitea/workflows/molecule.yml. Needs no network: the "binaries" are stub shell scripts written by
|
||||||
# test caller role lives in ../resources/roles, because the role refuses a call from a play.
|
# ../resources/prepare.yml, run by a stub systemd unit. The test caller role lives in
|
||||||
|
# ../resources/roles, because the role refuses a call from a play.
|
||||||
driver:
|
driver:
|
||||||
name: docker
|
name: docker
|
||||||
platforms:
|
platforms:
|
||||||
@@ -21,6 +22,21 @@ platforms:
|
|||||||
- /run/lock
|
- /run/lock
|
||||||
security_opts:
|
security_opts:
|
||||||
- apparmor=unconfined
|
- apparmor=unconfined
|
||||||
|
- name: ${KAMINO_RUN_ID:-local}-binary-update-2604-instance
|
||||||
|
labels:
|
||||||
|
net.rkdr.mortis.molecule-run: "${KAMINO_RUN_ID:-local}"
|
||||||
|
image: ${MOLECULE_IMAGE_2604}
|
||||||
|
pre_build_image: true
|
||||||
|
pull: true
|
||||||
|
command: /sbin/init
|
||||||
|
cgroupns_mode: host
|
||||||
|
volumes:
|
||||||
|
- /sys/fs/cgroup:/sys/fs/cgroup:rw
|
||||||
|
tmpfs:
|
||||||
|
- /run
|
||||||
|
- /run/lock
|
||||||
|
security_opts:
|
||||||
|
- apparmor=unconfined
|
||||||
provisioner:
|
provisioner:
|
||||||
name: ansible
|
name: ansible
|
||||||
env:
|
env:
|
||||||
@@ -30,13 +46,16 @@ verifier:
|
|||||||
scenario:
|
scenario:
|
||||||
# molecule's default sequence minus both destroys: scripts/run_molecule_scenarios.sh removes the
|
# molecule's default sequence minus both destroys: scripts/run_molecule_scenarios.sh removes the
|
||||||
# container as soon as this scenario ends. After a local run, run `molecule destroy` yourself.
|
# container as soon as this scenario ends. After a local run, run `molecule destroy` yourself.
|
||||||
|
# A check runs before the converge (fresh host) and after it (configured host).
|
||||||
test_sequence:
|
test_sequence:
|
||||||
- dependency
|
- dependency
|
||||||
- cleanup
|
- cleanup
|
||||||
- syntax
|
- syntax
|
||||||
- create
|
- create
|
||||||
- prepare
|
- prepare
|
||||||
|
- check
|
||||||
- converge
|
- converge
|
||||||
|
- check
|
||||||
- idempotence
|
- idempotence
|
||||||
- side_effect
|
- side_effect
|
||||||
- verify
|
- verify
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ Installs cloudflared as a systemd service for a locally managed Cloudflare Tunne
|
|||||||
|
|
||||||
## Supported platforms
|
## Supported platforms
|
||||||
|
|
||||||
Ubuntu 24.04 (noble), the platform the molecule scenario runs on. The role downloads the `cloudflared-linux-amd64` binary only, so other architectures are unsupported, and it needs `systemd`. The tasks that call the Cloudflare API run on the controller (`delegate_to: localhost`) and need the `community.general` collection (`cloudflare_dns`) there; the `mint` entry point also needs the `openssl` command on the controller. The target needs outbound access to github.com and to Cloudflare's edge; the role defines no firewall rules because the daemon only connects outbound.
|
Ubuntu 24.04 (noble) and 26.04 (resolute), the platforms the molecule scenario runs on. The role downloads the `cloudflared-linux-amd64` binary only, so other architectures are unsupported, and it needs `systemd`. The tasks that call the Cloudflare API run on the controller (`delegate_to: localhost`) and need the `community.general` collection (`cloudflare_dns`) there; the `mint` entry point also needs the `openssl` command on the controller. The target needs outbound access to github.com and to Cloudflare's edge; the role defines no firewall rules because the daemon only connects outbound.
|
||||||
|
|
||||||
The role targets Ubuntu hosts that run the tunnel daemon, not Proxmox nodes, so it does not cover Debian trixie.
|
The role targets Ubuntu hosts that run the tunnel daemon, not Proxmox nodes, so it does not cover Debian trixie.
|
||||||
|
|
||||||
@@ -32,6 +32,7 @@ The role targets Ubuntu hosts that run the tunnel daemon, not Proxmox nodes, so
|
|||||||
| `cloudflared_zone_name` | `""` (asserted while `cloudflared_manage_dns`) | Zone of the ingress hostnames. |
|
| `cloudflared_zone_name` | `""` (asserted while `cloudflared_manage_dns`) | Zone of the ingress hostnames. |
|
||||||
| `cloudflared_allow_dns_overwrite` | `[]` | Hostnames whose existing non-tunnel DNS record may be overwritten. |
|
| `cloudflared_allow_dns_overwrite` | `[]` | Hostnames whose existing non-tunnel DNS record may be overwritten. |
|
||||||
| `cloudflared_api_base_url` | `https://api.cloudflare.com/client/v4` | Cloudflare API base URL for the role's `uri` calls, no trailing slash. |
|
| `cloudflared_api_base_url` | `https://api.cloudflare.com/client/v4` | Cloudflare API base URL for the role's `uri` calls, no trailing slash. |
|
||||||
|
| `cloudflared_tunnel_lookup_delay` | `5` | Seconds between the three retries of a 404 from the tunnel lookup, at least 0. |
|
||||||
| `cloudflared_tunnel_name` | `{{ inventory_hostname }}-tunnel` | Tunnel name used by the `mint` entry point. |
|
| `cloudflared_tunnel_name` | `{{ inventory_hostname }}-tunnel` | Tunnel name used by the `mint` entry point. |
|
||||||
| `cloudflared_version` | pinned in `defaults/main.yml` | Release tag, `YYYY.M.P`. |
|
| `cloudflared_version` | pinned in `defaults/main.yml` | Release tag, `YYYY.M.P`. |
|
||||||
| `cloudflared_sha256_amd64` | pinned | SHA-256 of the amd64 binary. Update with the version. |
|
| `cloudflared_sha256_amd64` | pinned | SHA-256 of the amd64 binary. Update with the version. |
|
||||||
@@ -106,7 +107,7 @@ Remove with `-e "cloudflared_remove=true cloudflared_remove_data=true"`; only `c
|
|||||||
|
|
||||||
## Tests
|
## Tests
|
||||||
|
|
||||||
The `default` molecule scenario runs on one platform, Ubuntu 24.04 (noble) (`${MOLECULE_IMAGE}`), without Cloudflare: a stub cloudflared binary stands in for the daemon, the downloads come from local `file://` URLs, and a stub of the Cloudflare API on the controller's loopback (`molecule/default/files/cloudflare_api_stub.py`, reached through `cloudflared_api_base_url`) answers the tunnel, zone and DNS record calls. It covers the converge with `cloudflared_manage_dns` false and an update through `_binary_update` (and its idempotence), the rendered `config.yml`, credentials file and unit, a stale credentials file, a failed checksum that leaves the daemon running, the input asserts, the deleted-tunnel and DNS guards, the `mint` entry point (confirm guard, CI refusal, no-op, check mode and a mint against the stub, run as child processes) and the remove path. The `community.general.cloudflare_dns` calls, which cannot be pointed at the stub, are not covered: creating, pruning and deleting records.
|
The `default` molecule scenario runs in CI only, on two platforms: `${MOLECULE_IMAGE}` (Ubuntu 24.04) and `${MOLECULE_IMAGE_2604}` (Ubuntu 26.04). It runs without Cloudflare: a stub cloudflared binary stands in for the daemon, the downloads come from local `file://` URLs, and a stub of the Cloudflare API on the controller's loopback (`molecule/default/files/cloudflare_api_stub.py`, reached through `cloudflared_api_base_url`) answers the tunnel, zone and DNS record calls. It covers the converge with `cloudflared_manage_dns` false and an update through `_binary_update` (and its idempotence), the rendered `config.yml`, credentials file and unit, a stale credentials file, a failed checksum that leaves the daemon running, the input asserts, the deleted-tunnel and DNS guards, the `mint` entry point (confirm guard, CI refusal, no-op, check mode and a mint against the stub, run as child processes) and the remove path. The `community.general.cloudflare_dns` calls, which cannot be pointed at the stub, are not covered: creating, pruning and deleting records. It runs `check` before the converge (a fresh host) and after it (a configured host).
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
@@ -120,3 +121,4 @@ The `default` molecule scenario runs on one platform, Ubuntu 24.04 (noble) (`${M
|
|||||||
- The `Restart cloudflared` handler runs when `config.yml` or the credentials file changes. cloudflared's own ingress check (`ingress validate`) runs after `config.yml` is written.
|
- The `Restart cloudflared` handler runs when `config.yml` or the credentials file changes. cloudflared's own ingress check (`ingress validate`) runs after `config.yml` is written.
|
||||||
- Update: the version is compared as `YYYY.M.P` against `cloudflared --version`. The new binary is downloaded and checksum-verified into `cloudflared.new` before the service is stopped, so a failed download leaves it running; a configured hash that equals the installed binary's is refused with a message, since it means the hash was not bumped with the version. A binary that reports no version is replaced too.
|
- Update: the version is compared as `YYYY.M.P` against `cloudflared --version`. The new binary is downloaded and checksum-verified into `cloudflared.new` before the service is stopped, so a failed download leaves it running; a configured hash that equals the installed binary's is refused with a message, since it means the hash was not bumped with the version. A binary that reports no version is replaced too.
|
||||||
- The play fails when `cloudflared` is not `active` after start.
|
- The play fails when `cloudflared` is not `active` after start.
|
||||||
|
- Check mode: `--check` is the supported preview; a play-level `check_mode: true` is not supported. Under `--check`, the config directory task is skipped when the `cloudflared` group or user is new. When the systemd unit is new or would change, the start, the running check, the `Restart cloudflared` handler and the update swap are skipped.
|
||||||
@@ -17,6 +17,8 @@ cloudflared_config_dir: "/etc/cloudflared"
|
|||||||
cloudflared_service_unit: "/etc/systemd/system/cloudflared.service"
|
cloudflared_service_unit: "/etc/systemd/system/cloudflared.service"
|
||||||
|
|
||||||
cloudflared_api_base_url: "https://api.cloudflare.com/client/v4"
|
cloudflared_api_base_url: "https://api.cloudflare.com/client/v4"
|
||||||
|
# Seconds between the three retries of a 404 from the tunnel lookup.
|
||||||
|
cloudflared_tunnel_lookup_delay: 5
|
||||||
|
|
||||||
cloudflared_tunnel_name: "{{ inventory_hostname }}-tunnel"
|
cloudflared_tunnel_name: "{{ inventory_hostname }}-tunnel"
|
||||||
|
|
||||||
|
|||||||
@@ -4,3 +4,5 @@
|
|||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
name: cloudflared
|
name: cloudflared
|
||||||
state: restarted
|
state: restarted
|
||||||
|
# Under --check a new unit is only simulated, so systemd would not find it.
|
||||||
|
when: not ansible_check_mode or __cloudflared_unit_file | default({}) is not changed
|
||||||
@@ -102,6 +102,13 @@ argument_specs:
|
|||||||
Base URL of the Cloudflare API, without a trailing slash. Prefixed to every request the role makes with
|
Base URL of the Cloudflare API, without a trailing slash. Prefixed to every request the role makes with
|
||||||
C(ansible.builtin.uri) (tunnel lookup and delete, zone lookup and DNS record listing). The
|
C(ansible.builtin.uri) (tunnel lookup and delete, zone lookup and DNS record listing). The
|
||||||
C(community.general.cloudflare_dns) tasks always use the public endpoint.
|
C(community.general.cloudflare_dns) tasks always use the public endpoint.
|
||||||
|
cloudflared_tunnel_lookup_delay:
|
||||||
|
type: int
|
||||||
|
default: 5
|
||||||
|
description:
|
||||||
|
- >-
|
||||||
|
Seconds between the three retries of the tunnel lookup when Cloudflare answers 404, which right
|
||||||
|
after a mint can be read-after-write lag rather than a deleted tunnel. At least 0.
|
||||||
cloudflared_tunnel_name:
|
cloudflared_tunnel_name:
|
||||||
type: raw
|
type: raw
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ galaxy_info:
|
|||||||
- name: Ubuntu
|
- name: Ubuntu
|
||||||
versions:
|
versions:
|
||||||
- noble
|
- noble
|
||||||
|
- resolute
|
||||||
galaxy_tags:
|
galaxy_tags:
|
||||||
- cloudflared
|
- cloudflared
|
||||||
- cloudflare
|
- cloudflare
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
---
|
---
|
||||||
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404 image
|
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404
|
||||||
# (MOLECULE_IMAGE, the pin in .gitea/workflows/molecule.yml). No Cloudflare and no real
|
# (MOLECULE_IMAGE) and molecule-ubuntu2604 (MOLECULE_IMAGE_2604) images, pinned in
|
||||||
# cloudflared: prepare.yml starts a stub of the Cloudflare API on the controller's loopback
|
# .gitea/workflows/molecule.yml. No Cloudflare and no real cloudflared: prepare.yml starts a stub of
|
||||||
# (files/cloudflare_api_stub.py, reached through cloudflared_api_base_url; cleanup.yml stops it)
|
# the Cloudflare API on the controller's loopback (files/cloudflare_api_stub.py, reached through
|
||||||
# and seeds a stub cloudflared binary that reports an older version, so the update downloads its
|
# cloudflared_api_base_url; cleanup.yml stops it) and seeds a stub cloudflared binary that reports
|
||||||
# new stub from local file:// URLs. The scenario downloads nothing. cloudflared_manage_dns is
|
# an older version, so the update downloads its new stub from local file:// URLs. The scenario
|
||||||
# false here because community.general.cloudflare_dns cannot be pointed at the stub; the DNS
|
# downloads nothing. cloudflared_manage_dns is false here because community.general.cloudflare_dns
|
||||||
# guards in front of it are run with it true in verify.yml.
|
# cannot be pointed at the stub; the DNS guards in front of it are run with it true in verify.yml.
|
||||||
# The container runs systemd as PID 1 with a writable cgroup; no privileged mode.
|
# The container runs systemd as PID 1 with a writable cgroup; no privileged mode.
|
||||||
driver:
|
driver:
|
||||||
name: docker
|
name: docker
|
||||||
@@ -26,6 +26,21 @@ platforms:
|
|||||||
- /run/lock
|
- /run/lock
|
||||||
security_opts:
|
security_opts:
|
||||||
- apparmor=unconfined
|
- apparmor=unconfined
|
||||||
|
- name: ${KAMINO_RUN_ID:-local}-cloudflared-2604-instance
|
||||||
|
labels:
|
||||||
|
net.rkdr.mortis.molecule-run: "${KAMINO_RUN_ID:-local}"
|
||||||
|
image: ${MOLECULE_IMAGE_2604}
|
||||||
|
pre_build_image: true
|
||||||
|
pull: true
|
||||||
|
command: /sbin/init
|
||||||
|
cgroupns_mode: host
|
||||||
|
volumes:
|
||||||
|
- /sys/fs/cgroup:/sys/fs/cgroup:rw
|
||||||
|
tmpfs:
|
||||||
|
- /run
|
||||||
|
- /run/lock
|
||||||
|
security_opts:
|
||||||
|
- apparmor=unconfined
|
||||||
provisioner:
|
provisioner:
|
||||||
name: ansible
|
name: ansible
|
||||||
# One source for every play, so a verify play that runs the role again renders the same
|
# One source for every play, so a verify play that runs the role again renders the same
|
||||||
@@ -75,13 +90,16 @@ verifier:
|
|||||||
scenario:
|
scenario:
|
||||||
# molecule's default sequence minus both destroys: scripts/run_molecule_scenarios.sh removes the
|
# molecule's default sequence minus both destroys: scripts/run_molecule_scenarios.sh removes the
|
||||||
# container as soon as this scenario ends. After a local run, run `molecule destroy` yourself.
|
# container as soon as this scenario ends. After a local run, run `molecule destroy` yourself.
|
||||||
|
# A check runs before the converge (fresh host) and after it (configured host).
|
||||||
test_sequence:
|
test_sequence:
|
||||||
- dependency
|
- dependency
|
||||||
- cleanup
|
- cleanup
|
||||||
- syntax
|
- syntax
|
||||||
- create
|
- create
|
||||||
- prepare
|
- prepare
|
||||||
|
- check
|
||||||
- converge
|
- converge
|
||||||
|
- check
|
||||||
- idempotence
|
- idempotence
|
||||||
- side_effect
|
- side_effect
|
||||||
- verify
|
- verify
|
||||||
|
|||||||
@@ -23,6 +23,8 @@
|
|||||||
cloudflared_user: "{{ cloudflared_test_case.vars.cloudflared_user | default('cloudflared') }}"
|
cloudflared_user: "{{ cloudflared_test_case.vars.cloudflared_user | default('cloudflared') }}"
|
||||||
cloudflared_install_dir: "{{ cloudflared_test_case.vars.cloudflared_install_dir | default('/usr/local/bin') }}"
|
cloudflared_install_dir: "{{ cloudflared_test_case.vars.cloudflared_install_dir | default('/usr/local/bin') }}"
|
||||||
cloudflared_config_dir: "{{ cloudflared_test_case.vars.cloudflared_config_dir | default('/etc/cloudflared') }}"
|
cloudflared_config_dir: "{{ cloudflared_test_case.vars.cloudflared_config_dir | default('/etc/cloudflared') }}"
|
||||||
|
# The stub answers at once, so the retries need no wait; they still run.
|
||||||
|
cloudflared_tunnel_lookup_delay: "{{ cloudflared_test_case.vars.cloudflared_tunnel_lookup_delay | default(0) }}"
|
||||||
|
|
||||||
# Only reached when the include returned. The message must not contain the expected
|
# Only reached when the include returned. The message must not contain the expected
|
||||||
# text, so the rescue below cannot mistake it for the failure under test.
|
# text, so the rescue below cannot mistake it for the failure under test.
|
||||||
|
|||||||
@@ -157,6 +157,9 @@
|
|||||||
- name: tunnel-id-not-uuid
|
- name: tunnel-id-not-uuid
|
||||||
vars: {cloudflared_tunnel_id: not-a-uuid}
|
vars: {cloudflared_tunnel_id: not-a-uuid}
|
||||||
expect: must be a lowercase UUID
|
expect: must be a lowercase UUID
|
||||||
|
- name: lookup-delay-negative
|
||||||
|
vars: {cloudflared_tunnel_lookup_delay: -1}
|
||||||
|
expect: cloudflared_tunnel_lookup_delay must be a whole number of seconds, at least 0
|
||||||
- name: tunnel-not-minted
|
- name: tunnel-not-minted
|
||||||
vars: {cloudflared_tunnel_id: ""}
|
vars: {cloudflared_tunnel_id: ""}
|
||||||
expect: run the mint entry point first
|
expect: run the mint entry point first
|
||||||
@@ -172,7 +175,7 @@
|
|||||||
- name: tunnel-deleted
|
- name: tunnel-deleted
|
||||||
vars: {cloudflared_tunnel_id: 6f1a6e2c-0000-4000-8000-000000000002}
|
vars: {cloudflared_tunnel_id: 6f1a6e2c-0000-4000-8000-000000000002}
|
||||||
expect: no longer exists on Cloudflare
|
expect: no longer exists on Cloudflare
|
||||||
# Retried three times, 5 s apart, before the 404 is trusted.
|
# Retried three times (with no delay here) before the 404 is trusted.
|
||||||
- name: tunnel-unknown
|
- name: tunnel-unknown
|
||||||
vars: {cloudflared_tunnel_id: 6f1a6e2c-0000-4000-8000-00000000000f}
|
vars: {cloudflared_tunnel_id: 6f1a6e2c-0000-4000-8000-00000000000f}
|
||||||
expect: (HTTP 404)
|
expect: (HTTP 404)
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
# briefly before trusting it.
|
# briefly before trusting it.
|
||||||
until: __cloudflared_tunnel_lookup.status | default(0) == 200
|
until: __cloudflared_tunnel_lookup.status | default(0) == 200
|
||||||
retries: 3
|
retries: 3
|
||||||
delay: 5
|
delay: "{{ cloudflared_tunnel_lookup_delay }}"
|
||||||
# Running out of retries fails the task whatever its status, and no_log would hide why: the
|
# Running out of retries fails the task whatever its status, and no_log would hide why: the
|
||||||
# two tasks below fail instead, with the re-mint instructions for a 404.
|
# two tasks below fail instead, with the re-mint instructions for a 404.
|
||||||
ignore_errors: true # noqa: ignore-errors
|
ignore_errors: true # noqa: ignore-errors
|
||||||
@@ -281,6 +281,7 @@
|
|||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
|
register: __cloudflared_unit_file
|
||||||
|
|
||||||
- name: Reload systemd daemon
|
- name: Reload systemd daemon
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
@@ -291,6 +292,8 @@
|
|||||||
name: cloudflared
|
name: cloudflared
|
||||||
enabled: true
|
enabled: true
|
||||||
state: started
|
state: started
|
||||||
|
# Under --check a new unit is only simulated, so systemd would not find it.
|
||||||
|
when: not ansible_check_mode or __cloudflared_unit_file is not changed
|
||||||
|
|
||||||
- name: Check cloudflared service status
|
- name: Check cloudflared service status
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
@@ -301,5 +304,8 @@
|
|||||||
- name: Fail if cloudflared service is not running
|
- name: Fail if cloudflared service is not running
|
||||||
ansible.builtin.fail:
|
ansible.builtin.fail:
|
||||||
msg: "cloudflared service is not running"
|
msg: "cloudflared service is not running"
|
||||||
when: __cloudflared_service_status.status.ActiveState != "active"
|
when:
|
||||||
|
- __cloudflared_service_status.status.ActiveState != "active"
|
||||||
|
# The start above is skipped under --check for a new unit.
|
||||||
|
- not ansible_check_mode or __cloudflared_unit_file | default({}) is not changed
|
||||||
tags: [cloudflared, configure, health]
|
tags: [cloudflared, configure, health]
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
ansible.builtin.group:
|
ansible.builtin.group:
|
||||||
name: "{{ cloudflared_group }}"
|
name: "{{ cloudflared_group }}"
|
||||||
system: true
|
system: true
|
||||||
|
register: __cloudflared_group_account
|
||||||
tags: [cloudflared, prereqs, always]
|
tags: [cloudflared, prereqs, always]
|
||||||
|
|
||||||
- name: Create cloudflared user
|
- name: Create cloudflared user
|
||||||
@@ -15,6 +16,7 @@
|
|||||||
comment: "Cloudflare Tunnel daemon"
|
comment: "Cloudflare Tunnel daemon"
|
||||||
system: true
|
system: true
|
||||||
create_home: false
|
create_home: false
|
||||||
|
register: __cloudflared_user_account
|
||||||
tags: [cloudflared, prereqs, always]
|
tags: [cloudflared, prereqs, always]
|
||||||
|
|
||||||
- name: Create cloudflared config directory
|
- name: Create cloudflared config directory
|
||||||
@@ -25,6 +27,8 @@
|
|||||||
owner: "{{ cloudflared_user }}"
|
owner: "{{ cloudflared_user }}"
|
||||||
group: "{{ cloudflared_group }}"
|
group: "{{ cloudflared_group }}"
|
||||||
mode: "0750"
|
mode: "0750"
|
||||||
|
# Under --check a new account is only simulated, so an existing directory cannot be chowned to it.
|
||||||
|
when: not ansible_check_mode or (__cloudflared_group_account is not changed and __cloudflared_user_account is not changed)
|
||||||
tags: [cloudflared, prereqs, always]
|
tags: [cloudflared, prereqs, always]
|
||||||
|
|
||||||
- name: Check if cloudflared binary exists
|
- name: Check if cloudflared binary exists
|
||||||
|
|||||||
@@ -80,7 +80,8 @@
|
|||||||
cloudflared was not stopped and still runs {{ __cloudflared_installed_version }}.
|
cloudflared was not stopped and still runs {{ __cloudflared_installed_version }}.
|
||||||
tags: [cloudflared, update]
|
tags: [cloudflared, update]
|
||||||
|
|
||||||
# An include does not pass its tags on to the included tasks, hence apply.
|
# An include does not pass its tags on to the included tasks, hence apply. Under --check a
|
||||||
|
# new unit is only simulated, so the stop and start of the swap would not find it.
|
||||||
- name: Swap in the staged cloudflared binary
|
- name: Swap in the staged cloudflared binary
|
||||||
ansible.builtin.include_role:
|
ansible.builtin.include_role:
|
||||||
name: mortis.kamino._binary_update
|
name: mortis.kamino._binary_update
|
||||||
@@ -93,6 +94,7 @@
|
|||||||
_binary_update_version_command: ["{{ cloudflared_install_dir }}/cloudflared", --version]
|
_binary_update_version_command: ["{{ cloudflared_install_dir }}/cloudflared", --version]
|
||||||
_binary_update_expected_version: "{{ cloudflared_version }}"
|
_binary_update_expected_version: "{{ cloudflared_version }}"
|
||||||
_binary_update_version_regex: '([0-9]{4}\.[0-9]+\.[0-9]+)'
|
_binary_update_version_regex: '([0-9]{4}\.[0-9]+\.[0-9]+)'
|
||||||
|
when: not ansible_check_mode or __cloudflared_unit_file | default({}) is not changed
|
||||||
tags: [cloudflared, update]
|
tags: [cloudflared, update]
|
||||||
|
|
||||||
always:
|
always:
|
||||||
|
|||||||
@@ -63,6 +63,12 @@
|
|||||||
newline or %, and the two directories must be absolute paths.
|
newline or %, and the two directories must be absolute paths.
|
||||||
quiet: true
|
quiet: true
|
||||||
|
|
||||||
|
- name: Require a non-negative tunnel lookup delay
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that: cloudflared_tunnel_lookup_delay | int(-1) >= 0
|
||||||
|
fail_msg: cloudflared_tunnel_lookup_delay must be a whole number of seconds, at least 0.
|
||||||
|
quiet: true
|
||||||
|
|
||||||
# The role never creates the tunnel on its main entry point. Defined and empty (or null) counts
|
# The role never creates the tunnel on its main entry point. Defined and empty (or null) counts
|
||||||
# as missing, as in the mint entry point, so the two cannot disagree.
|
# as missing, as in the mint entry point, so the two cannot disagree.
|
||||||
- name: Require the minted tunnel secrets
|
- name: Require the minted tunnel secrets
|
||||||
|
|||||||
@@ -4,9 +4,7 @@ Installs Docker Engine from the upstream Docker APT repository, optionally updat
|
|||||||
|
|
||||||
## Supported platforms
|
## Supported platforms
|
||||||
|
|
||||||
Ubuntu 24.04 (noble), the platform 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.
|
||||||
|
|
||||||
Untested platforms: Ubuntu releases other than 24.04; `meta/main.yml` declares Ubuntu `all`.
|
|
||||||
|
|
||||||
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).
|
||||||
|
|
||||||
@@ -88,12 +86,12 @@ With any of `docker_daemon_options`, `docker_live_restore`, `docker_log_driver`,
|
|||||||
|
|
||||||
## Tests
|
## Tests
|
||||||
|
|
||||||
`molecule/default` runs in CI only (`.gitea/workflows/molecule.yml`, no local runner), on one platform: Ubuntu 24.04 (noble), the `molecule-ubuntu2404` test container (`${MOLECULE_IMAGE}`). A real Docker Engine cannot run there: `dockerd` needs the bridge, iptables rules and a delegated cgroup, and the container has no privileged mode. So the scenario builds a local APT repository, signs it with a throwaway key, and points the role at it with `docker_gpg_url` and `docker_repo_base_url`. The repository holds empty stand-ins for `docker-ce`, `docker-ce-cli` and `containerd.io`. The stand-in `docker-ce` ships a stub `docker.service` (`sleep infinity`) and creates the `docker` group, as the real package does.
|
`molecule/default` runs in CI only (`.gitea/workflows/molecule.yml`, no local runner), on two platforms: `${MOLECULE_IMAGE}` (Ubuntu 24.04) and `${MOLECULE_IMAGE_2604}` (Ubuntu 26.04). A real Docker Engine cannot run there: `dockerd` needs the bridge, iptables rules and a delegated cgroup, and the container has no privileged mode. So the scenario builds a local APT repository, signs it with a throwaway key, and points the role at it with `docker_gpg_url` and `docker_repo_base_url`. The repository holds empty stand-ins for `docker-ce`, `docker-ce-cli` and `containerd.io`. The stand-in `docker-ce` ships a stub `docker.service` (`sleep infinity`) and creates the `docker` group, as the real package does. It runs `check` before the converge (on a fresh host) and after it (on the configured host).
|
||||||
|
|
||||||
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.
|
||||||
@@ -106,6 +104,7 @@ What it does not show: what the units do at a real boot or shutdown (the contain
|
|||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
- Idempotent: yes.
|
- Idempotent: yes.
|
||||||
|
- Check mode: `--check` is the supported preview; a play-level `check_mode: true` is not supported. On a host where the Docker source line is not written yet, the package install, the service start, adding `docker_users` to `docker_group` and the `docker_update` tasks are skipped under `--check`, because the repository they need is only simulated.
|
||||||
- `docker_remove` is checked first: when true, only `remove.yml` runs.
|
- `docker_remove` is checked first: when true, only `remove.yml` runs.
|
||||||
- Removal with `docker_remove_data` is destructive. It deletes `/var/lib/docker`.
|
- Removal with `docker_remove_data` is destructive. It deletes `/var/lib/docker`.
|
||||||
- The update task resolves each package's candidate with `apt-cache policy` and fails if a package has none. It installs `package=version`, never `latest`.
|
- The update task resolves each package's candidate with `apt-cache policy` and fails if a package has none. It installs `package=version`, never `latest`.
|
||||||
|
|||||||
@@ -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: ""
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ galaxy_info:
|
|||||||
platforms:
|
platforms:
|
||||||
- name: Ubuntu
|
- name: Ubuntu
|
||||||
versions:
|
versions:
|
||||||
- all
|
- noble
|
||||||
|
- resolute
|
||||||
galaxy_tags:
|
galaxy_tags:
|
||||||
- docker
|
- docker
|
||||||
- containers
|
- containers
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
---
|
---
|
||||||
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404 image
|
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404
|
||||||
# (MOLECULE_IMAGE, the pin in .gitea/workflows/molecule.yml). No privileged mode: systemd needs a
|
# (MOLECULE_IMAGE) and molecule-ubuntu2604 (MOLECULE_IMAGE_2604) images, pinned in
|
||||||
# writable cgroup, nothing else. NET_ADMIN is kept so the platform matches the other scenarios;
|
# .gitea/workflows/molecule.yml. No privileged mode: systemd needs a writable cgroup, nothing else.
|
||||||
# this role does not need it, because the Docker Engine is a stand-in package and no daemon,
|
# NET_ADMIN is kept so the platform matches the other scenarios; this role does not need it,
|
||||||
# bridge or iptables rule is created.
|
# because the Docker Engine is a stand-in package and no daemon, bridge or iptables rule is
|
||||||
|
# created.
|
||||||
driver:
|
driver:
|
||||||
name: docker
|
name: docker
|
||||||
platforms:
|
platforms:
|
||||||
@@ -24,6 +25,23 @@ platforms:
|
|||||||
- NET_ADMIN
|
- NET_ADMIN
|
||||||
security_opts:
|
security_opts:
|
||||||
- apparmor=unconfined
|
- apparmor=unconfined
|
||||||
|
- name: ${KAMINO_RUN_ID:-local}-docker-2604-instance
|
||||||
|
labels:
|
||||||
|
net.rkdr.mortis.molecule-run: "${KAMINO_RUN_ID:-local}"
|
||||||
|
image: ${MOLECULE_IMAGE_2604}
|
||||||
|
pre_build_image: true
|
||||||
|
pull: true
|
||||||
|
command: /sbin/init
|
||||||
|
cgroupns_mode: host
|
||||||
|
volumes:
|
||||||
|
- /sys/fs/cgroup:/sys/fs/cgroup:rw
|
||||||
|
tmpfs:
|
||||||
|
- /run
|
||||||
|
- /run/lock
|
||||||
|
capabilities:
|
||||||
|
- NET_ADMIN
|
||||||
|
security_opts:
|
||||||
|
- apparmor=unconfined
|
||||||
provisioner:
|
provisioner:
|
||||||
name: ansible
|
name: ansible
|
||||||
verifier:
|
verifier:
|
||||||
@@ -31,13 +49,16 @@ verifier:
|
|||||||
scenario:
|
scenario:
|
||||||
# molecule's default sequence minus both destroys: scripts/run_molecule_scenarios.sh removes the
|
# molecule's default sequence minus both destroys: scripts/run_molecule_scenarios.sh removes the
|
||||||
# container as soon as this scenario ends. After a local run, run `molecule destroy` yourself.
|
# container as soon as this scenario ends. After a local run, run `molecule destroy` yourself.
|
||||||
|
# A check runs before the converge (fresh host) and after it (configured host).
|
||||||
test_sequence:
|
test_sequence:
|
||||||
- dependency
|
- dependency
|
||||||
- cleanup
|
- cleanup
|
||||||
- syntax
|
- syntax
|
||||||
- create
|
- create
|
||||||
- prepare
|
- prepare
|
||||||
|
- check
|
||||||
- converge
|
- converge
|
||||||
|
- check
|
||||||
- idempotence
|
- idempotence
|
||||||
- side_effect
|
- side_effect
|
||||||
- verify
|
- verify
|
||||||
|
|||||||
@@ -12,6 +12,12 @@
|
|||||||
docker_molecule_repo: /srv/docker-stub-repo
|
docker_molecule_repo: /srv/docker-stub-repo
|
||||||
docker_molecule_work: /var/tmp/docker-stub-work
|
docker_molecule_work: /var/tmp/docker-stub-work
|
||||||
tasks:
|
tasks:
|
||||||
|
# The image ships without apt lists, and --check does not refresh them, so the fresh-host
|
||||||
|
# check finds the packages the role installs.
|
||||||
|
- name: Refresh the apt cache
|
||||||
|
ansible.builtin.apt:
|
||||||
|
update_cache: true
|
||||||
|
|
||||||
- name: Copy the repository builder
|
- name: Copy the repository builder
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
src: build-stub-repo.sh
|
src: build-stub-repo.sh
|
||||||
|
|||||||
@@ -30,8 +30,9 @@
|
|||||||
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
|
||||||
tags: [docker, install]
|
tags: [docker, install]
|
||||||
|
|
||||||
- name: Install Docker Engine packages
|
- name: Install Docker Engine packages
|
||||||
@@ -40,7 +41,10 @@
|
|||||||
name: "{{ docker_packages }}"
|
name: "{{ docker_packages }}"
|
||||||
state: present
|
state: present
|
||||||
update_cache: true
|
update_cache: true
|
||||||
|
register: __docker_packages
|
||||||
notify: Restart docker
|
notify: Restart docker
|
||||||
|
# Under --check a new source line is only simulated, so apt would find no Docker package.
|
||||||
|
when: not ansible_check_mode or __docker_apt_source is not changed
|
||||||
tags: [docker, install]
|
tags: [docker, install]
|
||||||
|
|
||||||
- name: Enable and start Docker service
|
- name: Enable and start Docker service
|
||||||
@@ -49,4 +53,6 @@
|
|||||||
name: "{{ docker_service }}"
|
name: "{{ docker_service }}"
|
||||||
enabled: true
|
enabled: true
|
||||||
state: started
|
state: started
|
||||||
|
# Under --check on a host without the packages there is no unit to start yet.
|
||||||
|
when: not ansible_check_mode or (__docker_apt_source is not changed and __docker_packages is not changed)
|
||||||
tags: [docker, install]
|
tags: [docker, install]
|
||||||
@@ -24,6 +24,8 @@
|
|||||||
when:
|
when:
|
||||||
- not (docker_remove | default(false) | bool)
|
- not (docker_remove | default(false) | bool)
|
||||||
- docker_update | bool
|
- docker_update | bool
|
||||||
|
# Under --check a new source line is only simulated, so no package would have a candidate.
|
||||||
|
- not ansible_check_mode or __docker_apt_source | default({}) is not changed
|
||||||
tags: [docker, update]
|
tags: [docker, update]
|
||||||
|
|
||||||
- name: Add configured users to the docker group
|
- name: Add configured users to the docker group
|
||||||
@@ -33,7 +35,10 @@
|
|||||||
groups: "{{ docker_group }}"
|
groups: "{{ docker_group }}"
|
||||||
append: true
|
append: true
|
||||||
loop: "{{ docker_users }}"
|
loop: "{{ docker_users }}"
|
||||||
when: not (docker_remove | default(false) | bool)
|
when:
|
||||||
|
- not (docker_remove | default(false) | bool)
|
||||||
|
# Under --check on a host without the packages the group does not exist yet.
|
||||||
|
- not ansible_check_mode or (__docker_apt_source | default({}) is not changed and __docker_packages | default({}) is not changed)
|
||||||
tags: [docker, configure]
|
tags: [docker, configure]
|
||||||
|
|
||||||
- name: Install or remove the boot and shutdown units
|
- name: Install or remove the boot and shutdown units
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ Installs Fail2Ban, writes `/etc/fail2ban/jail.local` from `fail2ban_jails`, ensu
|
|||||||
|
|
||||||
## Supported platforms
|
## Supported platforms
|
||||||
|
|
||||||
Ubuntu 24.04 (noble), the platform the molecule scenario runs on. The default `sshd` jail reads the systemd journal because sshd logs there on that release. The role installs `python3-systemd`, which `backend = systemd` jails need.
|
Ubuntu 24.04 (noble) and 26.04 (resolute), the platforms the molecule scenario runs on. The default `sshd` jail reads the systemd journal because sshd logs there on those releases. The role installs `python3-systemd`, which `backend = systemd` jails need.
|
||||||
|
|
||||||
Ubuntu hosts only: the role targets the Ubuntu guests whose `system_baseline` profiles install `fail2ban`; Proxmox hosts are not targeted.
|
Ubuntu hosts only: the role targets the Ubuntu guests whose `system_baseline` profiles install `fail2ban`; Proxmox hosts are not targeted.
|
||||||
|
|
||||||
@@ -82,7 +82,7 @@ Main entry point: `fail2ban` (everything), `fail2ban_install`, `fail2ban_validat
|
|||||||
|
|
||||||
## Tests
|
## Tests
|
||||||
|
|
||||||
The scenario `molecule/default/` runs in CI only, on one platform: `${MOLECULE_IMAGE}`, an Ubuntu 24.04 (noble) container. The sequence runs prepare, converge, idempotence, side effect and verify; it has no check-mode step.
|
The scenario `molecule/default/` runs in CI only, on two platforms: `${MOLECULE_IMAGE}` (Ubuntu 24.04) and `${MOLECULE_IMAGE_2604}` (Ubuntu 26.04). It runs `check` before the converge (a fresh host, where the image already has fail2ban installed) and after it (a configured host).
|
||||||
|
|
||||||
- Converge applies the main entry point with an extra `fail2ban_ignoreip` network and calls `service_jail` twice, one jail with a `logpath` and one with a `journalmatch`.
|
- Converge applies the main entry point with an extra `fail2ban_ignoreip` network and calls `service_jail` twice, one jail with a `logpath` and one with a `journalmatch`.
|
||||||
- Converge also runs inputs that must be refused: a service filter without `failregex`, and a `fail2ban_ignoreip` entry with whitespace, a plain string instead of a list, and an entry starting with `;`. The `fail2ban_ignoreip` refusals are matched on their message.
|
- Converge also runs inputs that must be refused: a service filter without `failregex`, and a `fail2ban_ignoreip` entry with whitespace, a plain string instead of a list, and an entry starting with `;`. The `fail2ban_ignoreip` refusals are matched on their message.
|
||||||
@@ -94,6 +94,7 @@ Not covered: no failure is sent through a jail, so a ban triggered by `failregex
|
|||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
- Idempotent: yes.
|
- Idempotent: yes.
|
||||||
|
- Check mode: `--check` previews a host where fail2ban is already installed; a play-level `check_mode: true` is not supported. On a host without fail2ban it fails at the configuration and service tasks: the package is not installed under `--check`, so `/etc/fail2ban`, `fail2ban-client` and the unit are missing.
|
||||||
- `fail2ban_ignoreip` lives in the `[DEFAULT]` section of `jail.local`, so it also applies to the jails that `service_jail` writes to `jail.d`. The exemption only exists once the main entry point has written `jail.local` on that host: `service_jail` does not read `fail2ban_ignoreip`, so a host that uses only `service_jail` has none.
|
- `fail2ban_ignoreip` lives in the `[DEFAULT]` section of `jail.local`, so it also applies to the jails that `service_jail` writes to `jail.d`. The exemption only exists once the main entry point has written `jail.local` on that host: `service_jail` does not read `fail2ban_ignoreip`, so a host that uses only `service_jail` has none.
|
||||||
- `fail2ban_ignoreip` replaces an `ignoreip` set in `jail.conf` or `jail.d/*.conf`, which Fail2Ban reads before `jail.local`; a `jail.d/*.local` file is read after it and can still override it for one jail. Entries must not contain whitespace, `;` or `%` (a `;` after whitespace starts a comment in Fail2Ban's config files and a `%` is interpolation syntax).
|
- `fail2ban_ignoreip` replaces an `ignoreip` set in `jail.conf` or `jail.d/*.conf`, which Fail2Ban reads before `jail.local`; a `jail.d/*.local` file is read after it and can still override it for one jail. Entries must not contain whitespace, `;` or `%` (a `;` after whitespace starts a comment in Fail2Ban's config files and a `%` is interpolation syntax).
|
||||||
- Prefer IP addresses and CIDR networks in `fail2ban_ignoreip`. Fail2Ban resolves a hostname when the jail starts, and a failed lookup leaves that entry ineffective with only a log warning. The validation of `fail2ban_ignoreip` runs under the `fail2ban_validate` tag, so `--tags fail2ban_configure` skips it.
|
- Prefer IP addresses and CIDR networks in `fail2ban_ignoreip`. Fail2Ban resolves a hostname when the jail starts, and a failed lookup leaves that entry ineffective with only a log warning. The validation of `fail2ban_ignoreip` runs under the `fail2ban_validate` tag, so `--tags fail2ban_configure` skips it.
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ galaxy_info:
|
|||||||
- name: Ubuntu
|
- name: Ubuntu
|
||||||
versions:
|
versions:
|
||||||
- noble
|
- noble
|
||||||
|
- resolute
|
||||||
galaxy_tags:
|
galaxy_tags:
|
||||||
- fail2ban
|
- fail2ban
|
||||||
- security
|
- security
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
---
|
---
|
||||||
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404 image
|
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404
|
||||||
# (MOLECULE_IMAGE, the pin in .gitea/workflows/molecule.yml). No privileged mode: systemd needs a
|
# (MOLECULE_IMAGE) and molecule-ubuntu2604 (MOLECULE_IMAGE_2604) images, pinned in
|
||||||
# writable cgroup and the firewall tools need NET_ADMIN, nothing else.
|
# .gitea/workflows/molecule.yml. No privileged mode: systemd needs a writable cgroup and the
|
||||||
|
# firewall tools need NET_ADMIN, nothing else.
|
||||||
driver:
|
driver:
|
||||||
name: docker
|
name: docker
|
||||||
platforms:
|
platforms:
|
||||||
@@ -22,6 +23,23 @@ platforms:
|
|||||||
- NET_ADMIN
|
- NET_ADMIN
|
||||||
security_opts:
|
security_opts:
|
||||||
- apparmor=unconfined
|
- apparmor=unconfined
|
||||||
|
- name: ${KAMINO_RUN_ID:-local}-fail2ban-2604-instance
|
||||||
|
labels:
|
||||||
|
net.rkdr.mortis.molecule-run: "${KAMINO_RUN_ID:-local}"
|
||||||
|
image: ${MOLECULE_IMAGE_2604}
|
||||||
|
pre_build_image: true
|
||||||
|
pull: true
|
||||||
|
command: /sbin/init
|
||||||
|
cgroupns_mode: host
|
||||||
|
volumes:
|
||||||
|
- /sys/fs/cgroup:/sys/fs/cgroup:rw
|
||||||
|
tmpfs:
|
||||||
|
- /run
|
||||||
|
- /run/lock
|
||||||
|
capabilities:
|
||||||
|
- NET_ADMIN
|
||||||
|
security_opts:
|
||||||
|
- apparmor=unconfined
|
||||||
provisioner:
|
provisioner:
|
||||||
name: ansible
|
name: ansible
|
||||||
verifier:
|
verifier:
|
||||||
@@ -29,13 +47,16 @@ verifier:
|
|||||||
scenario:
|
scenario:
|
||||||
# molecule's default sequence minus both destroys: scripts/run_molecule_scenarios.sh removes the
|
# molecule's default sequence minus both destroys: scripts/run_molecule_scenarios.sh removes the
|
||||||
# container as soon as this scenario ends. After a local run, run `molecule destroy` yourself.
|
# container as soon as this scenario ends. After a local run, run `molecule destroy` yourself.
|
||||||
|
# A check runs before the converge (fresh host) and after it (configured host).
|
||||||
test_sequence:
|
test_sequence:
|
||||||
- dependency
|
- dependency
|
||||||
- cleanup
|
- cleanup
|
||||||
- syntax
|
- syntax
|
||||||
- create
|
- create
|
||||||
- prepare
|
- prepare
|
||||||
|
- check
|
||||||
- converge
|
- converge
|
||||||
|
- check
|
||||||
- idempotence
|
- idempotence
|
||||||
- side_effect
|
- side_effect
|
||||||
- verify
|
- verify
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ Installs the Gitea git service as a systemd-managed binary with a GPG-verified d
|
|||||||
|
|
||||||
## Supported platforms
|
## Supported platforms
|
||||||
|
|
||||||
Ubuntu 24.04 (noble), the platform the molecule scenario runs on. The role uses `ansible.builtin.apt`, so Debian-family hosts only, and needs outbound access to dl.gitea.com for the binary and signature and to `gitea_gpg_key_url` (keys.openpgp.org over HTTPS by default) for the signing key.
|
Ubuntu 24.04 (noble) and 26.04 (resolute), the platforms the molecule scenario runs on. The role uses `ansible.builtin.apt`, so Debian-family hosts only, and needs outbound access to dl.gitea.com for the binary and signature and to `gitea_gpg_key_url` (keys.openpgp.org over HTTPS by default) for the signing key.
|
||||||
|
|
||||||
The role targets Ubuntu hosts that serve Gitea, not Proxmox nodes, so it does not cover Debian trixie.
|
The role targets Ubuntu hosts that serve Gitea, not Proxmox nodes, so it does not cover Debian trixie.
|
||||||
|
|
||||||
@@ -142,13 +142,13 @@ Update or remove: pass `-e gitea_update=true`, or `-e "gitea_remove=true gitea_r
|
|||||||
|
|
||||||
## Tests
|
## Tests
|
||||||
|
|
||||||
The `default` molecule scenario runs on one platform, Ubuntu 24.04 (noble) (`${MOLECULE_IMAGE}`). It never installs Gitea: converge applies nothing and every check is in `verify.yml` (see `molecule/default`). It 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 never installs Gitea: converge applies nothing and every check is in `verify.yml` (see `molecule/default`). It covers:
|
||||||
|
|
||||||
- The guard and no-op paths of the `mint` entry point: the confirm guard, the CI refusal under each of `GITHUB_ACTIONS`, `GITEA_ACTIONS` and `CI`, the no-op when `gitea_api_token` is set, and an empty token treated as missing under `--check`. All but the confirm guard run as child processes with a controlled environment.
|
- The guard and no-op paths of the `mint` entry point: the confirm guard, the CI refusal under each of `GITHUB_ACTIONS`, `GITEA_ACTIONS` and `CI`, the no-op when `gitea_api_token` is set, and an empty token treated as missing under `--check`. All but the confirm guard run as child processes with a controlled environment.
|
||||||
- The signature check of the download, against local files and throwaway keys: a signature by the pinned key places the binary; a signature by another key, a tampered binary and a key file without the pinned key each fail at the expected task; no download directory is left behind.
|
- The signature check of the download, against local files and throwaway keys: a signature by the pinned key places the binary; a signature by another key, a tampered binary and a key file without the pinned key each fail at the expected task; no download directory is left behind.
|
||||||
- The remove path, against a stub unit and binary: both are deleted, the service is no longer active, only the Gitea ufw rules are removed (the SSH rule and a rule without an owner tag stay), and no config or data directory or `gitea_user` account is created.
|
- The remove path, against a stub unit and binary: both are deleted, the service is no longer active, only the Gitea ufw rules are removed (the SSH rule and a rule without an owner tag stay), and no config or data directory or `gitea_user` account is created.
|
||||||
|
|
||||||
Not covered: install, configure, the admin user, the SSH-key API calls, the update path, the normal-flow assert on `gitea_api_token` (after the service starts) and a mint that creates a token.
|
Not covered: install, configure, the admin user, the SSH-key API calls, the update path, the normal-flow assert on `gitea_api_token` (after the service starts) and a mint that creates a token. The scenario runs `check` before and after the converge, but its converge applies nothing, so neither check runs the role.
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
@@ -162,3 +162,4 @@ Not covered: install, configure, the admin user, the SSH-key API calls, the upda
|
|||||||
- The SSH-key API calls go to `gitea_http_addr:gitea_http_port` (wildcard becomes loopback, IPv6 is bracketed), not to `gitea_domain`.
|
- The SSH-key API calls go to `gitea_http_addr:gitea_http_port` (wildcard becomes loopback, IPv6 is bracketed), not to `gitea_domain`.
|
||||||
- Handlers: `Reload Gitea` restarts the service when `app.ini` changes, and `main.yml` flushes handlers at the end so a later failure in the same play does not drop the restart. The `Reload Systemd` handler is defined but no task in the role notifies it.
|
- Handlers: `Reload Gitea` restarts the service when `app.ini` changes, and `main.yml` flushes handlers at the end so a later failure in the same play does not drop the restart. The `Reload Systemd` handler is defined but no task in the role notifies it.
|
||||||
- The play fails when the service is not `active` after start.
|
- The play fails when the service is not `active` after start.
|
||||||
|
- Check mode: `--check` is the supported preview; a play-level `check_mode: true` is not supported. Under `--check` on a host without the binary, the binary assert and the bash completion tasks are skipped. When the systemd unit is new or would change, the start, the running check, the `Reload Gitea` handler and the update swap are skipped. The check-mode path is not tested.
|
||||||
@@ -9,3 +9,5 @@
|
|||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
name: gitea
|
name: gitea
|
||||||
state: restarted
|
state: restarted
|
||||||
|
# Under --check a new unit is only simulated, so systemd would not find it.
|
||||||
|
when: not ansible_check_mode or __gitea_unit_file | default({}) is not changed
|
||||||
@@ -10,6 +10,7 @@ galaxy_info:
|
|||||||
- name: Ubuntu
|
- name: Ubuntu
|
||||||
versions:
|
versions:
|
||||||
- noble
|
- noble
|
||||||
|
- resolute
|
||||||
galaxy_tags:
|
galaxy_tags:
|
||||||
- gitea
|
- gitea
|
||||||
- git
|
- git
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
---
|
---
|
||||||
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404 image
|
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404
|
||||||
# (MOLECULE_IMAGE, the pin in .gitea/workflows/molecule.yml). Tests the guard and no-op paths of
|
# (MOLECULE_IMAGE) and molecule-ubuntu2604 (MOLECULE_IMAGE_2604) images, pinned in
|
||||||
# the role's `mint` entry point, the signature check of the download against local files and
|
# .gitea/workflows/molecule.yml. Tests the guard and no-op paths of the role's `mint` entry point,
|
||||||
# throwaway keys, and the remove path with its ufw rules. Gitea is never installed, so the
|
# the signature check of the download against local files and throwaway keys, and the remove path
|
||||||
# normal-flow assert on gitea_api_token (after the service starts) is not
|
# with its ufw rules. Gitea is never installed, so the normal-flow assert on gitea_api_token (after
|
||||||
# covered. The mint tasks only assert, but the remove-path play at the end of verify.yml needs
|
# the service starts) is not covered. The mint tasks only assert, but the remove-path play at the
|
||||||
# systemd (it stops and disables a stub unit) and ufw (it deletes the Gitea rules), so the
|
# end of verify.yml needs systemd (it stops and disables a stub unit) and ufw (it deletes the Gitea
|
||||||
# container runs systemd as PID 1 with a writable cgroup and NET_ADMIN. No privileged mode. The
|
# rules), so the container runs systemd as PID 1 with a writable cgroup and NET_ADMIN. No
|
||||||
# image has ufw and gnupg preinstalled, so the scenario downloads nothing.
|
# privileged mode. Both images have ufw and gnupg preinstalled, so the scenario downloads nothing.
|
||||||
driver:
|
driver:
|
||||||
name: docker
|
name: docker
|
||||||
platforms:
|
platforms:
|
||||||
@@ -28,6 +28,23 @@ platforms:
|
|||||||
- NET_ADMIN
|
- NET_ADMIN
|
||||||
security_opts:
|
security_opts:
|
||||||
- apparmor=unconfined
|
- apparmor=unconfined
|
||||||
|
- name: ${KAMINO_RUN_ID:-local}-gitea-2604-instance
|
||||||
|
labels:
|
||||||
|
net.rkdr.mortis.molecule-run: "${KAMINO_RUN_ID:-local}"
|
||||||
|
image: ${MOLECULE_IMAGE_2604}
|
||||||
|
pre_build_image: true
|
||||||
|
pull: true
|
||||||
|
command: /sbin/init
|
||||||
|
cgroupns_mode: host
|
||||||
|
volumes:
|
||||||
|
- /sys/fs/cgroup:/sys/fs/cgroup:rw
|
||||||
|
tmpfs:
|
||||||
|
- /run
|
||||||
|
- /run/lock
|
||||||
|
capabilities:
|
||||||
|
- NET_ADMIN
|
||||||
|
security_opts:
|
||||||
|
- apparmor=unconfined
|
||||||
provisioner:
|
provisioner:
|
||||||
name: ansible
|
name: ansible
|
||||||
inventory:
|
inventory:
|
||||||
@@ -40,13 +57,16 @@ verifier:
|
|||||||
scenario:
|
scenario:
|
||||||
# molecule's default sequence minus both destroys: scripts/run_molecule_scenarios.sh removes the
|
# molecule's default sequence minus both destroys: scripts/run_molecule_scenarios.sh removes the
|
||||||
# container as soon as this scenario ends. After a local run, run `molecule destroy` yourself.
|
# container as soon as this scenario ends. After a local run, run `molecule destroy` yourself.
|
||||||
|
# A check runs before the converge (fresh host) and after it (configured host).
|
||||||
test_sequence:
|
test_sequence:
|
||||||
- dependency
|
- dependency
|
||||||
- cleanup
|
- cleanup
|
||||||
- syntax
|
- syntax
|
||||||
- create
|
- create
|
||||||
- prepare
|
- prepare
|
||||||
|
- check
|
||||||
- converge
|
- converge
|
||||||
|
- check
|
||||||
- idempotence
|
- idempotence
|
||||||
- side_effect
|
- side_effect
|
||||||
- verify
|
- verify
|
||||||
|
|||||||
@@ -92,6 +92,8 @@
|
|||||||
changed_when: false
|
changed_when: false
|
||||||
# Read-only: the script is only generated to be written by the next task, so it must also run in --check.
|
# Read-only: the script is only generated to be written by the next task, so it must also run in --check.
|
||||||
check_mode: false
|
check_mode: false
|
||||||
|
# Under --check on a fresh host there is no binary to run.
|
||||||
|
when: not ansible_check_mode or gitea_installed
|
||||||
tags: [gitea, configure]
|
tags: [gitea, configure]
|
||||||
|
|
||||||
- name: Write bash completion to system directory
|
- name: Write bash completion to system directory
|
||||||
@@ -102,6 +104,7 @@
|
|||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
|
when: not ansible_check_mode or gitea_installed
|
||||||
tags: [gitea, configure]
|
tags: [gitea, configure]
|
||||||
|
|
||||||
- name: Create systemd service file for Gitea
|
- name: Create systemd service file for Gitea
|
||||||
@@ -127,6 +130,7 @@
|
|||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
|
register: __gitea_unit_file
|
||||||
tags: [gitea, configure]
|
tags: [gitea, configure]
|
||||||
|
|
||||||
- name: Reload systemd daemon
|
- name: Reload systemd daemon
|
||||||
@@ -164,6 +168,8 @@
|
|||||||
name: gitea
|
name: gitea
|
||||||
enabled: true
|
enabled: true
|
||||||
state: started
|
state: started
|
||||||
|
# Under --check a new unit is only simulated, so systemd would not find it.
|
||||||
|
when: not ansible_check_mode or __gitea_unit_file is not changed
|
||||||
tags: [gitea, configure]
|
tags: [gitea, configure]
|
||||||
|
|
||||||
- name: Check Gitea service status
|
- name: Check Gitea service status
|
||||||
@@ -176,7 +182,10 @@
|
|||||||
- name: Fail if Gitea service is not running
|
- name: Fail if Gitea service is not running
|
||||||
ansible.builtin.fail:
|
ansible.builtin.fail:
|
||||||
msg: "Gitea service is not running"
|
msg: "Gitea service is not running"
|
||||||
when: gitea_service_status.status.ActiveState != "active"
|
when:
|
||||||
|
- gitea_service_status.status.ActiveState != "active"
|
||||||
|
# The start above is skipped under --check for a new unit.
|
||||||
|
- not ansible_check_mode or __gitea_unit_file | default({}) is not changed
|
||||||
tags: [gitea, configure, health]
|
tags: [gitea, configure, health]
|
||||||
|
|
||||||
# The token is minted by the opt-in mint entry point, never here. This sits after the
|
# The token is minted by the opt-in mint entry point, never here. This sits after the
|
||||||
|
|||||||
@@ -39,4 +39,6 @@
|
|||||||
that:
|
that:
|
||||||
- gitea_binary.stat.exists
|
- gitea_binary.stat.exists
|
||||||
fail_msg: "Gitea binary not found after download"
|
fail_msg: "Gitea binary not found after download"
|
||||||
|
# Nothing is downloaded under --check.
|
||||||
|
when: not ansible_check_mode
|
||||||
tags: [gitea, install, health, update]
|
tags: [gitea, install, health, update]
|
||||||
@@ -64,7 +64,8 @@
|
|||||||
Gitea was not stopped and still runs {{ gitea_installed_version }}.
|
Gitea was not stopped and still runs {{ gitea_installed_version }}.
|
||||||
tags: [gitea, update]
|
tags: [gitea, update]
|
||||||
|
|
||||||
# An include does not pass its tags on to the included tasks, hence apply.
|
# An include does not pass its tags on to the included tasks, hence apply. Under --check a
|
||||||
|
# new unit is only simulated, so the stop and start of the swap would not find it.
|
||||||
- name: Swap in the staged Gitea binary
|
- name: Swap in the staged Gitea binary
|
||||||
ansible.builtin.include_role:
|
ansible.builtin.include_role:
|
||||||
name: mortis.kamino._binary_update
|
name: mortis.kamino._binary_update
|
||||||
@@ -76,6 +77,7 @@
|
|||||||
_binary_update_staged_path: "{{ gitea_staging_dir }}/gitea"
|
_binary_update_staged_path: "{{ gitea_staging_dir }}/gitea"
|
||||||
_binary_update_version_command: ["{{ gitea_install_dir }}/gitea", --version]
|
_binary_update_version_command: ["{{ gitea_install_dir }}/gitea", --version]
|
||||||
_binary_update_expected_version: "{{ gitea_version }}"
|
_binary_update_expected_version: "{{ gitea_version }}"
|
||||||
|
when: not ansible_check_mode or __gitea_unit_file | default({}) is not changed
|
||||||
tags: [gitea, update]
|
tags: [gitea, update]
|
||||||
|
|
||||||
always:
|
always:
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ Installs a Gitea Actions runner (`gitea-runner`) with Docker as a systemd servic
|
|||||||
|
|
||||||
## Supported platforms
|
## Supported platforms
|
||||||
|
|
||||||
Ubuntu 24.04 (noble), the platform the molecule scenario runs on. The role uses `ansible.builtin.apt` and installs `docker.io`, so Debian-family hosts only, and needs outbound access to dl.gitea.com and Docker Hub (the Docker check pulls `ubuntu:24.04`). On an unprivileged LXC host, Docker needs nesting enabled on the container.
|
Ubuntu 24.04 (noble) and 26.04 (resolute), the platforms the molecule scenario runs on. The role uses `ansible.builtin.apt` and installs `docker.io`, so Debian-family hosts only, and needs outbound access to dl.gitea.com and Docker Hub (the Docker check pulls `ubuntu:24.04`). On an unprivileged LXC host, Docker needs nesting enabled on the container.
|
||||||
|
|
||||||
The role targets Ubuntu hosts that run CI jobs, not Proxmox nodes, so it does not cover Debian trixie.
|
The role targets Ubuntu hosts that run CI jobs, not Proxmox nodes, so it does not cover Debian trixie.
|
||||||
|
|
||||||
@@ -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.
|
||||||
@@ -89,7 +89,7 @@ Change the registration scope of a registered runner: set `gitea_runner_registra
|
|||||||
|
|
||||||
## Tests
|
## Tests
|
||||||
|
|
||||||
The `default` molecule scenario runs on one platform, Ubuntu 24.04 (noble) (`${MOLECULE_IMAGE}`), without a Gitea server and without Docker: a stub `docker.service`, a stub runner binary and a seeded `.runner` stand in for them, and the downloads come from local `file://` URLs. It covers the converge with the prune timer and an update through `_binary_update` (and its idempotence), the rendered `config.yaml` and unit, the prune gate script, the count prune and the disk check against a stub `docker` CLI, turning the pressure prune off, a failed checksum that leaves the runner running, the input asserts, the CI refusal of a forced re-registration and the mint-before-drop order, and the remove path. Registration, the Docker install and the host packages of the host-executor label are not covered.
|
The `default` molecule scenario runs in CI only, on two platforms: `${MOLECULE_IMAGE}` (Ubuntu 24.04) and `${MOLECULE_IMAGE_2604}` (Ubuntu 26.04). It runs without a Gitea server and without Docker: a stub `docker.service`, a stub runner binary and a seeded `.runner` stand in for them, and the downloads come from local `file://` URLs. It covers the converge with the prune timer and an update through `_binary_update` (and its idempotence), the rendered `config.yaml` and unit, the prune gate script, the count prune and the disk check against a stub `docker` CLI, turning the pressure prune off, a failed checksum that leaves the runner running, the input asserts, the CI refusal of a forced re-registration and the mint-before-drop order, and the remove path. Registration, the Docker install and the host packages of the host-executor label are not covered. It runs `check` before the converge (a fresh host) and after it (a configured host).
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
@@ -101,4 +101,5 @@ The `default` molecule scenario runs on one platform, Ubuntu 24.04 (noble) (`${M
|
|||||||
- The Docker prune units (`gitea-runner-docker-prune.{service,timer}`) are written only while `gitea_runner_docker_prune_enabled` is true. Setting it back to false leaves them in place: run `systemctl disable --now gitea-runner-docker-prune.timer` by hand. `gitea_runner_remove` deletes them, the pressure units and the prune scripts. A run skipped because a job was running is not retried until the next timer elapse: shorten `gitea_runner_docker_prune_schedule` (e.g. `*-*-* 04:30:00`) if that happens.
|
- The Docker prune units (`gitea-runner-docker-prune.{service,timer}`) are written only while `gitea_runner_docker_prune_enabled` is true. Setting it back to false leaves them in place: run `systemctl disable --now gitea-runner-docker-prune.timer` by hand. `gitea_runner_remove` deletes them, the pressure units and the prune scripts. A run skipped because a job was running is not retried until the next timer elapse: shorten `gitea_runner_docker_prune_schedule` (e.g. `*-*-* 04:30:00`) if that happens.
|
||||||
- The pressure prune (`gitea-runner-docker-prune-pressure.{service,timer}`) runs once per check while usage is above the threshold; it has no low watermark, so usage that stays high needs a smaller count or a larger disk. A threshold set back to `0` stops its timer and removes its units and the disk check script. The age prunes and the count prune both apply: an image either one removes is gone.
|
- The pressure prune (`gitea-runner-docker-prune-pressure.{service,timer}`) runs once per check while usage is above the threshold; it has no low watermark, so usage that stays high needs a smaller count or a larger disk. A threshold set back to `0` stops its timer and removes its units and the disk check script. The age prunes and the count prune both apply: an image either one removes is gone.
|
||||||
- The play fails when `gitea-runner` is not `active` after start.
|
- The play fails when `gitea-runner` is not `active` after start.
|
||||||
|
- Check mode: `--check` is the supported preview; a play-level `check_mode: true` is not supported. Under `--check`, the work directory ownership task is skipped when the runner group or user is new, and starting Docker when `docker.io` is not installed yet. When the systemd unit is new or would change, the start, the running check, the `Restart Gitea Runner` handler and the update swap are skipped.
|
||||||
- `no_log` covers the token mint, the token fact and the registration command.
|
- `no_log` covers the token mint, the token fact and the registration command.
|
||||||
@@ -4,3 +4,5 @@
|
|||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
name: gitea-runner
|
name: gitea-runner
|
||||||
state: restarted
|
state: restarted
|
||||||
|
# Under --check a new unit is only simulated, so systemd would not find it.
|
||||||
|
when: not ansible_check_mode or __gitea_runner_unit_file | default({}) is not changed
|
||||||
@@ -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:
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ galaxy_info:
|
|||||||
- name: Ubuntu
|
- name: Ubuntu
|
||||||
versions:
|
versions:
|
||||||
- noble
|
- noble
|
||||||
|
- resolute
|
||||||
galaxy_tags:
|
galaxy_tags:
|
||||||
- gitea
|
- gitea
|
||||||
- actions
|
- actions
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
---
|
---
|
||||||
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404 image
|
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404
|
||||||
# (MOLECULE_IMAGE, the pin in .gitea/workflows/molecule.yml). No Gitea server and no Docker
|
# (MOLECULE_IMAGE) and molecule-ubuntu2604 (MOLECULE_IMAGE_2604) images, pinned in
|
||||||
# daemon: prepare.yml seeds a stub docker.service, a stub runner binary that reports an older
|
# .gitea/workflows/molecule.yml. No Gitea server and no Docker daemon: prepare.yml seeds a stub
|
||||||
# version, and a .runner file, so the role skips the Docker install and the registration, and
|
# docker.service, a stub runner binary that reports an older version, and a .runner file, so the
|
||||||
# the update downloads its new stub from local file:// URLs. The scenario downloads nothing.
|
# role skips the Docker install and the registration, and the update downloads its new stub from
|
||||||
|
# local file:// URLs. The scenario downloads nothing.
|
||||||
# The container runs systemd as PID 1 with a writable cgroup; no privileged mode.
|
# The container runs systemd as PID 1 with a writable cgroup; no privileged mode.
|
||||||
driver:
|
driver:
|
||||||
name: docker
|
name: docker
|
||||||
@@ -23,6 +24,21 @@ platforms:
|
|||||||
- /run/lock
|
- /run/lock
|
||||||
security_opts:
|
security_opts:
|
||||||
- apparmor=unconfined
|
- apparmor=unconfined
|
||||||
|
- name: ${KAMINO_RUN_ID:-local}-runner-2604-instance
|
||||||
|
labels:
|
||||||
|
net.rkdr.mortis.molecule-run: "${KAMINO_RUN_ID:-local}"
|
||||||
|
image: ${MOLECULE_IMAGE_2604}
|
||||||
|
pre_build_image: true
|
||||||
|
pull: true
|
||||||
|
command: /sbin/init
|
||||||
|
cgroupns_mode: host
|
||||||
|
volumes:
|
||||||
|
- /sys/fs/cgroup:/sys/fs/cgroup:rw
|
||||||
|
tmpfs:
|
||||||
|
- /run
|
||||||
|
- /run/lock
|
||||||
|
security_opts:
|
||||||
|
- apparmor=unconfined
|
||||||
provisioner:
|
provisioner:
|
||||||
name: ansible
|
name: ansible
|
||||||
# One source for every play, so a verify play that runs the role again renders the same
|
# One source for every play, so a verify play that runs the role again renders the same
|
||||||
@@ -50,13 +66,16 @@ verifier:
|
|||||||
scenario:
|
scenario:
|
||||||
# molecule's default sequence minus both destroys: scripts/run_molecule_scenarios.sh removes the
|
# molecule's default sequence minus both destroys: scripts/run_molecule_scenarios.sh removes the
|
||||||
# container as soon as this scenario ends. After a local run, run `molecule destroy` yourself.
|
# container as soon as this scenario ends. After a local run, run `molecule destroy` yourself.
|
||||||
|
# A check runs before the converge (fresh host) and after it (configured host).
|
||||||
test_sequence:
|
test_sequence:
|
||||||
- dependency
|
- dependency
|
||||||
- cleanup
|
- cleanup
|
||||||
- syntax
|
- syntax
|
||||||
- create
|
- create
|
||||||
- prepare
|
- prepare
|
||||||
|
- check
|
||||||
- converge
|
- converge
|
||||||
|
- check
|
||||||
- idempotence
|
- idempotence
|
||||||
- side_effect
|
- side_effect
|
||||||
- verify
|
- verify
|
||||||
|
|||||||
@@ -17,6 +17,10 @@
|
|||||||
owner: "{{ gitea_runner_user }}"
|
owner: "{{ gitea_runner_user }}"
|
||||||
group: "{{ gitea_runner_group }}"
|
group: "{{ gitea_runner_group }}"
|
||||||
recurse: true
|
recurse: true
|
||||||
|
# Under --check a new account is only simulated, so an existing directory cannot be chowned to it.
|
||||||
|
when: >-
|
||||||
|
not ansible_check_mode or
|
||||||
|
(__gitea_runner_group_account | default({}) is not changed and __gitea_runner_user_account | default({}) is not changed)
|
||||||
tags: [gitea_runner, configure]
|
tags: [gitea_runner, configure]
|
||||||
|
|
||||||
- name: Check current runner registration file state
|
- name: Check current runner registration file state
|
||||||
@@ -62,6 +66,7 @@
|
|||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
register: __gitea_runner_unit_file
|
||||||
tags: [gitea_runner, configure]
|
tags: [gitea_runner, configure]
|
||||||
|
|
||||||
- name: Reload systemd
|
- name: Reload systemd
|
||||||
@@ -76,6 +81,8 @@
|
|||||||
name: gitea-runner
|
name: gitea-runner
|
||||||
enabled: true
|
enabled: true
|
||||||
state: started
|
state: started
|
||||||
|
# Under --check a new unit is only simulated, so systemd would not find it.
|
||||||
|
when: not ansible_check_mode or __gitea_runner_unit_file is not changed
|
||||||
tags: [gitea_runner, configure]
|
tags: [gitea_runner, configure]
|
||||||
|
|
||||||
- name: Check runner service status
|
- name: Check runner service status
|
||||||
@@ -88,5 +95,8 @@
|
|||||||
- name: Fail if runner service is not running
|
- name: Fail if runner service is not running
|
||||||
ansible.builtin.fail:
|
ansible.builtin.fail:
|
||||||
msg: "Gitea runner service is not running"
|
msg: "Gitea runner service is not running"
|
||||||
when: gitea_runner_service_status.status.ActiveState != "active"
|
when:
|
||||||
|
- gitea_runner_service_status.status.ActiveState != "active"
|
||||||
|
# The start above is skipped under --check for a new unit.
|
||||||
|
- not ansible_check_mode or __gitea_runner_unit_file | default({}) is not changed
|
||||||
tags: [gitea_runner, configure, health]
|
tags: [gitea_runner, configure, health]
|
||||||
@@ -17,6 +17,7 @@
|
|||||||
name:
|
name:
|
||||||
- docker.io
|
- docker.io
|
||||||
state: present
|
state: present
|
||||||
|
register: __gitea_runner_docker_package
|
||||||
tags: [gitea_runner, docker, install]
|
tags: [gitea_runner, docker, install]
|
||||||
|
|
||||||
- name: Enable and start Docker
|
- name: Enable and start Docker
|
||||||
@@ -25,6 +26,8 @@
|
|||||||
name: docker
|
name: docker
|
||||||
enabled: true
|
enabled: true
|
||||||
state: started
|
state: started
|
||||||
|
# Under --check a new package is only simulated, so there is no docker unit yet.
|
||||||
|
when: not ansible_check_mode or __gitea_runner_docker_package is not changed
|
||||||
tags: [gitea_runner, docker, install]
|
tags: [gitea_runner, docker, install]
|
||||||
|
|
||||||
- name: Add the runner user to the docker group
|
- name: Add the runner user to the docker group
|
||||||
@@ -33,6 +36,8 @@
|
|||||||
name: "{{ gitea_runner_user }}"
|
name: "{{ gitea_runner_user }}"
|
||||||
groups: docker
|
groups: docker
|
||||||
append: true
|
append: true
|
||||||
|
# Under --check a new docker.io creates no docker group, and user fails on a missing group.
|
||||||
|
when: not ansible_check_mode or __gitea_runner_docker_package is not changed
|
||||||
tags: [gitea_runner, docker, install]
|
tags: [gitea_runner, docker, install]
|
||||||
|
|
||||||
# Pulls ubuntu:24.04 from Docker Hub. Also proves Docker runs inside a container host
|
# Pulls ubuntu:24.04 from Docker Hub. Also proves Docker runs inside a container host
|
||||||
|
|||||||
@@ -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 }}"
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
ansible.builtin.group:
|
ansible.builtin.group:
|
||||||
name: "{{ gitea_runner_group }}"
|
name: "{{ gitea_runner_group }}"
|
||||||
system: true
|
system: true
|
||||||
|
register: __gitea_runner_group_account
|
||||||
tags: [gitea_runner, prereqs, always]
|
tags: [gitea_runner, prereqs, always]
|
||||||
|
|
||||||
- name: Ensure runner user exists
|
- name: Ensure runner user exists
|
||||||
@@ -16,6 +17,7 @@
|
|||||||
home: "{{ gitea_runner_home }}"
|
home: "{{ gitea_runner_home }}"
|
||||||
create_home: true
|
create_home: true
|
||||||
system: true
|
system: true
|
||||||
|
register: __gitea_runner_user_account
|
||||||
tags: [gitea_runner, prereqs, always]
|
tags: [gitea_runner, prereqs, always]
|
||||||
|
|
||||||
- name: Check if runner is installed
|
- name: Check if runner is installed
|
||||||
|
|||||||
@@ -54,7 +54,8 @@
|
|||||||
The runner was not stopped and still runs {{ gitea_runner_installed_version }}.
|
The runner was not stopped and still runs {{ gitea_runner_installed_version }}.
|
||||||
tags: [gitea_runner, update]
|
tags: [gitea_runner, update]
|
||||||
|
|
||||||
# An include does not pass its tags on to the included tasks, hence apply.
|
# An include does not pass its tags on to the included tasks, hence apply. Under --check a
|
||||||
|
# new unit is only simulated, so the stop and start of the swap would not find it.
|
||||||
- name: Swap in the staged runner binary
|
- name: Swap in the staged runner binary
|
||||||
ansible.builtin.include_role:
|
ansible.builtin.include_role:
|
||||||
name: mortis.kamino._binary_update
|
name: mortis.kamino._binary_update
|
||||||
@@ -66,6 +67,7 @@
|
|||||||
_binary_update_staged_path: "{{ gitea_runner_staged_binary }}"
|
_binary_update_staged_path: "{{ gitea_runner_staged_binary }}"
|
||||||
_binary_update_version_command: ["{{ gitea_runner_install_dir }}/gitea-runner", --version]
|
_binary_update_version_command: ["{{ gitea_runner_install_dir }}/gitea-runner", --version]
|
||||||
_binary_update_expected_version: "{{ gitea_runner_version }}"
|
_binary_update_expected_version: "{{ gitea_runner_version }}"
|
||||||
|
when: not ansible_check_mode or __gitea_runner_unit_file | default({}) is not changed
|
||||||
tags: [gitea_runner, update]
|
tags: [gitea_runner, update]
|
||||||
|
|
||||||
always:
|
always:
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ None. The role does not tag its tasks, so only a play-level tag applies.
|
|||||||
|
|
||||||
## Tests
|
## Tests
|
||||||
|
|
||||||
`molecule/default` runs in CI only, on one platform: Ubuntu 24.04 (noble), the `molecule-ubuntu2404` image (`${MOLECULE_IMAGE}`). The image has no `ifupdown2`, and a real reload could cut the container's own network, so the validate command is `/bin/true` and the apply command appends to a marker file; the rest of the role runs unchanged. Prepare seeds `/etc/network/interfaces` with a legacy body, so the converge has a change to make and a backup to take.
|
`molecule/default` runs in CI only, on one platform: Ubuntu 24.04 (noble), the `molecule-ubuntu2404` image (`${MOLECULE_IMAGE}`). The image has no `ifupdown2`, and a real reload could cut the container's own network, so the validate command is `/bin/true` and the apply command appends to a marker file; the rest of the role runs unchanged. Prepare seeds `/etc/network/interfaces` with a legacy body, so the converge has a change to make and a backup to take. The scenario runs `check` before the converge (fresh host) and after it (configured host).
|
||||||
|
|
||||||
Verify checks:
|
Verify checks:
|
||||||
|
|
||||||
@@ -76,4 +76,5 @@ It does not test `ifreload`, so no Debian release or `ifupdown2` version is veri
|
|||||||
- On change the order is: copy the current file to `network_interfaces_backup`, write the new file (notifies `Reload Interfaces`), run the validate command, flush handlers. Any failure in that block restores the backup and fails with "Invalid network configuration detected. Previous config restored." The restore does not reload the interfaces.
|
- On change the order is: copy the current file to `network_interfaces_backup`, write the new file (notifies `Reload Interfaces`), run the validate command, flush handlers. Any failure in that block restores the backup and fails with "Invalid network configuration detected. Previous config restored." The restore does not reload the interfaces.
|
||||||
- The validate command runs after the file is written, and the reload runs right after it. A configuration that passes validation but breaks connectivity is not detected.
|
- The validate command runs after the file is written, and the reload runs right after it. A configuration that passes validation but breaks connectivity is not detected.
|
||||||
- With `method: static`, `address` and `netmask` are required by the template.
|
- With `method: static`, `address` and `netmask` are required by the template.
|
||||||
|
- Check mode: `--check` is the supported preview; a play-level `check_mode: true` is not supported. Under `--check` the new file is not written, so the validate command and the reload are skipped; the preview shows whether the file would change, not whether it is valid.
|
||||||
- `no_log` is not used: the role handles no secrets.
|
- `no_log` is not used: the role handles no secrets.
|
||||||
@@ -29,13 +29,16 @@ verifier:
|
|||||||
scenario:
|
scenario:
|
||||||
# molecule's default sequence minus both destroys: scripts/run_molecule_scenarios.sh removes the
|
# molecule's default sequence minus both destroys: scripts/run_molecule_scenarios.sh removes the
|
||||||
# container as soon as this scenario ends. After a local run, run `molecule destroy` yourself.
|
# container as soon as this scenario ends. After a local run, run `molecule destroy` yourself.
|
||||||
|
# A check runs before the converge (fresh host) and after it (configured host).
|
||||||
test_sequence:
|
test_sequence:
|
||||||
- dependency
|
- dependency
|
||||||
- cleanup
|
- cleanup
|
||||||
- syntax
|
- syntax
|
||||||
- create
|
- create
|
||||||
- prepare
|
- prepare
|
||||||
|
- check
|
||||||
- converge
|
- converge
|
||||||
|
- check
|
||||||
- idempotence
|
- idempotence
|
||||||
- side_effect
|
- side_effect
|
||||||
- verify
|
- verify
|
||||||
|
|||||||
@@ -4,9 +4,7 @@ Installs [Pi-hole](https://pi-hole.net) v6 by cloning the upstream repository an
|
|||||||
|
|
||||||
## Supported platforms
|
## Supported platforms
|
||||||
|
|
||||||
Ubuntu 24.04 (noble), the platform the molecule scenario runs on. The role asserts that the host is Ubuntu before any change. The package dependencies come from `ansible.builtin.apt`. The host needs outbound access to the upstream Pi-hole repository (`repo.remote` in the merged settings) and to the apt mirrors.
|
Ubuntu 24.04 (noble) and 26.04 (resolute), the platforms the molecule scenario runs on. The role asserts that the host is Ubuntu before any change. The package dependencies come from `ansible.builtin.apt`. The host needs outbound access to the upstream Pi-hole repository (`repo.remote` in the merged settings) and to the apt mirrors.
|
||||||
|
|
||||||
Untested platforms: Ubuntu 26.04 (resolute). The apt dependencies exist there, but the scenario does not run on it yet.
|
|
||||||
|
|
||||||
The role targets Ubuntu hosts that serve DNS, not Proxmox nodes, so it does not cover Debian trixie: the upstream installer is run on the Ubuntu hosts it is tested on.
|
The role targets Ubuntu hosts that serve DNS, not Proxmox nodes, so it does not cover Debian trixie: the upstream installer is run on the Ubuntu hosts it is tested on.
|
||||||
|
|
||||||
@@ -60,7 +58,7 @@ The input asserts carry `always` (and `assert`), so they run whatever tags are s
|
|||||||
|
|
||||||
## Tests
|
## Tests
|
||||||
|
|
||||||
The `default` molecule scenario runs on noble. It replaces the upstream repository with a local stub whose installer only logs its arguments and creates the database file, so it tests the merge, the asserts, the user, the configuration directory and the rendered `pihole.toml` (owner, group and mode), the clone's checked-out version, the installer sequence (install once, then reconfigure from the handler) and idempotence, not Pi-hole itself: no pihole-FTL service runs, so that the service loaded the configuration is not verified. It runs `check` before the converge (a first-run preview) and after the idempotence run. Negative tests in `verify.yml` cover a host without Ubuntu facts, a missing `pihole_web_password`, an unset interface, empty upstreams, a non-string password and the placeholder password.
|
The `default` molecule scenario runs in CI only, on two platforms: `${MOLECULE_IMAGE}` (Ubuntu 24.04) and `${MOLECULE_IMAGE_2604}` (Ubuntu 26.04). It replaces the upstream repository with a local stub whose installer only logs its arguments and creates the database file, so it tests the merge, the asserts, the user, the configuration directory and the rendered `pihole.toml` (owner, group and mode), the clone's checked-out version, the installer sequence (install once, then reconfigure from the handler) and idempotence, not Pi-hole itself: no pihole-FTL service runs, so that the service loaded the configuration is not verified. It runs `check` before the converge (a fresh host) and after it (a configured host). Negative tests in `verify.yml` cover a host without Ubuntu facts, a missing `pihole_web_password`, an unset interface, empty upstreams, a non-string password and the placeholder password.
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ galaxy_info:
|
|||||||
- name: Ubuntu
|
- name: Ubuntu
|
||||||
versions:
|
versions:
|
||||||
- noble
|
- noble
|
||||||
|
- resolute
|
||||||
galaxy_tags:
|
galaxy_tags:
|
||||||
- pihole
|
- pihole
|
||||||
- dns
|
- dns
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
---
|
---
|
||||||
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404 image
|
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404
|
||||||
# (MOLECULE_IMAGE, the pin in .gitea/workflows/molecule.yml). Needs outbound network for the apt packages. The upstream
|
# (MOLECULE_IMAGE) and molecule-ubuntu2604 (MOLECULE_IMAGE_2604) images, pinned in
|
||||||
# Pi-hole repository is replaced by a local stub whose installer only logs its arguments
|
# .gitea/workflows/molecule.yml. Needs outbound network for the apt packages. The upstream Pi-hole
|
||||||
# (prepare.yml), so the scenario tests the role's own logic, not Pi-hole itself.
|
# repository is replaced by a local stub whose installer only logs its arguments (prepare.yml), so
|
||||||
# The containers run systemd as PID 1 with a writable cgroup; no privileged mode.
|
# the scenario tests the role's own logic, not Pi-hole itself. The containers run systemd as PID 1
|
||||||
|
# with a writable cgroup; no privileged mode.
|
||||||
driver:
|
driver:
|
||||||
name: docker
|
name: docker
|
||||||
platforms:
|
platforms:
|
||||||
@@ -22,6 +23,21 @@ platforms:
|
|||||||
- /run/lock
|
- /run/lock
|
||||||
security_opts:
|
security_opts:
|
||||||
- apparmor=unconfined
|
- apparmor=unconfined
|
||||||
|
- name: ${KAMINO_RUN_ID:-local}-pihole-resolute
|
||||||
|
labels:
|
||||||
|
net.rkdr.mortis.molecule-run: "${KAMINO_RUN_ID:-local}"
|
||||||
|
image: ${MOLECULE_IMAGE_2604}
|
||||||
|
pre_build_image: true
|
||||||
|
pull: true
|
||||||
|
command: /sbin/init
|
||||||
|
cgroupns_mode: host
|
||||||
|
volumes:
|
||||||
|
- /sys/fs/cgroup:/sys/fs/cgroup:rw
|
||||||
|
tmpfs:
|
||||||
|
- /run
|
||||||
|
- /run/lock
|
||||||
|
security_opts:
|
||||||
|
- apparmor=unconfined
|
||||||
provisioner:
|
provisioner:
|
||||||
name: ansible
|
name: ansible
|
||||||
# One source for every play, so the converge and the negative tests in verify.yml start from
|
# One source for every play, so the converge and the negative tests in verify.yml start from
|
||||||
@@ -47,7 +63,7 @@ verifier:
|
|||||||
scenario:
|
scenario:
|
||||||
# molecule's default sequence minus both destroys (scripts/run_molecule_scenarios.sh removes the
|
# molecule's default sequence minus both destroys (scripts/run_molecule_scenarios.sh removes the
|
||||||
# containers as soon as this scenario ends; after a local run, run `molecule destroy` yourself),
|
# containers as soon as this scenario ends; after a local run, run `molecule destroy` yourself),
|
||||||
# plus two check steps: one before the converge (first-run preview), one after the idempotence run.
|
# plus a check before the converge (fresh host) and one after it (configured host).
|
||||||
test_sequence:
|
test_sequence:
|
||||||
- dependency
|
- dependency
|
||||||
- cleanup
|
- cleanup
|
||||||
@@ -56,8 +72,8 @@ scenario:
|
|||||||
- prepare
|
- prepare
|
||||||
- check
|
- check
|
||||||
- converge
|
- converge
|
||||||
- idempotence
|
|
||||||
- check
|
- check
|
||||||
|
- idempotence
|
||||||
- side_effect
|
- side_effect
|
||||||
- verify
|
- verify
|
||||||
- cleanup
|
- cleanup
|
||||||
@@ -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.
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ The input validation (`tasks/validate.yml`) carries `always`, so it runs whateve
|
|||||||
|
|
||||||
## Tests
|
## Tests
|
||||||
|
|
||||||
The `default` molecule scenario runs in CI on Ubuntu 24.04 (noble), the `molecule-ubuntu2404` image, which stands in for the Proxmox node. The API lifecycle (detect, create, update, resize, start, stop, delete and the restarts) is not exercised: there is no Proxmox API in the scenario. The converge includes the internal task files `main.yml` runs on the node side, in its order (`validate`, `firewall`, `raw_config`), with `pve_lxc_state: stopped`, under which the role never restarts the container. Prepare seeds a container config with stale `lxc.*` lines, blockinfile markers and a snapshot section, and backup copies of two containers' configs. Verify checks the reconciled config byte for byte (Proxmox's lines kept in order, the desired `lxc.*` lines after them, the snapshot section untouched), the rendered firewall file, and that only this container's backups were removed. It runs `check` before the converge and after the idempotence run. Negative tests cover a state outside the spec, missing API credentials and a missing network prefix through `main`, and raw config given as a string, outside the `lxc.` namespace or with two lines in one item, a malformed firewall rule and an unknown policy through `validate`; a run with `pve_lxc_manage_lifecycle: false` checks the presence facts. No Proxmox service runs, so pmxcfs's handling of the files and `pve-firewall` loading the rules are not verified.
|
The `default` molecule scenario runs in CI on Ubuntu 24.04 (noble), the `molecule-ubuntu2404` image, which stands in for the Proxmox node. The API lifecycle (detect, create, update, resize, start, stop, delete and the restarts) is not exercised: there is no Proxmox API in the scenario. The converge includes the internal task files `main.yml` runs on the node side, in its order (`validate`, `firewall`, `raw_config`), with `pve_lxc_state: stopped`, under which the role never restarts the container. Prepare seeds a container config with stale `lxc.*` lines, blockinfile markers and a snapshot section, and backup copies of two containers' configs. Verify checks the reconciled config byte for byte (Proxmox's lines kept in order, the desired `lxc.*` lines after them, the snapshot section untouched), the rendered firewall file, and that only this container's backups were removed. It runs `check` before the converge (a fresh host) and after it (a configured host). Negative tests cover a state outside the spec, missing API credentials and a missing network prefix through `main`, and raw config given as a string, outside the `lxc.` namespace or with two lines in one item, a malformed firewall rule and an unknown policy through `validate`; a run with `pve_lxc_manage_lifecycle: false` checks the presence facts. No Proxmox service runs, so pmxcfs's handling of the files and `pve-firewall` loading the rules are not verified.
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ verifier:
|
|||||||
scenario:
|
scenario:
|
||||||
# molecule's default sequence minus both destroys (scripts/run_molecule_scenarios.sh removes the
|
# molecule's default sequence minus both destroys (scripts/run_molecule_scenarios.sh removes the
|
||||||
# container as soon as this scenario ends; after a local run, run `molecule destroy` yourself),
|
# container as soon as this scenario ends; after a local run, run `molecule destroy` yourself),
|
||||||
# plus two check steps: one before the converge (first-run preview), one after the idempotence run.
|
# plus a check before the converge (fresh host) and one after it (configured host).
|
||||||
test_sequence:
|
test_sequence:
|
||||||
- dependency
|
- dependency
|
||||||
- cleanup
|
- cleanup
|
||||||
@@ -66,8 +66,8 @@ scenario:
|
|||||||
- prepare
|
- prepare
|
||||||
- check
|
- check
|
||||||
- converge
|
- converge
|
||||||
- idempotence
|
|
||||||
- check
|
- check
|
||||||
|
- idempotence
|
||||||
- side_effect
|
- side_effect
|
||||||
- verify
|
- verify
|
||||||
- cleanup
|
- cleanup
|
||||||
@@ -4,9 +4,9 @@ Writes a hardened sshd drop-in, selected by a profile, and refuses configuration
|
|||||||
|
|
||||||
## Supported platforms
|
## Supported platforms
|
||||||
|
|
||||||
Ubuntu 24.04 (noble), the platform the molecule scenario runs on.
|
Ubuntu 24.04 (noble) and 26.04 (resolute), the platforms the molecule scenario runs on.
|
||||||
|
|
||||||
Untested platforms: Ubuntu 22.04 (jammy) and Debian trixie (Proxmox VE 9 nodes, the `pve` profile), listed in `meta/main.yml` but not converged by a test.
|
Untested platforms: Debian trixie (Proxmox VE 9 nodes, the `pve` profile), listed in `meta/main.yml` but not converged by a test.
|
||||||
|
|
||||||
The role targets Ubuntu guests (the `ubuntu_lxc` and `ubuntu_vm` profiles) and Proxmox VE nodes (the `pve` profile).
|
The role targets Ubuntu guests (the `ubuntu_lxc` and `ubuntu_vm` profiles) and Proxmox VE nodes (the `pve` profile).
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ The role defines none.
|
|||||||
|
|
||||||
## Tests
|
## Tests
|
||||||
|
|
||||||
The scenario `molecule/default/`, run by the Collection's CI, runs on one platform: `${MOLECULE_IMAGE}`, an Ubuntu 24.04 (noble) container that ships openssh-server. The sequence runs converge, idempotence and verify; it has no check-mode step.
|
The scenario `molecule/default/` runs in CI only, on two platforms: `${MOLECULE_IMAGE}` (Ubuntu 24.04) and `${MOLECULE_IMAGE_2604}` (Ubuntu 26.04). Both images ship openssh-server. It runs `check` before the converge (a fresh host) and after it (a configured host).
|
||||||
|
|
||||||
- Converge applies the `ubuntu_lxc` profile. It then loads the defaults through `tasks_from: validate.yml` without changing the host: every profile (`pve`, `ubuntu_lxc`, `ubuntu_vm`) passes validation and keeps its root login policy and key algorithms, a consumer `sshd_settings` override wins over the profile, and the `pve` guard accepts each value that allows root key login.
|
- Converge applies the `ubuntu_lxc` profile. It then loads the defaults through `tasks_from: validate.yml` without changing the host: every profile (`pve`, `ubuntu_lxc`, `ubuntu_vm`) passes validation and keeps its root login policy and key algorithms, a consumer `sshd_settings` override wins over the profile, and the `pve` guard accepts each value that allows root key login.
|
||||||
- Verify first checks the refusals: a run without `sshd_profile`, `PubkeyAuthentication no` (lock-out), a `pve` profile with `PermitRootLogin no` or `forced-commands-only`, a `pve` profile without `rsa-sha2-512`, SHA-1 `ssh-rsa`, and an unknown profile. Each but the missing profile is matched on its message.
|
- Verify first checks the refusals: a run without `sshd_profile`, `PubkeyAuthentication no` (lock-out), a `pve` profile with `PermitRootLogin no` or `forced-commands-only`, a `pve` profile without `rsa-sha2-512`, SHA-1 `ssh-rsa`, and an unknown profile. Each but the missing profile is matched on its message.
|
||||||
@@ -71,6 +71,7 @@ Not covered: the `pve` profile is not converged and no SSH login is attempted.
|
|||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
- Idempotent: yes.
|
- Idempotent: yes.
|
||||||
|
- Check mode: `--check` is the supported preview; a play-level `check_mode: true` is not supported.
|
||||||
- `tasks/validate.yml` fails the play for an unknown profile, an empty merged result, `PasswordAuthentication no` without `PubkeyAuthentication yes`, a `pve` profile whose `PermitRootLogin` does not allow root key login (`prohibit-password`, its alias `without-password`, or `yes`; `no` and `forced-commands-only` are refused), a `pve` profile whose `HostKeyAlgorithms` or `PubkeyAcceptedAlgorithms` lacks `rsa-sha2-512` (the `+`/`-`/`^` list forms are not parsed and fail; write the full list), and any profile that lists SHA-1 `ssh-rsa` in either.
|
- `tasks/validate.yml` fails the play for an unknown profile, an empty merged result, `PasswordAuthentication no` without `PubkeyAuthentication yes`, a `pve` profile whose `PermitRootLogin` does not allow root key login (`prohibit-password`, its alias `without-password`, or `yes`; `no` and `forced-commands-only` are refused), a `pve` profile whose `HostKeyAlgorithms` or `PubkeyAcceptedAlgorithms` lacks `rsa-sha2-512` (the `+`/`-`/`^` list forms are not parsed and fail; write the full list), and any profile that lists SHA-1 `ssh-rsa` in either.
|
||||||
- The drop-in is installed with `validate: sshd -t -f %s`. The handler named `Restart SSH` reloads the service, and is skipped in check mode or when `sshd_reload` is false.
|
- The drop-in is installed with `validate: sshd -t -f %s`. The handler named `Restart SSH` reloads the service, and is skipped in check mode or when `sshd_reload` is false.
|
||||||
- `ssh-keygen -A` runs on every play and always reports ok.
|
- `ssh-keygen -A` runs on every play and always reports ok.
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ galaxy_info:
|
|||||||
platforms:
|
platforms:
|
||||||
- name: Ubuntu
|
- name: Ubuntu
|
||||||
versions:
|
versions:
|
||||||
- jammy
|
|
||||||
- noble
|
- noble
|
||||||
|
- resolute
|
||||||
- name: Debian
|
- name: Debian
|
||||||
versions:
|
versions:
|
||||||
- trixie
|
- trixie
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
# The production profile: Ubuntu 24.04 LXCs. Only the profile name and the user are supplied.
|
# The production profile: Ubuntu LXCs. Only the profile name and the user are supplied.
|
||||||
- name: Converge the role with a valid profile
|
- name: Converge the role with a valid profile
|
||||||
hosts: all
|
hosts: all
|
||||||
vars:
|
vars:
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
---
|
---
|
||||||
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404 image
|
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404
|
||||||
# (MOLECULE_IMAGE, the pin in .gitea/workflows/molecule.yml), which ships openssh-server. No
|
# (MOLECULE_IMAGE) and molecule-ubuntu2604 (MOLECULE_IMAGE_2604) images, pinned in
|
||||||
# privileged mode: systemd needs a writable cgroup; NET_ADMIN keeps the container the same as
|
# .gitea/workflows/molecule.yml; both ship openssh-server. No privileged mode: systemd
|
||||||
# the other role scenarios.
|
# needs a writable cgroup; NET_ADMIN keeps the container the same as the other role scenarios.
|
||||||
driver:
|
driver:
|
||||||
name: docker
|
name: docker
|
||||||
platforms:
|
platforms:
|
||||||
@@ -23,6 +23,23 @@ platforms:
|
|||||||
- NET_ADMIN
|
- NET_ADMIN
|
||||||
security_opts:
|
security_opts:
|
||||||
- apparmor=unconfined
|
- apparmor=unconfined
|
||||||
|
- name: ${KAMINO_RUN_ID:-local}-sshd-2604-instance
|
||||||
|
labels:
|
||||||
|
net.rkdr.mortis.molecule-run: "${KAMINO_RUN_ID:-local}"
|
||||||
|
image: ${MOLECULE_IMAGE_2604}
|
||||||
|
pre_build_image: true
|
||||||
|
pull: true
|
||||||
|
command: /sbin/init
|
||||||
|
cgroupns_mode: host
|
||||||
|
volumes:
|
||||||
|
- /sys/fs/cgroup:/sys/fs/cgroup:rw
|
||||||
|
tmpfs:
|
||||||
|
- /run
|
||||||
|
- /run/lock
|
||||||
|
capabilities:
|
||||||
|
- NET_ADMIN
|
||||||
|
security_opts:
|
||||||
|
- apparmor=unconfined
|
||||||
provisioner:
|
provisioner:
|
||||||
name: ansible
|
name: ansible
|
||||||
verifier:
|
verifier:
|
||||||
@@ -30,13 +47,16 @@ verifier:
|
|||||||
scenario:
|
scenario:
|
||||||
# molecule's default sequence minus both destroys: scripts/run_molecule_scenarios.sh removes the
|
# molecule's default sequence minus both destroys: scripts/run_molecule_scenarios.sh removes the
|
||||||
# container as soon as this scenario ends. After a local run, run `molecule destroy` yourself.
|
# container as soon as this scenario ends. After a local run, run `molecule destroy` yourself.
|
||||||
|
# A check runs before the converge (fresh host) and after it (configured host).
|
||||||
test_sequence:
|
test_sequence:
|
||||||
- dependency
|
- dependency
|
||||||
- cleanup
|
- cleanup
|
||||||
- syntax
|
- syntax
|
||||||
- create
|
- create
|
||||||
- prepare
|
- prepare
|
||||||
|
- check
|
||||||
- converge
|
- converge
|
||||||
|
- check
|
||||||
- idempotence
|
- idempotence
|
||||||
- side_effect
|
- side_effect
|
||||||
- verify
|
- verify
|
||||||
|
|||||||
@@ -237,8 +237,10 @@
|
|||||||
- name: Root logs in with keys only, passwords stay off
|
- name: Root logs in with keys only, passwords stay off
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
# sshd -T prints the first alias in its table for prohibit-password: without-password.
|
# sshd -T prints prohibit-password under one of its names, by OpenSSH version.
|
||||||
- sshd_verify_pve_effective.stdout_lines is contains('permitrootlogin without-password')
|
- >-
|
||||||
|
'permitrootlogin prohibit-password' in sshd_verify_pve_effective.stdout_lines
|
||||||
|
or 'permitrootlogin without-password' in sshd_verify_pve_effective.stdout_lines
|
||||||
- sshd_verify_pve_effective.stdout_lines is contains('passwordauthentication no')
|
- sshd_verify_pve_effective.stdout_lines is contains('passwordauthentication no')
|
||||||
- sshd_verify_pve_effective.stdout_lines is contains('pubkeyauthentication yes')
|
- sshd_verify_pve_effective.stdout_lines is contains('pubkeyauthentication yes')
|
||||||
quiet: true
|
quiet: true
|
||||||
|
|||||||
@@ -4,15 +4,15 @@ Applies an OS baseline chosen by `system_baseline_system_type`: apt upgrade, pac
|
|||||||
|
|
||||||
## Supported platforms
|
## Supported platforms
|
||||||
|
|
||||||
Ubuntu 24.04 (noble) passes the molecule scenario. The tasks use apt and the reboot check is limited to the Debian family. See `meta/main.yml`.
|
Ubuntu 24.04 (noble) and 26.04 (resolute), the platforms the molecule scenario runs on. The tasks use apt and the reboot check is limited to the Debian family. See `meta/main.yml`.
|
||||||
|
|
||||||
Untested platforms: Debian 13 (trixie, Proxmox hosts), not verified by a test; Ubuntu 22.04 (jammy), listed in `meta/main.yml` but neither supported nor tested.
|
Untested platforms: Debian 13 (trixie, Proxmox hosts), listed in `meta/main.yml` but not verified by a test.
|
||||||
|
|
||||||
The role targets Ubuntu guests (the `ubuntu_lxc` and `ubuntu_vm` profiles) and Proxmox VE hosts on Debian (the `pve` profile).
|
The role targets Ubuntu guests (the `ubuntu_lxc` and `ubuntu_vm` profiles) and Proxmox VE hosts on Debian (the `pve` profile).
|
||||||
|
|
||||||
## 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 |
|
||||||
@@ -124,13 +126,15 @@ The two task files besides `main` are a supported interface, for a caller that d
|
|||||||
|
|
||||||
## Tests
|
## Tests
|
||||||
|
|
||||||
The scenario `molecule/default/` runs in CI only, on one platform: `${MOLECULE_IMAGE}`, an Ubuntu 24.04 (noble) container. It installs packages from the Ubuntu mirrors, so the runner needs outbound network. The sequence runs prepare, converge, idempotence and verify; it has no check-mode step.
|
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`.
|
||||||
@@ -207,6 +228,8 @@ The upgrade runs over the SSH connection Ansible uses. An `openssh-server` upgra
|
|||||||
|
|
||||||
In a dry run (`--check`) the main flow does not run the apt upgrade: a package that is only waiting for the next patch run, or a package cache older than an hour, is not drift, and the package module reports both as `changed`, so a scheduled dry run would flag every host whenever a package landed in between. The autoremove and autoclean step still runs, and is checked: a leftover package it would remove is reported as `changed`, on purpose. `apt-get autoclean` runs in this step in a real run, in the main flow and in the `update` entry point. The `update` entry point is unchanged: it is an explicit request to update, so in check mode it still previews the upgrade.
|
In a dry run (`--check`) the main flow does not run the apt upgrade: a package that is only waiting for the next patch run, or a package cache older than an hour, is not drift, and the package module reports both as `changed`, so a scheduled dry run would flag every host whenever a package landed in between. The autoremove and autoclean step still runs, and is checked: a leftover package it would remove is reported as `changed`, on purpose. `apt-get autoclean` runs in this step in a real run, in the main flow and in the `update` entry point. The `update` entry point is unchanged: it is an explicit request to update, so in check mode it still previews the upgrade.
|
||||||
|
|
||||||
|
`--check` is the supported preview; a play-level `check_mode: true` is not supported.
|
||||||
|
|
||||||
### Unattended-upgrades origins
|
### Unattended-upgrades origins
|
||||||
|
|
||||||
A profile's `unattended_upgrade_origins` list pins the origins unattended-upgrades may install from. apt merges every file in `/etc/apt/apt.conf.d` and appends list entries across files, so a later file that only lists origins would widen the distribution's `50unattended-upgrades`, never narrow it. A non-empty list is therefore written to `/etc/apt/apt.conf.d/90unattended-upgrades-origins`, which sorts after `50unattended-upgrades`, clears `Unattended-Upgrade::Allowed-Origins` and `Unattended-Upgrade::Origins-Pattern` (apt's `#clear` directive) and sets only the listed patterns. The origin lists in `50unattended-upgrades` itself are not edited. An empty or missing list removes the drop-in.
|
A profile's `unattended_upgrade_origins` list pins the origins unattended-upgrades may install from. apt merges every file in `/etc/apt/apt.conf.d` and appends list entries across files, so a later file that only lists origins would widen the distribution's `50unattended-upgrades`, never narrow it. A non-empty list is therefore written to `/etc/apt/apt.conf.d/90unattended-upgrades-origins`, which sorts after `50unattended-upgrades`, clears `Unattended-Upgrade::Allowed-Origins` and `Unattended-Upgrade::Origins-Pattern` (apt's `#clear` directive) and sets only the listed patterns. The origin lists in `50unattended-upgrades` itself are not edited. An empty or missing list removes the drop-in.
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ galaxy_info:
|
|||||||
platforms:
|
platforms:
|
||||||
- name: Ubuntu
|
- name: Ubuntu
|
||||||
versions:
|
versions:
|
||||||
- jammy
|
|
||||||
- noble
|
- noble
|
||||||
|
- resolute
|
||||||
- name: Debian
|
- name: Debian
|
||||||
versions:
|
versions:
|
||||||
- trixie
|
- trixie
|
||||||
|
|||||||
@@ -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,10 +1,10 @@
|
|||||||
---
|
---
|
||||||
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404 image
|
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404
|
||||||
# (MOLECULE_IMAGE, the pin in .gitea/workflows/molecule.yml). Unlike the other scenarios
|
# (MOLECULE_IMAGE) and molecule-ubuntu2604 (MOLECULE_IMAGE_2604) images, pinned in
|
||||||
# this one installs packages (the role's system_baseline_essential_packages list) from the Ubuntu
|
# .gitea/workflows/molecule.yml. Unlike the other scenarios this one installs packages (the
|
||||||
# mirrors during prepare and converge, so the runner needs outbound network. No
|
# role's system_baseline_essential_packages list) from the Ubuntu mirrors during prepare and
|
||||||
# privileged mode: systemd needs a writable cgroup and the firewall tools need
|
# converge, so the runner needs outbound network. No privileged mode: systemd needs a writable
|
||||||
# NET_ADMIN, nothing else.
|
# cgroup and the firewall tools need NET_ADMIN, nothing else.
|
||||||
driver:
|
driver:
|
||||||
name: docker
|
name: docker
|
||||||
platforms:
|
platforms:
|
||||||
@@ -25,6 +25,23 @@ platforms:
|
|||||||
- NET_ADMIN
|
- NET_ADMIN
|
||||||
security_opts:
|
security_opts:
|
||||||
- apparmor=unconfined
|
- apparmor=unconfined
|
||||||
|
- name: ${KAMINO_RUN_ID:-local}-system-baseline-2604-instance
|
||||||
|
labels:
|
||||||
|
net.rkdr.mortis.molecule-run: "${KAMINO_RUN_ID:-local}"
|
||||||
|
image: ${MOLECULE_IMAGE_2604}
|
||||||
|
pre_build_image: true
|
||||||
|
pull: true
|
||||||
|
command: /sbin/init
|
||||||
|
cgroupns_mode: host
|
||||||
|
volumes:
|
||||||
|
- /sys/fs/cgroup:/sys/fs/cgroup:rw
|
||||||
|
tmpfs:
|
||||||
|
- /run
|
||||||
|
- /run/lock
|
||||||
|
capabilities:
|
||||||
|
- NET_ADMIN
|
||||||
|
security_opts:
|
||||||
|
- apparmor=unconfined
|
||||||
provisioner:
|
provisioner:
|
||||||
name: ansible
|
name: ansible
|
||||||
options:
|
options:
|
||||||
@@ -36,13 +53,16 @@ verifier:
|
|||||||
scenario:
|
scenario:
|
||||||
# molecule's default sequence minus both destroys: scripts/run_molecule_scenarios.sh removes the
|
# molecule's default sequence minus both destroys: scripts/run_molecule_scenarios.sh removes the
|
||||||
# container as soon as this scenario ends. After a local run, run `molecule destroy` yourself.
|
# container as soon as this scenario ends. After a local run, run `molecule destroy` yourself.
|
||||||
|
# A check runs before the converge (fresh host) and after it (configured host).
|
||||||
test_sequence:
|
test_sequence:
|
||||||
- dependency
|
- dependency
|
||||||
- cleanup
|
- cleanup
|
||||||
- syntax
|
- syntax
|
||||||
- create
|
- create
|
||||||
- prepare
|
- prepare
|
||||||
|
- check
|
||||||
- converge
|
- converge
|
||||||
|
- check
|
||||||
- idempotence
|
- idempotence
|
||||||
- side_effect
|
- side_effect
|
||||||
- verify
|
- verify
|
||||||
|
|||||||
@@ -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:
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ Disables and masks risky services, writes a systemd manager hardening drop-in an
|
|||||||
|
|
||||||
## Supported platforms
|
## Supported platforms
|
||||||
|
|
||||||
The molecule scenario passes on Ubuntu 24.04 (noble); see [Tests](#tests). The role is meant for hosts with systemd: Ubuntu 24.04 (noble) LXCs, Ubuntu VMs and Debian 13 (trixie) Proxmox hosts. The role is applied to the three system types in `systemd_hardening_profiles`: `pve` (Proxmox hosts), `ubuntu_lxc` and `ubuntu_vm`.
|
Ubuntu 24.04 (noble) and 26.04 (resolute), the platforms the molecule scenario runs on; see [Tests](#tests). The role is meant for hosts with systemd: Ubuntu LXCs, Ubuntu VMs and Debian 13 (trixie) Proxmox hosts. The role is applied to the three system types in `systemd_hardening_profiles`: `pve` (Proxmox hosts), `ubuntu_lxc` and `ubuntu_vm`.
|
||||||
|
|
||||||
Untested platforms: Debian 13 (trixie), and Ubuntu 22.04 (jammy), which is listed in `meta/main.yml` but neither supported nor tested.
|
Untested platforms: Debian 13 (trixie), listed in `meta/main.yml` but not verified by a test.
|
||||||
|
|
||||||
## Requirements and run order
|
## Requirements and run order
|
||||||
|
|
||||||
@@ -52,11 +52,12 @@ Only `always` (the `systemd_hardening_system_type` assert) works as intended. `d
|
|||||||
|
|
||||||
## Tests
|
## Tests
|
||||||
|
|
||||||
`molecule/default` runs in CI only, on one platform: Ubuntu 24.04 (noble), the `molecule-ubuntu2404` image (`${MOLECULE_IMAGE}`). It runs the `ubuntu_lxc` profile against stub unit files (a socket and a service for the ones that ship both, a service only and a socket only for the others), because the test image installs none of the services the role disables or masks. It checks that the stub sockets and services end up stopped and disabled or masked, that a listed unit that does not exist is skipped, the manager and service drop-ins (loaded by systemd after the reload) and the refusals: a missing or unknown `systemd_hardening_system_type`, and a `systemd_hardening_services` entry or value that is not a mapping. It cannot show that a real `rpcbind` or similar stops. The `pve` and `ubuntu_vm` profiles and Debian 13 are not verified by a test.
|
`molecule/default` runs in CI only, on two platforms: `${MOLECULE_IMAGE}` (Ubuntu 24.04) and `${MOLECULE_IMAGE_2604}` (Ubuntu 26.04). It runs the `ubuntu_lxc` profile against stub unit files (a socket and a service for the ones that ship both, a service only and a socket only for the others), because the test images install none of the services the role disables or masks. It checks that the stub sockets and services end up stopped and disabled or masked, that a listed unit that does not exist is skipped, the manager and service drop-ins (loaded by systemd after the reload) and the refusals: a missing or unknown `systemd_hardening_system_type`, and a `systemd_hardening_services` entry or value that is not a mapping. It runs `check` before the converge (fresh host) and after it (configured host). It cannot show that a real `rpcbind` or similar stops. The `pve` and `ubuntu_vm` profiles and Debian 13 are not verified by a test.
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
- Idempotent: yes.
|
- Idempotent: yes.
|
||||||
|
- Check mode: `--check` is the supported preview; a play-level `check_mode: true` is not supported.
|
||||||
- Every name in `systemd_hardening_disable_services` and `systemd_hardening_mask_services` is looked up as a socket and as a service, with or without the `.service` or `.socket` suffix. Only units that systemd has a unit file for (`LoadState` is not `not-found`) are disabled or masked, the socket first: a stopped service whose socket still listens is started again by the next connection. A name with only a service, only a socket, or neither is fine. The role asks about the listed units only, with one `systemctl show`, and does not list every unit file. A template name such as `[email protected]` is not supported: that call fails.
|
- Every name in `systemd_hardening_disable_services` and `systemd_hardening_mask_services` is looked up as a socket and as a service, with or without the `.service` or `.socket` suffix. Only units that systemd has a unit file for (`LoadState` is not `not-found`) are disabled or masked, the socket first: a stopped service whose socket still listens is started again by the next connection. A name with only a service, only a socket, or neither is fine. The role asks about the listed units only, with one `systemctl show`, and does not list every unit file. A template name such as `[email protected]` is not supported: that call fails.
|
||||||
- `systemctl disable` does nothing for a static unit (one with no `[Install]` section), so the systemd module can report `changed` on every run for it; list only names whose units can be enabled, and note that this now applies to a listed name's socket as well.
|
- `systemctl disable` does nothing for a static unit (one with no `[Install]` section), so the systemd module can report `changed` on every run for it; list only names whose units can be enabled, and note that this now applies to a listed name's socket as well.
|
||||||
- The manager drop-in (`DefaultLimitNOFILE`, `DefaultLimitNPROC`, `DefaultLimitCORE`, and task, memory and CPU accounting) is written verbatim by `tasks/harden_manager.yml` and has no variable.
|
- The manager drop-in (`DefaultLimitNOFILE`, `DefaultLimitNPROC`, `DefaultLimitCORE`, and task, memory and CPU accounting) is written verbatim by `tasks/harden_manager.yml` and has no variable.
|
||||||
|
|||||||
Loaded 100 of 138 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user