Compare commits
136
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a185a301db | ||
|
|
c7c38c6bc0 | ||
|
|
b3b62121a3 | ||
|
|
b7bac07757 | ||
|
|
30a8e71f97 | ||
|
|
985995656a | ||
|
|
5ac8eadac1 | ||
|
|
1ab99405ea | ||
|
|
5fa17e036c | ||
|
|
dab3bd2d44 | ||
|
|
1be02c574b | ||
|
|
084d2d592f | ||
|
|
90f27812eb | ||
|
|
a5c1426b25 | ||
|
|
4c1cba6e35 | ||
|
|
008039c60c | ||
|
|
6364445e3c | ||
|
|
30352502dd | ||
|
|
9ae5eca2a3 | ||
|
|
b3037273b7 | ||
|
|
34990718f0 | ||
|
|
47540320b6 | ||
|
|
afd62a8cbb | ||
|
|
810a74d8e5 | ||
|
|
87738f65fd | ||
|
|
48e6dcb543 | ||
|
|
7df98ea8c7 | ||
|
|
4a6db3382c | ||
|
|
5e230201e6 | ||
|
|
114a21fc0f | ||
|
|
c33da78633 | ||
|
|
7dbf9a1bd0 | ||
|
|
6c031acc26 | ||
|
|
380d52cd13 | ||
|
|
ab0ce421cc | ||
|
|
7d11d23294 | ||
|
|
0973f39831 | ||
|
|
2e70980b44 | ||
|
|
6eca2f4031 | ||
|
|
16b1aa4136 | ||
|
|
1048628cc4 | ||
|
|
0eade70b56 | ||
|
|
e4eb3bc656 | ||
|
|
15c3731e7f | ||
|
|
04259751ad | ||
|
|
699179674f | ||
|
|
bf604a1af2 | ||
|
|
3d2fab5388 | ||
|
|
042051b3e5 | ||
|
|
6e3ea4521b | ||
|
|
7433a37697 | ||
|
|
0b8c45a19c | ||
|
|
2d4d44b871 | ||
|
|
d862097b9c | ||
|
|
6670ab664f | ||
|
|
1372c257c2 | ||
|
|
18475ea0a5 | ||
|
|
e2df672be7 | ||
|
|
2e92b11cbc | ||
|
|
7311a27e43 | ||
|
|
19449f7e93 | ||
|
|
84ad29b18b | ||
|
|
6d505c0db7 | ||
|
|
3bf9ae0efe | ||
|
|
fbc8b1b6d7 | ||
|
|
7c068c2b47 | ||
|
|
c51fa998b9 | ||
|
|
2eb7da3563 | ||
|
|
3a5040aae8 | ||
|
|
6a2060bd31 | ||
|
|
11fec7c8fc | ||
|
|
40e3b39990 | ||
|
|
e1a46fcdb1 | ||
|
|
5519733312 | ||
|
|
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 | ||
|
|
cda8677256 | ||
|
|
84ea8213e7 | ||
|
|
7f05d067c8 | ||
|
|
02d6f9a83e | ||
|
|
875e97ff3e | ||
|
|
0e15b3457e | ||
|
|
7d1f6df3d6 | ||
|
|
318229bdb3 | ||
|
|
ee129a2982 | ||
|
|
35cedf5163 | ||
|
|
a6b8bc150d | ||
|
|
bb0bf78964 | ||
|
|
5f936962e0 | ||
|
|
dc7d3bdfd9 | ||
|
|
6f73021d3f | ||
|
|
9d365f14ae | ||
|
|
44cd287d41 | ||
|
|
8def6cf274 | ||
|
|
da76e995b6 | ||
|
|
0d0fc3d1ec | ||
|
|
87b87dbcef | ||
|
|
efd3a550c5 | ||
|
|
5364f18728 | ||
|
|
62ffae7764 | ||
|
|
1f27f02f13 | ||
|
|
df06260b27 | ||
|
|
2e1ad033e4 |
No files matched your search
+5
-4
@@ -24,7 +24,8 @@ exclude_paths:
|
||||
supported_ansible_also:
|
||||
- "2.22."
|
||||
|
||||
skip_list:
|
||||
# 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).
|
||||
- role-name
|
||||
# complexity runs at the default max_tasks (100) until the schema accepts the key (#139). An empty
|
||||
# warn_list makes experimental rules (complexity), jinja[spacing] and fqcn[deep] fail Lint.
|
||||
enable_list:
|
||||
- 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/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]
|
||||
# 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
|
||||
@@ -0,0 +1,13 @@
|
||||
---
|
||||
# Merged under every scenario's molecule.yml. prerun off: the CI wrapper puts this checkout
|
||||
# first on ANSIBLE_COLLECTIONS_PATH, so molecule's per-scenario install is unused.
|
||||
prerun: false
|
||||
provisioner:
|
||||
config_options:
|
||||
connection:
|
||||
# Pipe each module over stdin: without it every task pays extra docker exec and docker cp
|
||||
# calls to make a temp dir, copy the module in and clean up.
|
||||
pipelining: true
|
||||
defaults:
|
||||
# Gather each host's facts once per playbook run, not in every play.
|
||||
gathering: smart
|
||||
@@ -57,6 +57,14 @@ issue.
|
||||
`.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.
|
||||
*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
|
||||
`v*` tags, where it checks the tag against `galaxy.yml`. *Why:* the tag is what consumers
|
||||
install. *Held:* review.
|
||||
@@ -72,14 +80,18 @@ issue.
|
||||
- **What a pull request runs is chosen by `scripts/select_molecule_scenarios.py`:** the scenarios
|
||||
of the roles it changes and of the roles that use them (any file naming
|
||||
`mortis.kamino.<role>`, transitively), none for a diff of only IGNORED paths, a failure for a
|
||||
changed role with no scenario, and every scenario for any other file. *Why:* a full run takes
|
||||
changed role with no scenario, for a `.gitea/workflows/molecule.yml` diff of only comments
|
||||
(outside `run:` scripts) or image pins the scenarios that name a changed `MOLECULE_IMAGE*` pin
|
||||
(every scenario for `CI_IMAGE`, or when a shared molecule file names the pin), and every
|
||||
scenario for any other file. *Why:* a full run takes
|
||||
the single runner slot for a long time. *Held:* control: the selector and its tests.
|
||||
- **A role named in an include, import, play `roles:` entry or meta dependency is written out in
|
||||
full**, never bare or templated. *Why:* the selector finds dependent roles by their FQCN.
|
||||
*Held:* control: a selector test fails a bare or templated name.
|
||||
- **Scenarios load `mortis.kamino` from the checkout, never from molecule's installed copy, so
|
||||
`galaxy.yml` is on IGNORED.** *Why:* molecule installs the collection from `galaxy.yml` into
|
||||
each scenario's `ANSIBLE_HOME`, which is not on `ANSIBLE_COLLECTIONS_PATH`, so its changes
|
||||
- **Scenarios load `mortis.kamino` from the checkout, never from an installed copy, so
|
||||
`galaxy.yml` is on IGNORED.** *Why:* the checkout is first on `ANSIBLE_COLLECTIONS_PATH` and the
|
||||
shared base config `.config/molecule/config.yml` turns off molecule's install of the collection
|
||||
(`prerun: false`), so changes to `galaxy.yml`
|
||||
(release versions, `build_ignore`) do not change what a scenario runs, and the Build check
|
||||
proves the collection builds; they had caused about a third of full pull request runs and their
|
||||
minutes (#338). *Held:* control: `scripts/check_scenarios_load_checkout.py`, which
|
||||
@@ -110,14 +122,16 @@ issue.
|
||||
*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`.
|
||||
- **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
|
||||
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
|
||||
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`
|
||||
fails a `destroy` in a sequence, a platform name that is not unique or not per run, a missing
|
||||
label, and a workflow that does not filter by it.
|
||||
fails a `destroy` in a sequence, a role scenario's `converge` without a `check` on each side, a
|
||||
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
|
||||
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
|
||||
|
||||
@@ -28,7 +28,7 @@ jobs:
|
||||
timeout-minutes: 30
|
||||
# The ci image (images/ci, built by image.yml): tag for the release, digest enforced.
|
||||
container:
|
||||
image: git.rkdr.net/mortis/ci:0.2.43@sha256:373c3ba69e3cdccdf6acf96d9c1cbfa173d2db0fbda441f4256eb46bd3ce6b99
|
||||
image: git.rkdr.net/mortis/ci:0.2.48@sha256:d1c6653255abf366462c0265d9372626d5b59095084fe74ae95b9ebe7414007d
|
||||
env:
|
||||
PIP_DISABLE_PIP_VERSION_CHECK: "1"
|
||||
steps:
|
||||
@@ -60,6 +60,11 @@ jobs:
|
||||
run: |
|
||||
if sha256sum --quiet -c /opt/ci-pins.sha256; then
|
||||
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
|
||||
echo "::warning::requirements-dev.txt, requirements-dev.lock, requirements.yml," \
|
||||
"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
|
||||
# release, digest enforced. Only its /opt/venv Python (with PyYAML) is used here.
|
||||
container:
|
||||
image: git.rkdr.net/mortis/ci:0.2.43@sha256:373c3ba69e3cdccdf6acf96d9c1cbfa173d2db0fbda441f4256eb46bd3ce6b99
|
||||
image: git.rkdr.net/mortis/ci:0.2.48@sha256:d1c6653255abf366462c0265d9372626d5b59095084fe74ae95b9ebe7414007d
|
||||
steps:
|
||||
# The container has no Node, so JavaScript actions such as actions/checkout
|
||||
# cannot run; clone with git and the job token.
|
||||
|
||||
@@ -62,7 +62,6 @@ jobs:
|
||||
github.event_name != 'pull_request' &&
|
||||
github.ref == 'refs/heads/main'
|
||||
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
|
||||
# may share it with one other job (Lint, Build or Molecule). An empty subpath means the
|
||||
# repository root is the build context.
|
||||
@@ -80,7 +79,7 @@ jobs:
|
||||
base: "0.1"
|
||||
subpath: images/molecule-ubuntu2404
|
||||
dockerfile: Dockerfile
|
||||
job_image: ubuntu:24.04@sha256:9c7f200c07e3d4a03e7249d2c16bf66a51120fb876aa2242cf31451412543289
|
||||
job_image: ubuntu:24.04@sha256:562111b88caa79c71391c0c4d3c2114a7d5c35915c20561fd893cb1e07929e6b
|
||||
- name: molecule-ubuntu2604
|
||||
base: "0.1"
|
||||
subpath: images/molecule-ubuntu2604
|
||||
|
||||
@@ -31,7 +31,7 @@ jobs:
|
||||
# The tag says which release, the digest is what is enforced (bump both together
|
||||
# when image.yml publishes a new version).
|
||||
container:
|
||||
image: git.rkdr.net/mortis/ci:0.2.43@sha256:373c3ba69e3cdccdf6acf96d9c1cbfa173d2db0fbda441f4256eb46bd3ce6b99
|
||||
image: git.rkdr.net/mortis/ci:0.2.48@sha256:d1c6653255abf366462c0265d9372626d5b59095084fe74ae95b9ebe7414007d
|
||||
env:
|
||||
PIP_DISABLE_PIP_VERSION_CHECK: "1"
|
||||
PRE_COMMIT_HOME: /opt/pre-commit
|
||||
@@ -59,6 +59,11 @@ jobs:
|
||||
run: |
|
||||
if sha256sum --quiet -c /opt/ci-pins.sha256; then
|
||||
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
|
||||
echo "::warning::requirements-dev.txt, requirements-dev.lock, requirements.yml," \
|
||||
"extensions/molecule/requirements.yml or .pre-commit-config.yaml differ from the ci image;" \
|
||||
@@ -108,8 +113,10 @@ jobs:
|
||||
fi
|
||||
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
|
||||
run: |
|
||||
unset PIP_NO_INDEX http_proxy https_proxy HTTP_PROXY HTTPS_PROXY
|
||||
export PATH="/opt/venv/bin:$PATH"
|
||||
python3 -m unittest discover -s tests/scripts
|
||||
|
||||
|
||||
@@ -47,22 +47,21 @@ jobs:
|
||||
(github.event_name != 'pull_request' ||
|
||||
github.event.pull_request.head.repo.full_name == github.repository)
|
||||
runs-on: [kamino-molecule]
|
||||
# Two full runs sharing the runner (a nightly run and a dispatch) take more than 30 minutes.
|
||||
# Also the age past which the sweep step removes a run's containers; a script test holds the
|
||||
# two equal.
|
||||
timeout-minutes: 45
|
||||
# A full run under load takes about 45 minutes (PR #405: 44m53s), so 45 left no margin. Also the
|
||||
# age past which the sweep step removes a run's containers; a script test holds the two equal.
|
||||
timeout-minutes: 90
|
||||
env:
|
||||
# The tools and collections molecule runs with: the image Lint and Build use.
|
||||
CI_IMAGE: >-
|
||||
git.rkdr.net/mortis/ci:0.2.43@sha256:373c3ba69e3cdccdf6acf96d9c1cbfa173d2db0fbda441f4256eb46bd3ce6b99
|
||||
git.rkdr.net/mortis/ci:0.2.48@sha256:d1c6653255abf366462c0265d9372626d5b59095084fe74ae95b9ebe7414007d
|
||||
# Used by the scenarios as `image: ${MOLECULE_IMAGE}`; set it the same way to run
|
||||
# one locally.
|
||||
MOLECULE_IMAGE: >-
|
||||
git.rkdr.net/mortis/molecule-ubuntu2404:0.1.10@sha256:7cdb45688667ade43a8026bdc725489a557fde7ce893123c4ee6b8d125c3fec6
|
||||
git.rkdr.net/mortis/molecule-ubuntu2404:0.1.11@sha256:e7389be9c397ec50fcf7d433c99cb9da7b16b149384aaa543e3c21a3ada1a4e1
|
||||
# The same for Ubuntu 26.04, the release the hosts are moving to; used by
|
||||
# `image: ${MOLECULE_IMAGE_2604}` in extensions/molecule/image-smoke-2604.
|
||||
MOLECULE_IMAGE_2604: >-
|
||||
git.rkdr.net/mortis/molecule-ubuntu2604:0.1.6@sha256:d7c216b33d18fa8f1ecbfee8795eb4adc867fe5ad8e7a73b7c67effe301cf771
|
||||
git.rkdr.net/mortis/molecule-ubuntu2604:0.1.7@sha256:86ee99fe77ab4c9af3911570ae7238ce525375cfaf923e9656860606c47488df
|
||||
# Names and labels this run's containers: the scenarios' as `${KAMINO_RUN_ID:-local}-<name>`
|
||||
# with the label net.rkdr.mortis.molecule-run, and the one molecule runs in.
|
||||
KAMINO_RUN_ID: ${{ github.run_id }}-${{ github.run_attempt }}
|
||||
@@ -98,7 +97,7 @@ jobs:
|
||||
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
|
||||
# live run's containers.
|
||||
cutoff="$(date -d '45 minutes ago' +%s)"
|
||||
cutoff="$(date -d '90 minutes ago' +%s)"
|
||||
old=""
|
||||
for id in $ids; do
|
||||
# a container removed since the listing, by its run or another run's sweep, is skipped
|
||||
|
||||
@@ -4,6 +4,68 @@ mortis.kamino Release Notes
|
||||
|
||||
.. contents:: Topics
|
||||
|
||||
v3.2.0
|
||||
======
|
||||
|
||||
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.
|
||||
- docker, system_baseline - The install tasks that only use the distribution's sources (docker's prerequisites, system_baseline's packages) refresh the APT cache only when it is older than an hour; before, every run refreshed it. Installs from a role's own APT source still refresh it on every run.
|
||||
- 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.
|
||||
- system_baseline - Add the input ``system_baseline_skip_upgrade_during_vzdump`` (default ``false``). With ``true`` on the ``pve`` system type, the main flow and the ``update`` entry point skip the apt upgrade while ``pvesh get /nodes/localhost/tasks --source active`` lists a ``vzdump`` task, and say so. With the default no ``pvesh`` command runs and the upgrade is unchanged.
|
||||
- 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 or a size journald reads, a number with an optional upper-case ``B``, ``K``, ``M``, ``G``, ``T``, ``P`` or ``E``. A value journald rejects, which the role used to write into the drop-in as it was and journald then ignored (``infinity``, a lower-case unit, a line break), now stops the run; an empty value used to write an empty ``SystemMaxUse=``.
|
||||
- traefik - New input ``traefik_release_url`` sets where the release archive and checksums are downloaded from, for a mirror (default: the GitHub releases, as before).
|
||||
|
||||
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.
|
||||
|
||||
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
|
||||
======
|
||||
|
||||
Minor Changes
|
||||
-------------
|
||||
|
||||
- galaxy.yml - Declare ``community.proxmox`` (>=2.1.0) as a dependency, needed by ``pve_lxc``. Its modules need the Python library ``proxmoxer`` 2.3 or later on the controller.
|
||||
- pve_lxc - New role. Creates, updates, grows the root disk of, starts, stops and (with ``pve_lxc_allow_destroy``) deletes a Proxmox VE LXC container through the Proxmox API (``community.proxmox``), reconciles the raw ``lxc.*`` lines of its config on the node and, opt-in, writes its guest firewall file. Declares Debian trixie, untested; the molecule scenario covers the node-side files and the input validation, not the API lifecycle.
|
||||
|
||||
v2.1.0
|
||||
======
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
An Ansible Collection of reusable, hardened roles for a self-hosted home lab:
|
||||
`cloudflared`, `docker`, `fail2ban`, `gitea`, `gitea_runner`, `network_interfaces`,
|
||||
`pihole`, `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).
|
||||
|
||||
Status: roles arrive in waves. Release 2.1.0 holds the `cloudflared`, `docker`, `fail2ban`, `gitea`, `gitea_runner`, `network_interfaces`, `pihole`, `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.2.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
|
||||
|
||||
@@ -17,11 +17,13 @@ name (FQCN) only, `mortis.kamino.<role>`:
|
||||
collections:
|
||||
- name: https://git.rkdr.net/mortis/kamino.git
|
||||
type: git
|
||||
version: v2.1.0
|
||||
version: v3.2.0
|
||||
```
|
||||
|
||||
Its dependencies (`community.general`, `ansible.posix`) are declared in `galaxy.yml`, so
|
||||
`ansible-galaxy` installs them unless the same file already pins a satisfying version.
|
||||
Its dependencies (`community.general`, `ansible.posix`, `community.proxmox`) are declared in `galaxy.yml`, so
|
||||
`ansible-galaxy` installs them unless the same file already pins a satisfying version. The modules of
|
||||
`community.proxmox` also need the Python library `proxmoxer` 2.3 or later on the controller
|
||||
(`pip install 'proxmoxer>=2.3'`); `galaxy.yml` cannot declare a Python dependency.
|
||||
|
||||
```yaml
|
||||
- ansible.builtin.include_role:
|
||||
@@ -39,7 +41,7 @@ when its own prerequisites (tests, a safe cutover wherever the role already runs
|
||||
|
||||
Still to come:
|
||||
|
||||
- Wave 2: `pve_vm`, `pve_lxc`, `tailscale`.
|
||||
- Wave 2: `pve_vm`.
|
||||
- Wave 3: `rke2`, `proxmox_host`.
|
||||
- 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.
|
||||
- **Trigger:** a token that can push here but cannot reach the secrets.
|
||||
- **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.
|
||||
@@ -35,6 +35,10 @@ objects:
|
||||
description: Install and configure Pi-hole from the upstream repository
|
||||
name: pihole
|
||||
version_added: null
|
||||
pve_lxc:
|
||||
description: Manage a Proxmox LXC container
|
||||
name: pve_lxc
|
||||
version_added: null
|
||||
sshd:
|
||||
description: Write a hardened sshd drop-in
|
||||
name: sshd
|
||||
@@ -47,6 +51,10 @@ objects:
|
||||
description: Harden systemd for a system type
|
||||
name: systemd_hardening
|
||||
version_added: null
|
||||
tailscale:
|
||||
description: Install Tailscale and bring the node up
|
||||
name: tailscale
|
||||
version_added: null
|
||||
traefik:
|
||||
description: Install, configure, update or remove Traefik as a systemd binary
|
||||
name: traefik
|
||||
@@ -65,6 +73,8 @@ plugins:
|
||||
callback: {}
|
||||
cliconf: {}
|
||||
connection: {}
|
||||
eda_event_filter: {}
|
||||
eda_event_source: {}
|
||||
filter: {}
|
||||
httpapi: {}
|
||||
inventory: {}
|
||||
@@ -75,4 +85,4 @@ plugins:
|
||||
strategy: {}
|
||||
test: {}
|
||||
vars: {}
|
||||
version: 2.1.0
|
||||
version: 3.2.0
|
||||
@@ -414,3 +414,121 @@ releases:
|
||||
- pihole-role.yml
|
||||
- system-baseline-apt-tmpdir.yml
|
||||
release_date: '2026-11-25'
|
||||
2.2.0:
|
||||
changes:
|
||||
minor_changes:
|
||||
- galaxy.yml - Declare ``community.proxmox`` (>=2.1.0) as a dependency, needed
|
||||
by ``pve_lxc``. Its modules need the Python library ``proxmoxer`` 2.3 or later
|
||||
on the controller.
|
||||
- pve_lxc - New role. Creates, updates, grows the root disk of, starts, stops
|
||||
and (with ``pve_lxc_allow_destroy``) deletes a Proxmox VE LXC container through
|
||||
the Proxmox API (``community.proxmox``), reconciles the raw ``lxc.*`` lines
|
||||
of its config on the node and, opt-in, writes its guest firewall file. Declares
|
||||
Debian trixie, untested; the molecule scenario covers the node-side files
|
||||
and the input validation, not the API lifecycle.
|
||||
fragments:
|
||||
- 386-community-proxmox-dependency.yml
|
||||
- pve-lxc-role.yml
|
||||
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'
|
||||
3.2.0:
|
||||
changes:
|
||||
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.
|
||||
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.
|
||||
- docker, system_baseline - The install tasks that only use the distribution's
|
||||
sources (docker's prerequisites, system_baseline's packages) refresh the APT
|
||||
cache only when it is older than an hour; before, every run refreshed it.
|
||||
Installs from a role's own APT source still refresh it on every run.
|
||||
- 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.
|
||||
- system_baseline - Add the input ``system_baseline_skip_upgrade_during_vzdump``
|
||||
(default ``false``). With ``true`` on the ``pve`` system type, the main flow
|
||||
and the ``update`` entry point skip the apt upgrade while ``pvesh get /nodes/localhost/tasks
|
||||
--source active`` lists a ``vzdump`` task, and say so. With the default no
|
||||
``pvesh`` command runs and the upgrade is unchanged.
|
||||
- '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 or a size journald reads, a number with an optional
|
||||
upper-case ``B``, ``K``, ``M``, ``G``, ``T``, ``P`` or ``E``. A value journald
|
||||
rejects, which the role used to write into the drop-in as it was and journald
|
||||
then ignored (``infinity``, a lower-case unit, a line break), now stops the
|
||||
run; an empty value used to write an empty ``SystemMaxUse=``.'
|
||||
- 'traefik - New input ``traefik_release_url`` sets where the release archive
|
||||
and checksums are downloaded from, for a mirror (default: the GitHub releases,
|
||||
as before).'
|
||||
fragments:
|
||||
- 364-ansible-facts.yml
|
||||
- 399-extra-packages.yml
|
||||
- 400-skip-upgrade-during-vzdump.yml
|
||||
- 401-journal-max-use-empty.yml
|
||||
- apt-cache-valid-time.yml
|
||||
- cloudflared-tunnel-lookup-delay.yml
|
||||
- refusals-in-verify.yml
|
||||
- traefik-release-url.yml
|
||||
release_date: '2026-11-27'
|
||||
@@ -0,0 +1,6 @@
|
||||
---
|
||||
minor_changes:
|
||||
- >-
|
||||
docker - New input ``docker_keyring_checksum``: the Docker APT key is verified against a pinned
|
||||
sha256, and a changed key fails the install until a person has checked it and updated the hash.
|
||||
Set ``docker_keyring_checksum`` too when ``docker_gpg_url`` is overridden.
|
||||
@@ -0,0 +1,50 @@
|
||||
# 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).
|
||||
Molecule's controller image is added by [ADR 0003](0003-molecule-controller-image.md).
|
||||
- **The molecule images bake in everything except what a role installs itself.** The test
|
||||
fixtures a scenario's `prepare.yml` needs are baked in. Packages a role installs are still
|
||||
downloaded, because that install path is what the test exercises. A converge is not kept off
|
||||
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.
|
||||
@@ -0,0 +1,60 @@
|
||||
# 0003. Molecule runs in its own controller image, not the `ci` image
|
||||
|
||||
Status: accepted
|
||||
|
||||
## Context
|
||||
|
||||
[ADR 0002](0002-self-built-ci-and-molecule-images.md) built one `ci` image that bakes every CI
|
||||
tool, and Lint, Build and Molecule all pin it. A change to a tool only Lint uses (apm-cli,
|
||||
antsibull-changelog, a pre-commit hook environment) publishes a new `ci` version, and its pin
|
||||
pull request moves `CI_IMAGE` in `molecule.yml`. The scenario selector cannot tell what changed
|
||||
inside an image, so it runs every scenario. 9 of 18 `ci` pin pull requests over two weeks
|
||||
were Lint-only. Images are built only on push to `main`, so a bump and its pin never share a pull
|
||||
request.
|
||||
|
||||
## Decision
|
||||
|
||||
- **Molecule runs in a `molecule-controller` image**, separate from `ci`. It bakes only what
|
||||
Molecule needs: ansible-core, molecule, molecule-plugins, the Python packages of the Docker
|
||||
connection, and the collections of `requirements.yml` and
|
||||
`extensions/molecule/requirements.yml`.
|
||||
- **Its Python packages come from a requirements file and hash-pinned lock of its own.**
|
||||
- **`molecule.yml` pins it instead of `ci`**; Lint and Build keep `ci`.
|
||||
- **It follows ADR 0002 otherwise:** built by `image.yml`, versioned by CI, pinned by
|
||||
`<version>@sha256:<digest>`, moved by Renovate. This adds to ADR 0002's set of images; the
|
||||
rest of ADR 0002 stands.
|
||||
|
||||
## Reason
|
||||
|
||||
A `ci` pin pull request then touches only paths the selector ignores and runs no scenario. A
|
||||
`molecule-controller` pin pull request still runs every scenario, which is right: it changes
|
||||
Molecule's tools.
|
||||
|
||||
The cost: one more image and lock to maintain, its layers to estimate against the 100 MB limit,
|
||||
a hand-made first pin, and ansible-core pinned in two locks that must stay equal. A collection
|
||||
bump is an input of both images, so it publishes two versions and two pin pull requests.
|
||||
|
||||
The controller's requirements file and lock must not be on the selector's IGNORED list, so a
|
||||
bump of ansible-core or molecule there runs every scenario before it merges. Today
|
||||
`requirements-dev.txt` and `requirements-dev.lock` are on IGNORED, so such a bump selects no
|
||||
scenario unless it edits `meta/runtime.yml`; this decision does not change that list.
|
||||
|
||||
The implementation updates: `image.yml` (matrix, and its push `paths` unless the new files live
|
||||
under `images/`), `molecule.yml`,
|
||||
`scripts/run_molecule_in_ci_image.sh` (its pin comparison reads the `ci` image's checksums),
|
||||
`scripts/check_image_versions.py`, `scripts/check_bot_pr_diff.py` and
|
||||
`scripts/lock-requirements.sh` (they know only `requirements-dev.lock`), their tests, the
|
||||
`pip-compile` patterns in `renovate.json`, `images/AGENTS.md` (the consumer list, and "each
|
||||
molecule image is one Ubuntu release"), the Molecule rules in `.gitea/workflows/AGENTS.md`,
|
||||
`docs/images/` (a new page, and `ci.md`, which names Molecule as a consumer), the `ci`
|
||||
Dockerfile's description label, `docs/contributing/setup.md` if the clone's tools change, and the
|
||||
[Accepted risks](../../SECURITY.md#accepted-risks) entry "Pin bumps first behaviour-tested after
|
||||
they merge", which counts on the `ci` pin pull request running every scenario.
|
||||
|
||||
## Not done
|
||||
|
||||
- **The selector classifies the packages a lock change moves, to decide whether a `CI_IMAGE`
|
||||
bump matters:** a heuristic package list inside a script that judges pull requests.
|
||||
- **Status quo:** every Lint-only tool change keeps costing a full Molecule run.
|
||||
- **Grouping pin pull requests only:** adopted separately; it lowers the number of full runs
|
||||
but not the cause.
|
||||
@@ -15,10 +15,23 @@ trailers, are in [ai-assistance.md](ai-assistance.md).
|
||||
*Reason:* every change reaches `main` through the Lint and Build checks and a reviewer.
|
||||
*Held by:* control: branch protection on `main`.
|
||||
- **Do not push to someone else's branch or to a bot's branch; put your change in a pull request of
|
||||
your own.** Updating a branch from `main` with Gitea's update button is allowed.
|
||||
your own.** Updating a branch from `main` with Gitea's update button is allowed under the next
|
||||
two rules.
|
||||
*Reason:* a push changes a head its author already reviewed or scheduled to merge, and a hand-made
|
||||
commit on a `renovate/` branch makes Renovate stop rebasing it.
|
||||
*Held by:* aspirational.
|
||||
- **Update a pull request's branch from `main` only when it is next to merge: reviewed, green on its
|
||||
previous head, and the only branch being updated. After updating your own pull request, give it a
|
||||
scheduled merge; merge anyone else's as [reviewing.md](reviewing.md) says.**
|
||||
*Reason:* `main` blocks an outdated branch, so every update re-runs Lint, Build and Molecule, and
|
||||
a new head cancels the run in progress; an update made while another pull request merges first is
|
||||
wasted.
|
||||
*Held by:* aspirational.
|
||||
- **Never press the update button on a `renovate/` branch. When a Renovate pull request is next to
|
||||
merge and behind `main`, tick the rebase/retry checkbox in its description; Renovate rebases it at
|
||||
its next run.**
|
||||
*Reason:* the update button adds a hand-made commit, and Renovate stops rebasing that branch.
|
||||
*Held by:* aspirational.
|
||||
- **File an issue or open a pull request with the headings of the matching template in `.gitea/`,
|
||||
also when you file through the API, `tea` or an MCP server.**
|
||||
*Reason:* those routes skip the templates, and an agent's built-in body leaves out what review needs.
|
||||
|
||||
+5
-3
@@ -9,9 +9,10 @@ Ubuntu 26.04 with:
|
||||
|
||||
- **Python tools** in `/opt/venv` (on `PATH`; it runs on Python 3.14, the version of `.python-version`, from the baked copy and not from the distribution's `python3`), from `requirements-dev.lock` (the hashed lock of `requirements-dev.txt`, installed with `pip install --require-hashes`): `ansible-core`,
|
||||
`ansible-lint`, `pre-commit`, `antsibull-changelog`, `galaxy-importer`, `reuse`, `molecule` and
|
||||
`molecule-plugins[docker]` (the Docker driver, with the `docker` Python SDK).
|
||||
`molecule-plugins[docker]` (the Docker driver, with the `docker` Python SDK), and `proxmoxer`, the controller-side
|
||||
library the modules of `community.proxmox` import.
|
||||
- **The collections the roles call** in `/opt/collections` (`ANSIBLE_COLLECTIONS_PATH` is set to it), from
|
||||
`requirements.yml`: `community.general` and `ansible.posix` at the exact versions CI tests against, so
|
||||
`requirements.yml`: `community.general`, `ansible.posix` and `community.proxmox` at the exact versions CI tests against, so
|
||||
`ansible-lint --offline` resolves their modules instead of mocking them; and from
|
||||
`extensions/molecule/requirements.yml`, `community.docker`, which the Molecule Docker driver's own playbooks call.
|
||||
- **Every pre-commit hook environment** of `.pre-commit-config.yaml` in `/opt/pre-commit`
|
||||
@@ -65,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
|
||||
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
|
||||
(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.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
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
|
||||
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
|
||||
|
||||
@@ -12,7 +12,9 @@ It is the release the hosts are moving to; the roles are tested on it next to 24
|
||||
`ca-certificates`.
|
||||
- Python for Ansible on the target: `python3`, `python3-apt`, `python3-systemd`.
|
||||
- The packages the roles manage, preinstalled so a converge makes no network calls:
|
||||
`iptables`, `ufw`, `fail2ban`, `openssh-server` (the `ssh` unit is enabled).
|
||||
`iptables`, `ufw`, `fail2ban`, `openssh-server` (the `ssh` unit is enabled), and `gnupg`
|
||||
(the docker scenario signs its stand-in APT repository with it).
|
||||
- root's `sudo` skips the PAM account check (`pam_rootok`), so `become` works in the container.
|
||||
- Throwaway SSH host keys and a machine-id generated at build time. They are not secrets and the
|
||||
image is a test target that must never be exposed to a network.
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
- ufw
|
||||
- fail2ban
|
||||
- openssh-server
|
||||
- gnupg
|
||||
|
||||
- name: Query the units a role scenario relies on
|
||||
ansible.builtin.systemd:
|
||||
@@ -56,3 +57,14 @@
|
||||
- name: NET_ADMIN is granted, so the firewall tools can work
|
||||
ansible.builtin.command: iptables -S
|
||||
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
|
||||
@@ -57,3 +57,14 @@
|
||||
- name: NET_ADMIN is granted, so the firewall tools can work
|
||||
ansible.builtin.command: iptables -S
|
||||
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.
|
||||
collections:
|
||||
- name: community.docker
|
||||
version: 5.4.0
|
||||
version: 5.4.1
|
||||
+8
-4
@@ -1,14 +1,14 @@
|
||||
---
|
||||
namespace: mortis
|
||||
name: kamino
|
||||
version: 2.1.0
|
||||
version: 3.2.0
|
||||
readme: README.md
|
||||
authors:
|
||||
- Defame1297
|
||||
description: >-
|
||||
Reusable, hardened Ansible roles for a self-hosted home lab (cloudflared, docker, fail2ban,
|
||||
gitea, gitea_runner, network_interfaces, pihole, sshd, system_baseline, systemd_hardening,
|
||||
traefik, ufw, user_management; _binary_update is internal).
|
||||
gitea, gitea_runner, network_interfaces, pihole, pve_lxc, sshd, system_baseline,
|
||||
systemd_hardening, tailscale, traefik, ufw, user_management; _binary_update is internal).
|
||||
license:
|
||||
- GPL-3.0-or-later
|
||||
tags:
|
||||
@@ -22,10 +22,13 @@ homepage: https://git.rkdr.net/mortis/kamino
|
||||
issues: https://git.rkdr.net/mortis/kamino/issues
|
||||
# CI tests the versions pinned in requirements.yml; the lower bounds here are not tested.
|
||||
# No upper bound, so a consumer's newer pin does not conflict. community.general is used by system_baseline and ufw,
|
||||
# ansible.posix by system_baseline and user_management.
|
||||
# ansible.posix by system_baseline and user_management, community.proxmox by pve_lxc (Proxmox VE guest lifecycle).
|
||||
# community.proxmox's modules import the Python library proxmoxer (2.3 or later) on the controller; galaxy.yml
|
||||
# cannot declare a Python dependency, so the README says it and requirements-dev.txt pins it for CI.
|
||||
dependencies:
|
||||
community.general: ">=14.0.0"
|
||||
ansible.posix: ">=2.2.0"
|
||||
community.proxmox: ">=2.1.0"
|
||||
build_ignore:
|
||||
# Repository tooling that is not part of the Collection. scripts/check_tarball.py fails
|
||||
# the build if anything outside its allowlist ends up in the archive, so a new top-level
|
||||
@@ -36,6 +39,7 @@ build_ignore:
|
||||
- apm_modules
|
||||
- .apm-local
|
||||
- .claude
|
||||
- .config
|
||||
- .gitea
|
||||
- .gitignore
|
||||
- .pre-commit-config.yaml
|
||||
|
||||
+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
|
||||
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
|
||||
the network-off check (#168) lands.
|
||||
file). *Why:* a run that downloads is slower and depends on the network. *Held:* control: on
|
||||
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
|
||||
it lives (a comment next to it). *Why:* machinery is kept only for a saving someone can check.
|
||||
*Held:* review.
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
# - OS packages: git, shellcheck (actionlint runs it over run: blocks), the
|
||||
# distribution's python3 and ca-certificates.
|
||||
# - /opt/venv: requirements-dev.lock, the hashed lock of requirements-dev.txt (ansible-core, ansible-lint, pre-commit,
|
||||
# antsibull-changelog, galaxy-importer, reuse, molecule and its Docker driver), on the Python of
|
||||
# antsibull-changelog, galaxy-importer, reuse, molecule and its Docker driver, proxmoxer), on the Python of
|
||||
# .python-version (PYTHON_VERSION below), the one the lock was resolved on and a clone's .venv uses.
|
||||
# - /opt/collections: the collections of requirements.yml (the versions the roles are
|
||||
# tested against), found through ANSIBLE_COLLECTIONS_PATH, so `ansible-lint --offline`
|
||||
@@ -177,7 +177,7 @@ FROM os AS final
|
||||
ARG PYTHON_VERSION=3.14
|
||||
|
||||
LABEL org.opencontainers.image.title="ci" \
|
||||
org.opencontainers.image.description="CI tooling image for the mortis.kamino Ansible Collection: the Lint, Build and Molecule workflows run in it, so a job only checks out the code and runs. It bakes in ansible-core, ansible-lint, pre-commit with every hook environment of the repository, antsibull-changelog, galaxy-importer, reuse, molecule with its Docker driver, the collections of requirements.yml and extensions/molecule/requirements.yml, git, shellcheck, Python 3.11, 3.13 and the version of .python-version (the tools in /opt/venv run on it) next to the distribution python3 and primed ansible-test sanity virtualenvs. Pin it by tag and digest, as a job container or with docker run; it has no Node, so clone with git." \
|
||||
org.opencontainers.image.description="CI tooling image for the mortis.kamino Ansible Collection: the Lint, Build and Molecule workflows run in it, so a job only checks out the code and runs. It bakes in ansible-core, ansible-lint, pre-commit with every hook environment of the repository, antsibull-changelog, galaxy-importer, reuse, molecule with its Docker driver, proxmoxer, the collections of requirements.yml and extensions/molecule/requirements.yml, git, shellcheck, Python 3.11, 3.13 and the version of .python-version (the tools in /opt/venv run on it) next to the distribution python3 and primed ansible-test sanity virtualenvs. Pin it by tag and digest, as a job container or with docker run; it has no Node, so clone with git." \
|
||||
org.opencontainers.image.source="https://git.rkdr.net/mortis/kamino" \
|
||||
org.opencontainers.image.url="https://git.rkdr.net/mortis/kamino" \
|
||||
org.opencontainers.image.documentation="https://git.rkdr.net/mortis/kamino/src/branch/main/docs/images/ci.md" \
|
||||
@@ -185,7 +185,7 @@ LABEL org.opencontainers.image.title="ci" \
|
||||
org.opencontainers.image.authors="Defame1297 and contributors" \
|
||||
org.opencontainers.image.base.name="ubuntu:26.04" \
|
||||
net.rkdr.mortis.purpose="CI tooling image for the mortis.kamino Ansible Collection: the Lint, Build and Molecule workflows run in it, so a job only checks out the code and runs." \
|
||||
net.rkdr.mortis.contents="Ubuntu 26.04, /opt/venv (ansible-core, ansible-lint, pre-commit, antsibull-changelog, galaxy-importer, reuse, molecule, molecule-plugins[docker]), /opt/collections (community.general, ansible.posix, community.docker), /opt/pre-commit hook environments, ansible-test sanity venvs, python3 (distribution), python3.11, python3.13, python<PYTHON_VERSION> (the one of /opt/venv), git, shellcheck, /opt/ci-pins.sha256" \
|
||||
net.rkdr.mortis.contents="Ubuntu 26.04, /opt/venv (ansible-core, ansible-lint, pre-commit, antsibull-changelog, galaxy-importer, reuse, molecule, molecule-plugins[docker], proxmoxer), /opt/collections (community.general, ansible.posix, community.proxmox, community.docker), /opt/pre-commit hook environments, ansible-test sanity venvs, python3 (distribution), python3.11, python3.13, python<PYTHON_VERSION> (the one of /opt/venv), git, shellcheck, /opt/ci-pins.sha256" \
|
||||
net.rkdr.mortis.usage="Lint and Build: job container on the kamino-docker runner, git.rkdr.net/mortis/ci:version@sha256:digest with PRE_COMMIT_HOME set to /opt/pre-commit. Molecule (host executor, kamino-molecule runner): docker run as the runner user, with the Docker socket and the checkout mounted at the same path. In both, run sha256sum -c /opt/ci-pins.sha256 in the checkout root and install the pinned tools and collections when a pull request changed them, else use /opt/venv/bin and ANSIBLE_COLLECTIONS_PATH=/opt/collections. See the documentation label."
|
||||
|
||||
ENV PIP_DISABLE_PIP_VERSION_CHECK=1 \
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
# 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.
|
||||
# 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" \
|
||||
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." \
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# One RUN layer: about 30 MB compressed on top of the 29.8 MB base (estimated from
|
||||
# the real .debs, with the .pyc files the postinst scripts compile), far below
|
||||
# Cloudflare's 100 MB request-body limit on git.rkdr.net (kaniko pushes a layer as
|
||||
# one request). apt packages are not version-pinned, as in the original image; the
|
||||
# one request; gnupg adds a few MB, not measured). apt packages are not version-pinned, as in the original image; the
|
||||
# base image is pinned by digest and a rebuild is a reviewed digest bump downstream.
|
||||
#
|
||||
# The image carries SSH host keys and a machine-id generated at build time (the
|
||||
@@ -36,7 +36,7 @@ LABEL org.opencontainers.image.title="molecule-ubuntu2604" \
|
||||
org.opencontainers.image.authors="Defame1297 and contributors" \
|
||||
org.opencontainers.image.base.name="ubuntu:26.04" \
|
||||
net.rkdr.mortis.purpose="Disposable Ubuntu 26.04 test target for the molecule scenarios of the mortis.kamino Ansible Collection." \
|
||||
net.rkdr.mortis.contents="Ubuntu 26.04, systemd, systemd-sysv, dbus, sudo, iproute2, ca-certificates, python3, python3-apt, python3-systemd, iptables, ufw, fail2ban, openssh-server (ssh enabled)" \
|
||||
net.rkdr.mortis.contents="Ubuntu 26.04, systemd, systemd-sysv, dbus, sudo, iproute2, ca-certificates, python3, python3-apt, python3-systemd, iptables, ufw, fail2ban, openssh-server (ssh enabled), gnupg" \
|
||||
net.rkdr.mortis.usage="Molecule docker-driver platform with pre_build_image true, command /sbin/init, cgroupns_mode host, /sys/fs/cgroup mounted rw, tmpfs on /run and /run/lock, capability NET_ADMIN, security_opts apparmor=unconfined (not privileged). Pin git.rkdr.net/mortis/name:version@sha256:digest. See the documentation label."
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
@@ -44,15 +44,22 @@ ENV DEBIAN_FRONTEND=noninteractive
|
||||
# systemd as PID 1 with D-Bus, sudo and networking tools; the Python Ansible needs on
|
||||
# the target (python3-apt for the apt module); the firewall and intrusion-prevention
|
||||
# packages the roles manage (python3-systemd is a dependency of fail2ban's systemd
|
||||
# backend); sshd, enabled so a converge can test it under systemd.
|
||||
# backend); sshd, enabled so a converge can test it under systemd; gnupg, which the docker
|
||||
# scenario signs its stand-in APT repository with and which would otherwise cost it an
|
||||
# apt update and install in every run.
|
||||
# root's sudo (Ansible's become here) skips pam_unix's account check, whose unix_chkpwd
|
||||
# helper fails inside the container; non-root callers still go through pam_unix.
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
systemd systemd-sysv dbus sudo iproute2 ca-certificates \
|
||||
python3 python3-apt python3-systemd \
|
||||
iptables ufw fail2ban \
|
||||
openssh-server \
|
||||
gnupg \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& systemctl enable ssh
|
||||
&& systemctl enable ssh \
|
||||
&& sed -i '0,/^@include common-account/s//account sufficient pam_rootok.so\n@include common-account/' /etc/pam.d/sudo \
|
||||
&& grep -qx 'account sufficient pam_rootok.so' /etc/pam.d/sudo
|
||||
|
||||
STOPSIGNAL SIGRTMIN+3
|
||||
CMD ["/sbin/init"]
|
||||
+48
-9
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"description": "Run by .gitea/workflows/renovate.yml on this repository's own runner. Policy: automerge minor and patch, majors by hand. Every bot pull request must pass scripts/check_bot_pr_diff.py (lint workflow), which allows only version, tag, digest and pin lines. Image versions are assigned by the Images workflow when an image's inputs change, so a bot pull request needs no version edit.",
|
||||
"description": "Run by .gitea/workflows/renovate.yml on this repository's own runner. Policy: automerge minor and patch, majors by hand. Every bot pull request must pass scripts/check_bot_pr_diff.py (lint workflow), which allows only version, tag, digest and pin lines. Image versions are assigned by the Images workflow when an image's inputs change, so a bot pull request needs no version edit. Updates open on Mondays (UTC), so any Monday run can act; the own image pins and vulnerability fixes found on osv.dev open at any time. The weekly window and the groups bound the volume, so there is no hourly pull request limit. Vulnerability fixes skip the release-age wait, so they are never automerged: a person checks a fix that had no time to be pulled as a compromised release. Base-image bumps are manual: every Dockerfile is FROM ubuntu, grouped with the job containers.",
|
||||
"extends": [
|
||||
"config:recommended",
|
||||
":enablePreCommit"
|
||||
@@ -19,7 +19,7 @@
|
||||
],
|
||||
"automerge": true,
|
||||
"automergeType": "pr",
|
||||
"prHourlyLimit": 5,
|
||||
"prHourlyLimit": 0,
|
||||
"minimumReleaseAge": "3 days",
|
||||
"minimumReleaseAgeBehaviour": "timestamp-optional",
|
||||
"timezone": "UTC",
|
||||
@@ -90,7 +90,7 @@
|
||||
],
|
||||
"packageRules": [
|
||||
{
|
||||
"description": "Dockerfile base-image tag and digest bumps (images/*/Dockerfile) MAY automerge. Kamino is the untrusted side and the bump pull request's own CI exercises the new image before the merge. Placed first so the major-version rule below still turns automerge off. The merge publishes a new image version.",
|
||||
"description": "Dockerfile base-image tag and digest bumps (images/*/Dockerfile) MAY automerge. Kamino is the untrusted side and the bump pull request's own CI exercises the new image before the merge. Placed first so the major-version rule below still turns automerge off. The merge publishes a new image version. Today every Dockerfile is FROM ubuntu, whose bumps join the manual ubuntu base images group below; this rule is the safety net for a future base image of another kind.",
|
||||
"matchManagers": [
|
||||
"dockerfile"
|
||||
],
|
||||
@@ -145,12 +145,18 @@
|
||||
"allowedVersions": "<=26.10.1"
|
||||
},
|
||||
{
|
||||
"description": "The job containers of image.yml (matrix job_image, ubuntu by digest) hold the org registry push credential while the image job runs: never automerged, and kept in their own branch so the Dockerfile base-image bumps are not held back with them.",
|
||||
"description": "The job containers of image.yml (matrix job_image, ubuntu by digest) hold the org registry push credential while the image job runs: never automerged. Their ubuntu bumps share one branch with the Dockerfile FROM bumps (ubuntu base images rule below), so that pull request is manual too: a group automerges only if every update in it does.",
|
||||
"matchFileNames": [
|
||||
".gitea/workflows/image.yml"
|
||||
],
|
||||
"automerge": false,
|
||||
"additionalBranchPrefix": "job-container-"
|
||||
"automerge": false
|
||||
},
|
||||
{
|
||||
"description": "The Dockerfile FROM digests and the image.yml job_image digests of one Ubuntu update move in one pull request, so the release pair stays in step and one Images run covers both.",
|
||||
"matchPackageNames": [
|
||||
"ubuntu"
|
||||
],
|
||||
"groupName": "ubuntu base images"
|
||||
},
|
||||
{
|
||||
"description": "Safety net only: kaniko is pinned by layer digests in image.yml and no Renovate manager reads them, so it is updated by hand. If a manager ever starts to read it, its bumps are not automerged.",
|
||||
@@ -160,11 +166,15 @@
|
||||
"automerge": false
|
||||
},
|
||||
{
|
||||
"description": "Pin follow-up for our own images (git.rkdr.net/mortis/*): moves the image:<version>@sha256:<digest> pins of lint.yml, build.yml, molecule.yml and gitea-release-key.yml to the newest published version and its digest, and automerges. The Images workflow's completion starts a Renovate run, so this pull request opens minutes after a new version is pushed. The pull request's own Lint and Build run in the new image before the merge, and scripts/check_bot_pr_diff.py allows only these pin lines. The registry lists tags and digests anonymously, so no hostRules are needed. A major version stays manual (rule above).",
|
||||
"description": "Pin follow-up for our own images (git.rkdr.net/mortis/*): moves the image:<version>@sha256:<digest> pins of lint.yml, build.yml, molecule.yml and gitea-release-key.yml to the newest published version and its digest, and automerges. The Images workflow's completion starts a Renovate run, so this pull request opens minutes after a new version is pushed. The pull request's own Lint and Build run in the new image before the merge, and scripts/check_bot_pr_diff.py allows only these pin lines. The registry lists tags and digests anonymously, so no hostRules are needed. A major version stays manual (rule above). One pull request moves every image an Images run published (ci and both molecule images), so one Molecule run tests them together. Exempt from the weekly schedule, so the pins on main catch up with a new image within minutes.",
|
||||
"matchPackageNames": [
|
||||
"git.rkdr.net/mortis/**"
|
||||
],
|
||||
"automerge": true
|
||||
"automerge": true,
|
||||
"groupName": "own CI images",
|
||||
"schedule": [
|
||||
"at any time"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Look the pre-commit hook repositories up with git ls-remote (git-tags) instead of the GitHub API. This run has no GitHub token, and the github-tags datasource then either skips every hook (skipReason github-token-required, dry run 3880) or is refused at once with 403 rate limit (githubTokenWarn off, local run). git-tags needs no API and no credential, and it uses the dereferenced hash of an annotated tag, so the new rev is the commit, as pre-commit needs. The `# frozen:` form is kept by the manager's own replace template. It works only together with RENOVATE_GITHUB_TOKEN_WARN=false in renovate.yml: the token check runs after extraction and skips every github-tags dependency before a package rule can change its datasource (local run, Renovate 44.161.0). git-tags has no release timestamps, so minimumReleaseAge cannot delay a hook bump: hook bumps are never automerged, a person reviews each one.",
|
||||
@@ -177,16 +187,45 @@
|
||||
"overrideDatasource": "git-tags",
|
||||
"overridePackageName": "https://github.com/{{{depName}}}",
|
||||
"automerge": false
|
||||
},
|
||||
{
|
||||
"description": "Lint and build tooling in one weekly pull request across requirements-dev.lock and the ci image's uv pin, so one ci image build instead of one per tool.",
|
||||
"matchDatasources": [
|
||||
"pypi"
|
||||
],
|
||||
"matchPackageNames": [
|
||||
"apm-cli",
|
||||
"antsibull-changelog",
|
||||
"galaxy-importer",
|
||||
"reuse",
|
||||
"pre-commit",
|
||||
"uv"
|
||||
],
|
||||
"groupName": "lint tooling"
|
||||
},
|
||||
{
|
||||
"description": "The pre-commit hooks in one weekly pull request; never automerged (rule above).",
|
||||
"matchManagers": [
|
||||
"pre-commit"
|
||||
],
|
||||
"groupName": "pre-commit hooks"
|
||||
}
|
||||
],
|
||||
"lockFileMaintenance": {
|
||||
"enabled": true,
|
||||
"schedule": [
|
||||
"before 6am on monday"
|
||||
"on monday"
|
||||
],
|
||||
"automerge": false,
|
||||
"labels": [
|
||||
"lock-file-maintenance"
|
||||
]
|
||||
},
|
||||
"schedule": [
|
||||
"on monday"
|
||||
],
|
||||
"osvVulnerabilityAlerts": true,
|
||||
"vulnerabilityAlerts": {
|
||||
"automerge": false
|
||||
}
|
||||
}
|
||||
+15
-6
@@ -214,10 +214,14 @@ ansible-lint==26.10.1 \
|
||||
# via
|
||||
# -r requirements-dev.txt
|
||||
# galaxy-importer
|
||||
antsibull-changelog==0.37.0 \
|
||||
--hash=sha256:649105fe6ccd4f035688c4e2e580573660712af1e46f8c0d3d8891352ffc7e2e \
|
||||
--hash=sha256:c9fb0e7625b208ae4ea6fe3633bc0dbeb029bcd2a79da36a8ef7f5a256beadc4
|
||||
antsibull-changelog==0.38.0 \
|
||||
--hash=sha256:674989862b8518ad14bb3ba2b149dc4d70f180666102e0f104864efa6f62ae21 \
|
||||
--hash=sha256:a37d7cd00943e97ed076eb9426a7cd5cd675b247209300ea719948ceaddc9d63
|
||||
# via -r requirements-dev.txt
|
||||
antsibull-docs-loader==1.0.0 \
|
||||
--hash=sha256:92ec1647c24e9006efe7bb7525f3087b9ac70c878da2f2a1b105e7485fd7b240 \
|
||||
--hash=sha256:c1c08623c14d3fc02add4b927678690174f8a082543ea0a48fd61e3647dcd053
|
||||
# via antsibull-changelog
|
||||
antsibull-docs-parser==1.2.3 \
|
||||
--hash=sha256:0d4835c615b6ae1b64d219d42260c2e1b58b6312809599e8e1a63adf7797e968 \
|
||||
--hash=sha256:66d593ad90d5499112cc3167fb178bfa787b496eb883102dfe12a4a4047406ba
|
||||
@@ -236,9 +240,9 @@ anyio==4.16.0 \
|
||||
# via
|
||||
# httpx2
|
||||
# openai
|
||||
apm-cli==0.37.0 \
|
||||
--hash=sha256:1078dc4d5bd7d797f4924548f684daffd026df740b31f99b17fc13958e5da762 \
|
||||
--hash=sha256:87cbcb6a864aa8251ffea446fc34fd439caa6d01d51df1a9399669bed5fab576
|
||||
apm-cli==0.38.1 \
|
||||
--hash=sha256:c2a0394643e54d3516efefcd78bb043509ac48b65cca1f40166023789b8eb89a \
|
||||
--hash=sha256:c2ddd1ea95f7223de2ced83c1bbb61b756a10de2651edc76b93346c925dc162b
|
||||
# via -r requirements-dev.txt
|
||||
attrs==23.2.0 \
|
||||
--hash=sha256:935dc3b529c262f6cf76e50877d35a4bd3c1de194fd41f47a2b7ae8f19971f30 \
|
||||
@@ -1619,6 +1623,10 @@ propcache==0.5.4 \
|
||||
# via
|
||||
# aiohttp
|
||||
# yarl
|
||||
proxmoxer==2.3.0 \
|
||||
--hash=sha256:0b0b2067187af1fc6d4257a46ac68c8fd79cc25d2813637cdae7a9a98fbfd11f \
|
||||
--hash=sha256:1c03445e95cf9c53b6e50614dbaf561e0e1eb3ec878cf45ddde4bc4421c56743
|
||||
# via -r requirements-dev.txt
|
||||
puremagic==2.3.0 \
|
||||
--hash=sha256:15ce035fe4c3f23e884a105d07448a5a81dd2e297985bdb636928ddf89bb3fe7 \
|
||||
--hash=sha256:b54e4a69dd37c50bacc879380f132382ab4e9a935529628c8975abcc73e10640
|
||||
@@ -1939,6 +1947,7 @@ pyyaml==6.0.4 \
|
||||
# ansible-compat
|
||||
# ansible-core
|
||||
# ansible-lint
|
||||
# antsibull-docs-loader
|
||||
# antsibull-fileutils
|
||||
# apm-cli
|
||||
# galaxy-importer
|
||||
|
||||
@@ -9,11 +9,14 @@
|
||||
ansible-core==2.22.0
|
||||
ansible-lint==26.10.1
|
||||
pre-commit==4.7.0
|
||||
antsibull-changelog==0.37.0
|
||||
antsibull-changelog==0.38.0
|
||||
galaxy-importer==0.4.44
|
||||
reuse==6.3.0
|
||||
molecule==26.11.0
|
||||
molecule-plugins[docker]==26.11.0
|
||||
# proxmoxer: the controller-side library community.proxmox's modules import (they refuse anything below 2.3),
|
||||
# so lint and Molecule run where a consumer's controller would.
|
||||
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):
|
||||
# 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
|
||||
@@ -11,3 +11,5 @@ collections:
|
||||
version: 14.0.1
|
||||
- name: ansible.posix
|
||||
version: 2.2.2
|
||||
- name: community.proxmox
|
||||
version: 2.1.0
|
||||
+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.
|
||||
- **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:*
|
||||
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
|
||||
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
|
||||
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
|
||||
`jammy` or `all` still declared. *Why:* no tool reads the declaration, so it is worth something
|
||||
only if true. *Held:* review.
|
||||
Debian image (#226) lands: `trixie` declared untested, and Debian `all` in network_interfaces.
|
||||
*Why:* no tool reads the declaration, so it is worth something only if true. *Held:* review.
|
||||
- **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.
|
||||
*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):
|
||||
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.
|
||||
- **Check mode.** Every scenario runs `check` before and after converge. The only guards are
|
||||
`check_mode: false` on read-only probes and `when: not ansible_check_mode`; `--check` is the
|
||||
supported preview, and the README says a play-level `check_mode: true` is not supported. A role
|
||||
that cannot support check mode says why in README Notes and drops the step. *Why:* check-mode
|
||||
breakage is a frequent fix, and one guard pattern is reviewable. *Held:* review until every
|
||||
scenario's `test_sequence` runs `check` (#134).
|
||||
- **Check mode.** Every scenario runs `check` before and after converge. Guards:
|
||||
`check_mode: false` on read-only probes, and `when: not ansible_check_mode`, alone or as
|
||||
`not ansible_check_mode or <condition>` where the condition shows the task can run (such as a
|
||||
registered result that is not changed). README: `--check` is the supported preview and a
|
||||
play-level `check_mode: true` is not supported; a role whose `--check` needs its package
|
||||
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
|
||||
|
||||
@@ -122,4 +125,5 @@ names a check that does not exist yet and its backlog issue.
|
||||
review that each new internal role has it.
|
||||
- **`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.
|
||||
*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
|
||||
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),
|
||||
which is the source of truth.
|
||||
|
||||
@@ -63,11 +66,13 @@ itself always stops and starts the service.
|
||||
|
||||
## Testing
|
||||
|
||||
Two molecule scenarios run on Ubuntu 24.04 (noble) against stub binaries (shell scripts) under
|
||||
a 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
|
||||
Two molecule scenarios run in CI only, on two platforms: `${MOLECULE_IMAGE}` (Ubuntu 24.04) and
|
||||
`${MOLECULE_IMAGE_2604}` (Ubuntu 26.04). They run against stub binaries (shell scripts) under a
|
||||
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
|
||||
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.
|
||||
|
||||
Idempotent: yes.
|
||||
@@ -11,6 +11,7 @@ galaxy_info:
|
||||
- name: Ubuntu
|
||||
versions:
|
||||
- noble
|
||||
- resolute
|
||||
galaxy_tags:
|
||||
- systemd
|
||||
- update
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
---
|
||||
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404 image
|
||||
# (MOLECULE_IMAGE, the pin in .gitea/workflows/molecule.yml). Needs no network: the "binaries"
|
||||
# are stub shell scripts written by ../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.
|
||||
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404
|
||||
# (MOLECULE_IMAGE) and molecule-ubuntu2604 (MOLECULE_IMAGE_2604) images, pinned in
|
||||
# .gitea/workflows/molecule.yml. Needs no network: the "binaries" are stub shell scripts written by
|
||||
# ../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:
|
||||
name: docker
|
||||
platforms:
|
||||
@@ -21,6 +22,21 @@ platforms:
|
||||
- /run/lock
|
||||
security_opts:
|
||||
- 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:
|
||||
name: ansible
|
||||
env:
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
---
|
||||
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404 image
|
||||
# (MOLECULE_IMAGE, the pin in .gitea/workflows/molecule.yml). Needs no network: the "binaries"
|
||||
# are stub shell scripts written by ../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.
|
||||
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404
|
||||
# (MOLECULE_IMAGE) and molecule-ubuntu2604 (MOLECULE_IMAGE_2604) images, pinned in
|
||||
# .gitea/workflows/molecule.yml. Needs no network: the "binaries" are stub shell scripts written by
|
||||
# ../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:
|
||||
name: docker
|
||||
platforms:
|
||||
@@ -21,6 +22,21 @@ platforms:
|
||||
- /run/lock
|
||||
security_opts:
|
||||
- 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:
|
||||
name: ansible
|
||||
env:
|
||||
@@ -30,13 +46,16 @@ verifier:
|
||||
scenario:
|
||||
# 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.
|
||||
# A check runs before the converge (fresh host) and after it (configured host).
|
||||
test_sequence:
|
||||
- dependency
|
||||
- cleanup
|
||||
- syntax
|
||||
- create
|
||||
- prepare
|
||||
- check
|
||||
- converge
|
||||
- check
|
||||
- idempotence
|
||||
- side_effect
|
||||
- verify
|
||||
|
||||
@@ -4,7 +4,7 @@ Installs cloudflared as a systemd service for a locally managed Cloudflare Tunne
|
||||
|
||||
## 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.
|
||||
|
||||
@@ -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_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_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_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. |
|
||||
@@ -106,7 +107,7 @@ Remove with `-e "cloudflared_remove=true cloudflared_remove_data=true"`; only `c
|
||||
|
||||
## 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
|
||||
|
||||
@@ -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.
|
||||
- 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.
|
||||
- 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_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"
|
||||
|
||||
|
||||
@@ -4,3 +4,5 @@
|
||||
ansible.builtin.systemd:
|
||||
name: cloudflared
|
||||
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
|
||||
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.
|
||||
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:
|
||||
type: raw
|
||||
description:
|
||||
|
||||
@@ -10,6 +10,7 @@ galaxy_info:
|
||||
- name: Ubuntu
|
||||
versions:
|
||||
- noble
|
||||
- resolute
|
||||
galaxy_tags:
|
||||
- cloudflared
|
||||
- cloudflare
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
---
|
||||
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404 image
|
||||
# (MOLECULE_IMAGE, the pin in .gitea/workflows/molecule.yml). No Cloudflare and no real
|
||||
# cloudflared: prepare.yml starts a stub of the Cloudflare API on the controller's loopback
|
||||
# (files/cloudflare_api_stub.py, reached through cloudflared_api_base_url; cleanup.yml stops it)
|
||||
# and seeds a stub cloudflared binary that reports an older version, so the update downloads its
|
||||
# new stub from local file:// URLs. The scenario downloads nothing. cloudflared_manage_dns is
|
||||
# false here because community.general.cloudflare_dns cannot be pointed at the stub; the DNS
|
||||
# guards in front of it are run with it true in verify.yml.
|
||||
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404
|
||||
# (MOLECULE_IMAGE) and molecule-ubuntu2604 (MOLECULE_IMAGE_2604) images, pinned in
|
||||
# .gitea/workflows/molecule.yml. No Cloudflare and no real cloudflared: prepare.yml starts a stub of
|
||||
# the Cloudflare API on the controller's loopback (files/cloudflare_api_stub.py, reached through
|
||||
# cloudflared_api_base_url; cleanup.yml stops it) and seeds a stub cloudflared binary that reports
|
||||
# an older version, so the update downloads its new stub from local file:// URLs. The scenario
|
||||
# downloads nothing. cloudflared_manage_dns is false here because community.general.cloudflare_dns
|
||||
# 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.
|
||||
driver:
|
||||
name: docker
|
||||
@@ -26,6 +26,21 @@ platforms:
|
||||
- /run/lock
|
||||
security_opts:
|
||||
- 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:
|
||||
name: ansible
|
||||
# One source for every play, so a verify play that runs the role again renders the same
|
||||
@@ -75,13 +90,16 @@ verifier:
|
||||
scenario:
|
||||
# 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.
|
||||
# A check runs before the converge (fresh host) and after it (configured host).
|
||||
test_sequence:
|
||||
- dependency
|
||||
- cleanup
|
||||
- syntax
|
||||
- create
|
||||
- prepare
|
||||
- check
|
||||
- converge
|
||||
- check
|
||||
- idempotence
|
||||
- side_effect
|
||||
- verify
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
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_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
|
||||
# text, so the rescue below cannot mistake it for the failure under test.
|
||||
|
||||
@@ -157,6 +157,9 @@
|
||||
- name: tunnel-id-not-uuid
|
||||
vars: {cloudflared_tunnel_id: not-a-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
|
||||
vars: {cloudflared_tunnel_id: ""}
|
||||
expect: run the mint entry point first
|
||||
@@ -172,7 +175,7 @@
|
||||
- name: tunnel-deleted
|
||||
vars: {cloudflared_tunnel_id: 6f1a6e2c-0000-4000-8000-000000000002}
|
||||
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
|
||||
vars: {cloudflared_tunnel_id: 6f1a6e2c-0000-4000-8000-00000000000f}
|
||||
expect: (HTTP 404)
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
# briefly before trusting it.
|
||||
until: __cloudflared_tunnel_lookup.status | default(0) == 200
|
||||
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
|
||||
# two tasks below fail instead, with the re-mint instructions for a 404.
|
||||
ignore_errors: true # noqa: ignore-errors
|
||||
@@ -281,6 +281,7 @@
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
register: __cloudflared_unit_file
|
||||
|
||||
- name: Reload systemd daemon
|
||||
ansible.builtin.systemd:
|
||||
@@ -291,6 +292,8 @@
|
||||
name: cloudflared
|
||||
enabled: true
|
||||
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
|
||||
ansible.builtin.systemd:
|
||||
@@ -301,5 +304,8 @@
|
||||
- name: Fail if cloudflared service is not running
|
||||
ansible.builtin.fail:
|
||||
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]
|
||||
@@ -4,6 +4,7 @@
|
||||
ansible.builtin.group:
|
||||
name: "{{ cloudflared_group }}"
|
||||
system: true
|
||||
register: __cloudflared_group_account
|
||||
tags: [cloudflared, prereqs, always]
|
||||
|
||||
- name: Create cloudflared user
|
||||
@@ -15,6 +16,7 @@
|
||||
comment: "Cloudflare Tunnel daemon"
|
||||
system: true
|
||||
create_home: false
|
||||
register: __cloudflared_user_account
|
||||
tags: [cloudflared, prereqs, always]
|
||||
|
||||
- name: Create cloudflared config directory
|
||||
@@ -25,6 +27,8 @@
|
||||
owner: "{{ cloudflared_user }}"
|
||||
group: "{{ cloudflared_group }}"
|
||||
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]
|
||||
|
||||
- name: Check if cloudflared binary exists
|
||||
|
||||
@@ -80,7 +80,8 @@
|
||||
cloudflared was not stopped and still runs {{ __cloudflared_installed_version }}.
|
||||
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
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino._binary_update
|
||||
@@ -93,6 +94,7 @@
|
||||
_binary_update_version_command: ["{{ cloudflared_install_dir }}/cloudflared", --version]
|
||||
_binary_update_expected_version: "{{ cloudflared_version }}"
|
||||
_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]
|
||||
|
||||
always:
|
||||
|
||||
@@ -63,6 +63,12 @@
|
||||
newline or %, and the two directories must be absolute paths.
|
||||
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
|
||||
# as missing, as in the mint entry point, so the two cannot disagree.
|
||||
- name: Require the minted tunnel secrets
|
||||
|
||||
@@ -4,9 +4,7 @@ Installs Docker Engine from the upstream Docker APT repository, optionally updat
|
||||
|
||||
## 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.
|
||||
|
||||
Untested platforms: Ubuntu releases other than 24.04; `meta/main.yml` declares Ubuntu `all`.
|
||||
Ubuntu 24.04 (noble) and 26.04 (resolute), the platforms the molecule scenario runs on. The key and repository URLs point at `download.docker.com/linux/ubuntu`, and the source line uses `ansible_facts['distribution_release']`. The apt architecture is derived from the host (`x86_64` gives `amd64`, `aarch64` gives `arm64`); any other architecture fails the play until `docker_apt_arch` is set. A limited molecule scenario covers the role's own logic (see [Tests](#tests)); the real Docker Engine is not tested.
|
||||
|
||||
The role targets Ubuntu hosts only: it installs from Docker's Ubuntu repository, so it does not cover Debian trixie (Proxmox hosts).
|
||||
|
||||
@@ -29,6 +27,7 @@ The role targets Ubuntu hosts only: it installs from Docker's Ubuntu repository,
|
||||
| `docker_keyring_path` | `/etc/apt/keyrings/docker.asc` | no | Repository key location. |
|
||||
| `docker_apt_list_path` | `/etc/apt/sources.list.d/docker.list` | no | APT source file. |
|
||||
| `docker_gpg_url` | `https://download.docker.com/linux/ubuntu/gpg` | no | Key URL. |
|
||||
| `docker_keyring_checksum` | sha256 of the current Docker key | no | Expected sha256 (hex, no `sha256:` prefix) of the key at `docker_gpg_url`; set it too when `docker_gpg_url` is overridden; a mismatch fails the download, so a changed key stops the install until this is updated. |
|
||||
| `docker_repo_base_url` | `https://download.docker.com/linux/ubuntu` | no | Repository base URL. |
|
||||
| `docker_apt_arch` | derived from the host | no | Architecture in the APT source. Empty derives it (`x86_64` gives `amd64`, `aarch64` gives `arm64`); another architecture fails until this is set. A value set here is always used; lowercase letters and digits only. |
|
||||
| `docker_start_missed` | `false` | no | Install a boot unit that starts the containers Docker skipped after a reboot (see [Boot and shutdown units](#boot-and-shutdown-units)). |
|
||||
@@ -88,17 +87,18 @@ With any of `docker_daemon_options`, `docker_live_restore`, `docker_log_driver`,
|
||||
|
||||
## 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`, `docker_keyring_checksum` (the throwaway key's hash) 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:
|
||||
|
||||
- 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 key is fetched, checked against `docker_keyring_checksum`, 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_facts['distribution_release']`.
|
||||
- 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`.
|
||||
- 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.
|
||||
- With the daemon inputs set, `/etc/docker/daemon.json` is valid JSON with exactly the expected keys, mode `0644` and root-owned. A change with `docker_daemon_restart: false` leaves dockerd running (its start time is unchanged); with `true` it restarts it. A key set both in `docker_daemon_options` and by a dedicated input, and a bad log size, driver or file count, are refused before any change.
|
||||
- The argument check refuses a mapping for `docker_users`, a non-boolean `docker_remove` and a `docker_stop_at_shutdown_timeout` of 0.
|
||||
- A key whose hash does not match `docker_keyring_checksum` fails the key download.
|
||||
- A second run changes nothing (molecule's idempotence check).
|
||||
|
||||
What it does not show: what the units do at a real boot or shutdown (the container has no dockerd, no NFS shares and no reboot; the selection logic of `docker-start-missed` is unit-tested in `tests/scripts/test_docker_files.py`), that the upstream repository and key at `download.docker.com` are reachable and valid, that the real packages install, that `dockerd` starts, anything about container networking or iptables, the `docker_update` path (`tasks/update.yml`), and removal without `docker_remove_data` (the removal stops the unit first, so it can run only once per install). It needs the Ubuntu mirrors, for the `curl` the role installs. These gaps are a known residual risk of the role.
|
||||
@@ -106,6 +106,7 @@ What it does not show: what the units do at a real boot or shutdown (the contain
|
||||
## Notes
|
||||
|
||||
- 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.
|
||||
- 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`.
|
||||
|
||||
@@ -11,6 +11,10 @@ docker_packages:
|
||||
docker_keyring_path: /etc/apt/keyrings/docker.asc
|
||||
docker_apt_list_path: /etc/apt/sources.list.d/docker.list
|
||||
docker_gpg_url: https://download.docker.com/linux/ubuntu/gpg
|
||||
# sha256 of Docker's package signing key (9DC858229FC7DD38854AE2D88D81803C0EBFCD88), as the ASCII-armored file
|
||||
# docker_gpg_url serves. Static on purpose: a rotated or re-armored key fails the install until a person has checked the
|
||||
# new one and updated this hash.
|
||||
docker_keyring_checksum: "1500c1f56fa9e26b9b8f42452a553675796ade0807cdce11975eb98170b3a570"
|
||||
docker_repo_base_url: https://download.docker.com/linux/ubuntu
|
||||
|
||||
# Architecture written into the APT source. Empty (the default) derives it from the host: x86_64 gives amd64, aarch64 gives arm64, any
|
||||
|
||||
@@ -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
|
||||
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:
|
||||
docker_remove:
|
||||
type: bool
|
||||
@@ -49,11 +49,19 @@ argument_specs:
|
||||
default: https://download.docker.com/linux/ubuntu/gpg
|
||||
description:
|
||||
- URL of the repository signing key.
|
||||
docker_keyring_checksum:
|
||||
type: str
|
||||
default: 1500c1f56fa9e26b9b8f42452a553675796ade0807cdce11975eb98170b3a570
|
||||
description:
|
||||
- >-
|
||||
sha256 of the key at C(docker_gpg_url), as the hex digest without the C(sha256:) prefix. The download fails
|
||||
on a mismatch, so a rotated or re-armored upstream key stops the install until the new key is checked and
|
||||
the hash updated. Set C(docker_keyring_checksum) too when C(docker_gpg_url) is overridden.
|
||||
docker_repo_base_url:
|
||||
type: str
|
||||
default: https://download.docker.com/linux/ubuntu
|
||||
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:
|
||||
type: str
|
||||
default: ""
|
||||
|
||||
@@ -9,7 +9,8 @@ galaxy_info:
|
||||
platforms:
|
||||
- name: Ubuntu
|
||||
versions:
|
||||
- all
|
||||
- noble
|
||||
- resolute
|
||||
galaxy_tags:
|
||||
- docker
|
||||
- containers
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
hosts: all
|
||||
vars:
|
||||
docker_gpg_url: file:///srv/docker-stub-repo/docker.asc
|
||||
# The stand-in key is generated per run, so its hash is read here rather than pinned.
|
||||
docker_keyring_checksum: "{{ docker_stub_key.stat.checksum }}"
|
||||
docker_repo_base_url: file:///srv/docker-stub-repo
|
||||
docker_users: [moleculeuser]
|
||||
docker_start_missed: true
|
||||
@@ -18,118 +20,11 @@
|
||||
docker_log_max_file: "3"
|
||||
docker_daemon_options:
|
||||
max-concurrent-downloads: 3
|
||||
pre_tasks:
|
||||
- name: Stat the stand-in repository key
|
||||
ansible.builtin.stat:
|
||||
path: /srv/docker-stub-repo/docker.asc
|
||||
checksum_algorithm: sha256
|
||||
register: docker_stub_key
|
||||
roles:
|
||||
- role: mortis.kamino.docker
|
||||
|
||||
# The plays below are refusals: argument_specs rejects the wrong types before any task runs,
|
||||
# so the idempotence run stays clean. A sentinel in the failure message tells "the role
|
||||
# refused" from "the fail task after the role ran", which a bare rescue cannot.
|
||||
- name: A docker_users value that is not a list is refused
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
vars:
|
||||
docker_users:
|
||||
not: a-list
|
||||
tasks:
|
||||
- name: Apply the role with a mapping for docker_users
|
||||
block:
|
||||
- name: Include the role
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.docker
|
||||
- name: Fail when the wrong type was accepted
|
||||
ansible.builtin.fail:
|
||||
msg: MOLECULE-ACCEPTED
|
||||
rescue:
|
||||
- name: The argument check stopped the play
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- "'MOLECULE-ACCEPTED' not in ansible_failed_result.msg | default('')"
|
||||
- "'docker_users' in ansible_failed_result.msg | default('')"
|
||||
quiet: true
|
||||
|
||||
- name: A docker_remove value that is not a boolean is refused
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
vars:
|
||||
docker_remove: maybe
|
||||
tasks:
|
||||
- name: Apply the role with a non-boolean docker_remove
|
||||
block:
|
||||
- name: Include the role
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.docker
|
||||
- name: Fail when the wrong type was accepted
|
||||
ansible.builtin.fail:
|
||||
msg: MOLECULE-ACCEPTED
|
||||
rescue:
|
||||
- name: The argument check stopped the play
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- "'MOLECULE-ACCEPTED' not in ansible_failed_result.msg | default('')"
|
||||
- "'docker_remove' in ansible_failed_result.msg | default('')"
|
||||
quiet: true
|
||||
|
||||
# The architecture is written into the one-line apt source, so a value with a space or a bracket is refused before anything
|
||||
# changes. The derived default is covered by the converge above and verify.yml (the container is x86_64, so the source says amd64).
|
||||
- name: A docker_apt_arch value that would corrupt the apt source is refused
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
vars:
|
||||
docker_apt_arch: "bad arch"
|
||||
tasks:
|
||||
- name: Apply the role with a bad architecture
|
||||
block:
|
||||
- name: Include the role
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.docker
|
||||
- name: Fail when the bad architecture was accepted
|
||||
ansible.builtin.fail:
|
||||
msg: MOLECULE-ACCEPTED
|
||||
rescue:
|
||||
- name: The validation stopped the play
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- "'MOLECULE-ACCEPTED' not in ansible_failed_result.msg | default('')"
|
||||
- "'docker_apt_arch' in ansible_failed_result.msg | default('')"
|
||||
quiet: true
|
||||
|
||||
# The unit timings are checked before anything changes.
|
||||
- name: A docker_stop_at_shutdown_timeout of 0 is refused
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
vars:
|
||||
docker_stop_at_shutdown_timeout: 0
|
||||
tasks:
|
||||
- name: Apply the role with a timeout of 0
|
||||
block:
|
||||
- name: Include the role
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.docker
|
||||
- name: Fail when the timeout was accepted
|
||||
ansible.builtin.fail:
|
||||
msg: MOLECULE-ACCEPTED
|
||||
rescue:
|
||||
- name: The validation stopped the play
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- "'MOLECULE-ACCEPTED' not in ansible_failed_result.msg | default('')"
|
||||
- "'docker_stop_at_shutdown_timeout' in ansible_failed_result.msg | default('')"
|
||||
quiet: true
|
||||
|
||||
# A key that docker_daemon_options and a dedicated input both set, and a log value dockerd would reject, stop the run before any change.
|
||||
- name: A bad daemon setting is refused
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: Apply the role with each bad setting
|
||||
ansible.builtin.include_tasks: tasks/refuse_daemon.yml
|
||||
vars:
|
||||
docker_refused: "{{ item }}"
|
||||
loop:
|
||||
- {docker_live_restore: true, docker_daemon_options: {live-restore: false}}
|
||||
- {docker_log_driver: local, docker_daemon_options: {log-driver: json-file}}
|
||||
- {docker_log_max_size: 10m, docker_daemon_options: {log-opts: {max-size: 1m}}}
|
||||
- {docker_log_driver: Local}
|
||||
- {docker_log_max_size: ten}
|
||||
- {docker_log_max_file: "0"}
|
||||
- {docker_log_max_file: "-1"}
|
||||
@@ -1,9 +1,10 @@
|
||||
---
|
||||
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404 image
|
||||
# (MOLECULE_IMAGE, the pin in .gitea/workflows/molecule.yml). No privileged mode: systemd needs a
|
||||
# writable cgroup, nothing else. NET_ADMIN is kept so the platform matches the other scenarios;
|
||||
# this role does not need it, because the Docker Engine is a stand-in package and no daemon,
|
||||
# bridge or iptables rule is created.
|
||||
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404
|
||||
# (MOLECULE_IMAGE) and molecule-ubuntu2604 (MOLECULE_IMAGE_2604) images, pinned in
|
||||
# .gitea/workflows/molecule.yml. No privileged mode: systemd needs a writable cgroup, nothing else.
|
||||
# NET_ADMIN is kept so the platform matches the other scenarios; this role does not need it,
|
||||
# because the Docker Engine is a stand-in package and no daemon, bridge or iptables rule is
|
||||
# created.
|
||||
driver:
|
||||
name: docker
|
||||
platforms:
|
||||
@@ -24,6 +25,23 @@ platforms:
|
||||
- NET_ADMIN
|
||||
security_opts:
|
||||
- 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:
|
||||
name: ansible
|
||||
verifier:
|
||||
@@ -31,13 +49,16 @@ verifier:
|
||||
scenario:
|
||||
# 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.
|
||||
# A check runs before the converge (fresh host) and after it (configured host).
|
||||
test_sequence:
|
||||
- dependency
|
||||
- cleanup
|
||||
- syntax
|
||||
- create
|
||||
- prepare
|
||||
- check
|
||||
- converge
|
||||
- check
|
||||
- idempotence
|
||||
- side_effect
|
||||
- verify
|
||||
|
||||
@@ -12,6 +12,12 @@
|
||||
docker_molecule_repo: /srv/docker-stub-repo
|
||||
docker_molecule_work: /var/tmp/docker-stub-work
|
||||
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
|
||||
ansible.builtin.copy:
|
||||
src: build-stub-repo.sh
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
---
|
||||
# The zeroed hash matches no file, so the key task must be the one that fails.
|
||||
- name: Run the role with a checksum the stand-in key does not have
|
||||
block:
|
||||
- name: Include the role
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.docker
|
||||
vars:
|
||||
docker_gpg_url: file:///srv/docker-stub-repo/docker.asc
|
||||
docker_repo_base_url: file:///srv/docker-stub-repo
|
||||
docker_keyring_path: /tmp/docker-refused-key.asc
|
||||
docker_keyring_checksum: "{{ '0' * 64 }}"
|
||||
- name: Fail when the wrong key was accepted
|
||||
ansible.builtin.fail:
|
||||
msg: MOLECULE-ACCEPTED
|
||||
rescue:
|
||||
- name: The key download stopped the play
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- ansible_failed_task.name == 'Install Docker APT GPG key'
|
||||
- "'did not match' in ansible_failed_result.msg | default('')"
|
||||
quiet: true
|
||||
always:
|
||||
- name: Remove the refused key path
|
||||
ansible.builtin.file:
|
||||
path: /tmp/docker-refused-key.asc
|
||||
state: absent
|
||||
@@ -1,4 +1,133 @@
|
||||
---
|
||||
# The refusals need no container, so they run once, on the controller, in check mode so that a
|
||||
# refusal that regressed cannot change it. The controller has no gathered facts, so a play that
|
||||
# does not test the architecture sets it. A sentinel in the failure message tells "the role
|
||||
# refused" from "the fail task after the role ran", which a bare rescue cannot.
|
||||
- name: A docker_users value that is not a list is refused
|
||||
hosts: localhost
|
||||
connection: local
|
||||
check_mode: true
|
||||
gather_facts: false
|
||||
vars:
|
||||
docker_apt_arch: amd64
|
||||
docker_users:
|
||||
not: a-list
|
||||
tasks:
|
||||
- name: Apply the role with a mapping for docker_users
|
||||
block:
|
||||
- name: Include the role
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.docker
|
||||
- name: Fail when the wrong type was accepted
|
||||
ansible.builtin.fail:
|
||||
msg: MOLECULE-ACCEPTED
|
||||
rescue:
|
||||
- name: The argument check stopped the play
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- "'MOLECULE-ACCEPTED' not in ansible_failed_result.msg | default('')"
|
||||
- "'docker_users' in ansible_failed_result.msg | default('')"
|
||||
quiet: true
|
||||
|
||||
- name: A docker_remove value that is not a boolean is refused
|
||||
hosts: localhost
|
||||
connection: local
|
||||
check_mode: true
|
||||
gather_facts: false
|
||||
vars:
|
||||
docker_apt_arch: amd64
|
||||
docker_remove: maybe
|
||||
tasks:
|
||||
- name: Apply the role with a non-boolean docker_remove
|
||||
block:
|
||||
- name: Include the role
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.docker
|
||||
- name: Fail when the wrong type was accepted
|
||||
ansible.builtin.fail:
|
||||
msg: MOLECULE-ACCEPTED
|
||||
rescue:
|
||||
- name: The argument check stopped the play
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- "'MOLECULE-ACCEPTED' not in ansible_failed_result.msg | default('')"
|
||||
- "'docker_remove' in ansible_failed_result.msg | default('')"
|
||||
quiet: true
|
||||
|
||||
# The architecture is written into the one-line apt source, so a value with a space or a bracket is refused before anything
|
||||
# changes. The derived default is covered by converge.yml and the plays below (the container is x86_64, so the source says amd64).
|
||||
- name: A docker_apt_arch value that would corrupt the apt source is refused
|
||||
hosts: localhost
|
||||
connection: local
|
||||
check_mode: true
|
||||
gather_facts: false
|
||||
vars:
|
||||
docker_apt_arch: "bad arch"
|
||||
tasks:
|
||||
- name: Apply the role with a bad architecture
|
||||
block:
|
||||
- name: Include the role
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.docker
|
||||
- name: Fail when the bad architecture was accepted
|
||||
ansible.builtin.fail:
|
||||
msg: MOLECULE-ACCEPTED
|
||||
rescue:
|
||||
- name: The validation stopped the play
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- "'MOLECULE-ACCEPTED' not in ansible_failed_result.msg | default('')"
|
||||
- "'docker_apt_arch' in ansible_failed_result.msg | default('')"
|
||||
quiet: true
|
||||
|
||||
# The unit timings are checked before anything changes.
|
||||
- name: A docker_stop_at_shutdown_timeout of 0 is refused
|
||||
hosts: localhost
|
||||
connection: local
|
||||
check_mode: true
|
||||
gather_facts: false
|
||||
vars:
|
||||
docker_apt_arch: amd64
|
||||
docker_stop_at_shutdown_timeout: 0
|
||||
tasks:
|
||||
- name: Apply the role with a timeout of 0
|
||||
block:
|
||||
- name: Include the role
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.docker
|
||||
- name: Fail when the timeout was accepted
|
||||
ansible.builtin.fail:
|
||||
msg: MOLECULE-ACCEPTED
|
||||
rescue:
|
||||
- name: The validation stopped the play
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- "'MOLECULE-ACCEPTED' not in ansible_failed_result.msg | default('')"
|
||||
- "'docker_stop_at_shutdown_timeout' in ansible_failed_result.msg | default('')"
|
||||
quiet: true
|
||||
|
||||
# A key that docker_daemon_options and a dedicated input both set, and a log value dockerd would reject, stop the run before any change.
|
||||
- name: A bad daemon setting is refused
|
||||
hosts: localhost
|
||||
connection: local
|
||||
check_mode: true
|
||||
gather_facts: false
|
||||
vars:
|
||||
docker_apt_arch: amd64
|
||||
tasks:
|
||||
- name: Apply the role with each bad setting
|
||||
ansible.builtin.include_tasks: tasks/refuse_daemon.yml
|
||||
vars:
|
||||
docker_refused: "{{ item }}"
|
||||
loop:
|
||||
- {docker_live_restore: true, docker_daemon_options: {live-restore: false}}
|
||||
- {docker_log_driver: local, docker_daemon_options: {log-driver: json-file}}
|
||||
- {docker_log_max_size: 10m, docker_daemon_options: {log-opts: {max-size: 1m}}}
|
||||
- {docker_log_driver: Local}
|
||||
- {docker_log_max_size: ten}
|
||||
- {docker_log_max_file: "0"}
|
||||
- {docker_log_max_file: "-1"}
|
||||
|
||||
# What the role is for, as far as stand-in packages can show it: the repository key and the
|
||||
# source line are in place and apt really used them, the packages are installed from that
|
||||
# repository, the unit is enabled and running, and the user joined the group. The second play
|
||||
@@ -173,12 +302,19 @@
|
||||
hosts: all
|
||||
vars:
|
||||
docker_gpg_url: file:///srv/docker-stub-repo/docker.asc
|
||||
docker_keyring_checksum: "{{ docker_stub_key.stat.checksum }}"
|
||||
docker_repo_base_url: file:///srv/docker-stub-repo
|
||||
docker_users: [moleculeuser]
|
||||
docker_start_missed: false
|
||||
docker_stop_at_shutdown: true
|
||||
docker_stop_at_shutdown_timeout: 20
|
||||
tasks:
|
||||
- name: Stat the stand-in repository key
|
||||
ansible.builtin.stat:
|
||||
path: /srv/docker-stub-repo/docker.asc
|
||||
checksum_algorithm: sha256
|
||||
register: docker_stub_key
|
||||
|
||||
- name: Apply the role with the boot unit off
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.docker
|
||||
@@ -239,6 +375,7 @@
|
||||
hosts: all
|
||||
vars:
|
||||
docker_gpg_url: file:///srv/docker-stub-repo/docker.asc
|
||||
docker_keyring_checksum: "{{ docker_stub_key.stat.checksum }}"
|
||||
docker_repo_base_url: file:///srv/docker-stub-repo
|
||||
docker_users: [moleculeuser]
|
||||
docker_start_missed: true
|
||||
@@ -249,6 +386,12 @@
|
||||
docker_log_max_file: "3"
|
||||
docker_live_restore: true
|
||||
tasks:
|
||||
- name: Stat the stand-in repository key
|
||||
ansible.builtin.stat:
|
||||
path: /srv/docker-stub-repo/docker.asc
|
||||
checksum_algorithm: sha256
|
||||
register: docker_stub_key
|
||||
|
||||
- name: Read the start time of the service
|
||||
ansible.builtin.command: systemctl show -p ActiveEnterTimestampMonotonic docker.service # noqa: command-instead-of-module
|
||||
register: docker_verify_before
|
||||
@@ -291,6 +434,14 @@
|
||||
- (docker_verify_daemon_after.content | b64decode | from_json)['max-concurrent-downloads'] == 6
|
||||
quiet: true
|
||||
|
||||
# A key that does not match docker_keyring_checksum fails at the key download, so the source line and packages are untouched. It goes to a separate path, so
|
||||
# the installed key stays for the removal below.
|
||||
- name: A key that does not match the pinned checksum is refused
|
||||
hosts: all
|
||||
tasks:
|
||||
- name: Apply the role with a wrong checksum
|
||||
ansible.builtin.include_tasks: tasks/refuse_checksum.yml
|
||||
|
||||
# docker_remove_data is set, so this also covers the destructive path: the packages are
|
||||
# purged and /var/lib/docker, seeded in prepare.yml, is deleted. The removal stops the unit
|
||||
# before the package takes it away, so it can only run once; a second run would fail on the
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
- curl
|
||||
state: present
|
||||
update_cache: true
|
||||
cache_valid_time: 3600
|
||||
tags: [docker, install]
|
||||
|
||||
- name: Ensure APT keyrings directory exists
|
||||
@@ -22,6 +23,7 @@
|
||||
ansible.builtin.get_url:
|
||||
url: "{{ docker_gpg_url }}"
|
||||
dest: "{{ docker_keyring_path }}"
|
||||
checksum: "sha256:{{ docker_keyring_checksum }}"
|
||||
mode: "0644"
|
||||
tags: [docker, install]
|
||||
|
||||
@@ -30,8 +32,9 @@
|
||||
ansible.builtin.copy:
|
||||
dest: "{{ docker_apt_list_path }}"
|
||||
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"
|
||||
register: __docker_apt_source
|
||||
tags: [docker, install]
|
||||
|
||||
- name: Install Docker Engine packages
|
||||
@@ -39,8 +42,12 @@
|
||||
ansible.builtin.apt:
|
||||
name: "{{ docker_packages }}"
|
||||
state: present
|
||||
# Always refreshed: a run that wrote the source line but failed to fetch its lists heals here.
|
||||
update_cache: true
|
||||
register: __docker_packages
|
||||
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]
|
||||
|
||||
- name: Enable and start Docker service
|
||||
@@ -49,4 +56,6 @@
|
||||
name: "{{ docker_service }}"
|
||||
enabled: true
|
||||
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]
|
||||
@@ -24,6 +24,8 @@
|
||||
when:
|
||||
- not (docker_remove | default(false) | 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]
|
||||
|
||||
- name: Add configured users to the docker group
|
||||
@@ -33,7 +35,10 @@
|
||||
groups: "{{ docker_group }}"
|
||||
append: true
|
||||
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]
|
||||
|
||||
- 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
|
||||
|
||||
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.
|
||||
|
||||
@@ -82,7 +82,7 @@ Main entry point: `fail2ban` (everything), `fail2ban_install`, `fail2ban_validat
|
||||
|
||||
## 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 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
|
||||
|
||||
- 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` 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.
|
||||
|
||||
@@ -10,6 +10,7 @@ galaxy_info:
|
||||
- name: Ubuntu
|
||||
versions:
|
||||
- noble
|
||||
- resolute
|
||||
galaxy_tags:
|
||||
- fail2ban
|
||||
- security
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
---
|
||||
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404 image
|
||||
# (MOLECULE_IMAGE, the pin in .gitea/workflows/molecule.yml). No privileged mode: systemd needs a
|
||||
# writable cgroup and the firewall tools need NET_ADMIN, nothing else.
|
||||
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404
|
||||
# (MOLECULE_IMAGE) and molecule-ubuntu2604 (MOLECULE_IMAGE_2604) images, pinned in
|
||||
# .gitea/workflows/molecule.yml. No privileged mode: systemd needs a writable cgroup and the
|
||||
# firewall tools need NET_ADMIN, nothing else.
|
||||
driver:
|
||||
name: docker
|
||||
platforms:
|
||||
@@ -22,6 +23,23 @@ platforms:
|
||||
- NET_ADMIN
|
||||
security_opts:
|
||||
- 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:
|
||||
name: ansible
|
||||
verifier:
|
||||
@@ -29,13 +47,16 @@ verifier:
|
||||
scenario:
|
||||
# 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.
|
||||
# A check runs before the converge (fresh host) and after it (configured host).
|
||||
test_sequence:
|
||||
- dependency
|
||||
- cleanup
|
||||
- syntax
|
||||
- create
|
||||
- prepare
|
||||
- check
|
||||
- converge
|
||||
- check
|
||||
- idempotence
|
||||
- side_effect
|
||||
- verify
|
||||
|
||||
@@ -4,7 +4,7 @@ Installs the Gitea git service as a systemd-managed binary with a GPG-verified d
|
||||
|
||||
## 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.
|
||||
|
||||
@@ -142,13 +142,13 @@ Update or remove: pass `-e gitea_update=true`, or `-e "gitea_remove=true gitea_r
|
||||
|
||||
## 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 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.
|
||||
|
||||
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
|
||||
|
||||
@@ -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`.
|
||||
- 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.
|
||||
- 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:
|
||||
name: gitea
|
||||
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
|
||||
versions:
|
||||
- noble
|
||||
- resolute
|
||||
galaxy_tags:
|
||||
- gitea
|
||||
- git
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
---
|
||||
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404 image
|
||||
# (MOLECULE_IMAGE, the pin in .gitea/workflows/molecule.yml). Tests the guard and no-op paths of
|
||||
# the role's `mint` entry point, the signature check of the download against local files and
|
||||
# throwaway keys, and the remove path with its ufw rules. Gitea is never installed, so the
|
||||
# normal-flow assert on gitea_api_token (after the service starts) is not
|
||||
# covered. The mint tasks only assert, but the remove-path play at the end of verify.yml needs
|
||||
# systemd (it stops and disables a stub unit) and ufw (it deletes the Gitea rules), so the
|
||||
# container runs systemd as PID 1 with a writable cgroup and NET_ADMIN. No privileged mode. The
|
||||
# image has ufw and gnupg preinstalled, so the scenario downloads nothing.
|
||||
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404
|
||||
# (MOLECULE_IMAGE) and molecule-ubuntu2604 (MOLECULE_IMAGE_2604) images, pinned in
|
||||
# .gitea/workflows/molecule.yml. Tests the guard and no-op paths of the role's `mint` entry point,
|
||||
# the signature check of the download against local files and throwaway keys, and the remove path
|
||||
# with its ufw rules. Gitea is never installed, so the normal-flow assert on gitea_api_token (after
|
||||
# the service starts) is not covered. The mint tasks only assert, but the remove-path play at the
|
||||
# end of verify.yml needs systemd (it stops and disables a stub unit) and ufw (it deletes the Gitea
|
||||
# rules), so the container runs systemd as PID 1 with a writable cgroup and NET_ADMIN. No
|
||||
# privileged mode. Both images have ufw and gnupg preinstalled, so the scenario downloads nothing.
|
||||
driver:
|
||||
name: docker
|
||||
platforms:
|
||||
@@ -28,6 +28,23 @@ platforms:
|
||||
- NET_ADMIN
|
||||
security_opts:
|
||||
- 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:
|
||||
name: ansible
|
||||
inventory:
|
||||
@@ -40,13 +57,16 @@ verifier:
|
||||
scenario:
|
||||
# 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.
|
||||
# A check runs before the converge (fresh host) and after it (configured host).
|
||||
test_sequence:
|
||||
- dependency
|
||||
- cleanup
|
||||
- syntax
|
||||
- create
|
||||
- prepare
|
||||
- check
|
||||
- converge
|
||||
- check
|
||||
- idempotence
|
||||
- side_effect
|
||||
- verify
|
||||
|
||||
@@ -92,6 +92,8 @@
|
||||
changed_when: false
|
||||
# Read-only: the script is only generated to be written by the next task, so it must also run in --check.
|
||||
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]
|
||||
|
||||
- name: Write bash completion to system directory
|
||||
@@ -102,6 +104,7 @@
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
when: not ansible_check_mode or gitea_installed
|
||||
tags: [gitea, configure]
|
||||
|
||||
- name: Create systemd service file for Gitea
|
||||
@@ -127,6 +130,7 @@
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
register: __gitea_unit_file
|
||||
tags: [gitea, configure]
|
||||
|
||||
- name: Reload systemd daemon
|
||||
@@ -164,6 +168,8 @@
|
||||
name: gitea
|
||||
enabled: true
|
||||
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]
|
||||
|
||||
- name: Check Gitea service status
|
||||
@@ -176,7 +182,10 @@
|
||||
- name: Fail if Gitea service is not running
|
||||
ansible.builtin.fail:
|
||||
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]
|
||||
|
||||
# The token is minted by the opt-in mint entry point, never here. This sits after the
|
||||
|
||||
@@ -39,4 +39,6 @@
|
||||
that:
|
||||
- gitea_binary.stat.exists
|
||||
fail_msg: "Gitea binary not found after download"
|
||||
# Nothing is downloaded under --check.
|
||||
when: not ansible_check_mode
|
||||
tags: [gitea, install, health, update]
|
||||
@@ -64,7 +64,8 @@
|
||||
Gitea was not stopped and still runs {{ gitea_installed_version }}.
|
||||
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
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino._binary_update
|
||||
@@ -76,6 +77,7 @@
|
||||
_binary_update_staged_path: "{{ gitea_staging_dir }}/gitea"
|
||||
_binary_update_version_command: ["{{ gitea_install_dir }}/gitea", --version]
|
||||
_binary_update_expected_version: "{{ gitea_version }}"
|
||||
when: not ansible_check_mode or __gitea_unit_file | default({}) is not changed
|
||||
tags: [gitea, update]
|
||||
|
||||
always:
|
||||
|
||||
@@ -4,7 +4,7 @@ Installs a Gitea Actions runner (`gitea-runner`) with Docker as a systemd servic
|
||||
|
||||
## 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.
|
||||
|
||||
@@ -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 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`.
|
||||
- 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.
|
||||
- `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.
|
||||
@@ -89,7 +89,7 @@ Change the registration scope of a registered runner: set `gitea_runner_registra
|
||||
|
||||
## 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
|
||||
|
||||
@@ -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 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.
|
||||
- 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.
|
||||
@@ -4,3 +4,5 @@
|
||||
ansible.builtin.systemd:
|
||||
name: gitea-runner
|
||||
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
|
||||
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).
|
||||
options:
|
||||
gitea_runner_remove:
|
||||
|
||||
@@ -10,6 +10,7 @@ galaxy_info:
|
||||
- name: Ubuntu
|
||||
versions:
|
||||
- noble
|
||||
- resolute
|
||||
galaxy_tags:
|
||||
- gitea
|
||||
- actions
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
---
|
||||
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404 image
|
||||
# (MOLECULE_IMAGE, the pin in .gitea/workflows/molecule.yml). No Gitea server and no Docker
|
||||
# daemon: prepare.yml seeds a stub docker.service, a stub runner binary that reports an older
|
||||
# version, and a .runner file, so the role skips the Docker install and the registration, and
|
||||
# the update downloads its new stub from local file:// URLs. The scenario downloads nothing.
|
||||
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404
|
||||
# (MOLECULE_IMAGE) and molecule-ubuntu2604 (MOLECULE_IMAGE_2604) images, pinned in
|
||||
# .gitea/workflows/molecule.yml. No Gitea server and no Docker daemon: prepare.yml seeds a stub
|
||||
# docker.service, a stub runner binary that reports an older version, and a .runner file, so the
|
||||
# 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.
|
||||
driver:
|
||||
name: docker
|
||||
@@ -23,6 +24,21 @@ platforms:
|
||||
- /run/lock
|
||||
security_opts:
|
||||
- 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:
|
||||
name: ansible
|
||||
# One source for every play, so a verify play that runs the role again renders the same
|
||||
@@ -50,13 +66,16 @@ verifier:
|
||||
scenario:
|
||||
# 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.
|
||||
# A check runs before the converge (fresh host) and after it (configured host).
|
||||
test_sequence:
|
||||
- dependency
|
||||
- cleanup
|
||||
- syntax
|
||||
- create
|
||||
- prepare
|
||||
- check
|
||||
- converge
|
||||
- check
|
||||
- idempotence
|
||||
- side_effect
|
||||
- verify
|
||||
|
||||
@@ -17,6 +17,10 @@
|
||||
owner: "{{ gitea_runner_user }}"
|
||||
group: "{{ gitea_runner_group }}"
|
||||
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]
|
||||
|
||||
- name: Check current runner registration file state
|
||||
@@ -62,6 +66,7 @@
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
register: __gitea_runner_unit_file
|
||||
tags: [gitea_runner, configure]
|
||||
|
||||
- name: Reload systemd
|
||||
@@ -76,6 +81,8 @@
|
||||
name: gitea-runner
|
||||
enabled: true
|
||||
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]
|
||||
|
||||
- name: Check runner service status
|
||||
@@ -88,5 +95,8 @@
|
||||
- name: Fail if runner service is not running
|
||||
ansible.builtin.fail:
|
||||
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]
|
||||
@@ -17,6 +17,7 @@
|
||||
name:
|
||||
- docker.io
|
||||
state: present
|
||||
register: __gitea_runner_docker_package
|
||||
tags: [gitea_runner, docker, install]
|
||||
|
||||
- name: Enable and start Docker
|
||||
@@ -25,6 +26,8 @@
|
||||
name: docker
|
||||
enabled: true
|
||||
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]
|
||||
|
||||
- name: Add the runner user to the docker group
|
||||
@@ -33,6 +36,8 @@
|
||||
name: "{{ gitea_runner_user }}"
|
||||
groups: docker
|
||||
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]
|
||||
|
||||
# Pulls ubuntu:24.04 from Docker Hub. Also proves Docker runs inside a container host
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
become: true
|
||||
ansible.builtin.copy:
|
||||
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
|
||||
owner: "{{ gitea_runner_state.stat.pw_name }}"
|
||||
group: "{{ gitea_runner_state.stat.gr_name }}"
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
ansible.builtin.group:
|
||||
name: "{{ gitea_runner_group }}"
|
||||
system: true
|
||||
register: __gitea_runner_group_account
|
||||
tags: [gitea_runner, prereqs, always]
|
||||
|
||||
- name: Ensure runner user exists
|
||||
@@ -16,6 +17,7 @@
|
||||
home: "{{ gitea_runner_home }}"
|
||||
create_home: true
|
||||
system: true
|
||||
register: __gitea_runner_user_account
|
||||
tags: [gitea_runner, prereqs, always]
|
||||
|
||||
- name: Check if runner is installed
|
||||
|
||||
@@ -54,7 +54,8 @@
|
||||
The runner was not stopped and still runs {{ gitea_runner_installed_version }}.
|
||||
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
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino._binary_update
|
||||
@@ -66,6 +67,7 @@
|
||||
_binary_update_staged_path: "{{ gitea_runner_staged_binary }}"
|
||||
_binary_update_version_command: ["{{ gitea_runner_install_dir }}/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]
|
||||
|
||||
always:
|
||||
|
||||
@@ -57,7 +57,7 @@ None. The role does not tag its tasks, so only a play-level tag applies.
|
||||
|
||||
## 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:
|
||||
|
||||
@@ -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.
|
||||
- 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.
|
||||
- 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.
|
||||
@@ -29,13 +29,16 @@ verifier:
|
||||
scenario:
|
||||
# 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.
|
||||
# A check runs before the converge (fresh host) and after it (configured host).
|
||||
test_sequence:
|
||||
- dependency
|
||||
- cleanup
|
||||
- syntax
|
||||
- create
|
||||
- prepare
|
||||
- check
|
||||
- converge
|
||||
- check
|
||||
- idempotence
|
||||
- side_effect
|
||||
- verify
|
||||
|
||||
@@ -4,9 +4,7 @@ Installs [Pi-hole](https://pi-hole.net) v6 by cloning the upstream repository an
|
||||
|
||||
## 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.
|
||||
|
||||
Untested platforms: Ubuntu 26.04 (resolute). The apt dependencies exist there, but the scenario does not run on it yet.
|
||||
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.
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ galaxy_info:
|
||||
- name: Ubuntu
|
||||
versions:
|
||||
- noble
|
||||
- resolute
|
||||
galaxy_tags:
|
||||
- pihole
|
||||
- dns
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
---
|
||||
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404 image
|
||||
# (MOLECULE_IMAGE, the pin in .gitea/workflows/molecule.yml). Needs outbound network for the apt packages. The upstream
|
||||
# Pi-hole repository is replaced by a local stub whose installer only logs its arguments
|
||||
# (prepare.yml), so 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.
|
||||
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404
|
||||
# (MOLECULE_IMAGE) and molecule-ubuntu2604 (MOLECULE_IMAGE_2604) images, pinned in
|
||||
# .gitea/workflows/molecule.yml. Needs outbound network for the apt packages. The upstream Pi-hole
|
||||
# repository is replaced by a local stub whose installer only logs its arguments (prepare.yml), so
|
||||
# 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:
|
||||
name: docker
|
||||
platforms:
|
||||
@@ -22,6 +23,21 @@ platforms:
|
||||
- /run/lock
|
||||
security_opts:
|
||||
- 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:
|
||||
name: ansible
|
||||
# One source for every play, so the converge and the negative tests in verify.yml start from
|
||||
@@ -47,7 +63,7 @@ verifier:
|
||||
scenario:
|
||||
# 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),
|
||||
# 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:
|
||||
- dependency
|
||||
- cleanup
|
||||
@@ -56,8 +72,8 @@ scenario:
|
||||
- prepare
|
||||
- check
|
||||
- converge
|
||||
- idempotence
|
||||
- check
|
||||
- idempotence
|
||||
- side_effect
|
||||
- verify
|
||||
- cleanup
|
||||
@@ -98,8 +98,8 @@
|
||||
- name: The user is a system account without a login shell
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- getent_passwd.pihole[5] == '/usr/sbin/nologin'
|
||||
- getent_passwd.pihole[1] | int < 1000
|
||||
- ansible_facts['getent_passwd'].pihole[5] == '/usr/sbin/nologin'
|
||||
- ansible_facts['getent_passwd'].pihole[1] | int < 1000
|
||||
quiet: true
|
||||
|
||||
# Neither check run (before and after the converge) ran the installer or the handler.
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
# pve_lxc
|
||||
|
||||
Creates and maintains a Proxmox VE LXC container through the Proxmox API: configuration, root disk size, raw `lxc.*` config lines, an opt-in guest firewall file and the power state. Variables and their types are defined in [`meta/argument_specs.yml`](meta/argument_specs.yml), which is the source of truth.
|
||||
|
||||
## Supported platforms
|
||||
|
||||
Proxmox VE nodes on Debian 13 (trixie). The play runs for the container's inventory host: the API calls run on the controller (`delegate_to: localhost`), and the raw config, the guest firewall file and the filesystem resize run on the Proxmox node (`delegate_to: pve_lxc_node`) with become.
|
||||
|
||||
Untested platforms: Debian trixie, as declared in `meta/main.yml`. The molecule scenario runs the node-side tasks in an Ubuntu 24.04 (noble) container standing in for the node (see [Tests](#tests)); a Debian test image does not exist yet.
|
||||
|
||||
The role targets Proxmox nodes only, so it does not cover Ubuntu noble or resolute: Proxmox VE runs on Debian.
|
||||
|
||||
## Requirements and run order
|
||||
|
||||
- Use it by its fully qualified name, `mortis.kamino.pve_lxc`, in a play over the container hosts. It gathers no facts and needs none.
|
||||
- The controller needs the `community.proxmox` collection and the Python library `proxmoxer`.
|
||||
- Role dependencies: none.
|
||||
- `pve_lxc_node` must be an inventory host: the node-side tasks are delegated to it, and its `ansible_host` is the default API address. `pve_lxc_api_user` and `pve_lxc_api_token_secret` have no usable default and are asserted non-empty before any change when `pve_lxc_manage_lifecycle` is true; `pve_lxc_net_prefix` too, unless `pve_lxc_state` is `absent`. The raw config and firewall inputs are validated at the same point.
|
||||
- The container's own `ansible_host` is its address in `net0` and the target of the SSH wait, and `inventory_hostname` is its hostname.
|
||||
- Run it before any role that configures the inside of the container. Gate those on `pve_lxc_present` (below), so a container that is absent is not configured.
|
||||
|
||||
## Role variables
|
||||
|
||||
No variable is marked required in the argument spec: with `pve_lxc_manage_lifecycle: false` the role reads none of the Proxmox inputs.
|
||||
|
||||
| Variable | Default | Description |
|
||||
|---|---|---|
|
||||
| `pve_lxc_state` | `present` | `present`, `started`, `stopped` or `absent`. `present` leaves the power state alone. |
|
||||
| `pve_lxc_manage_lifecycle` | `true` | False skips everything and treats the container as present (a container on a node Ansible does not manage). |
|
||||
| `pve_lxc_allow_destroy` | `false` | Required before `absent` deletes the container. |
|
||||
| `pve_lxc_wait_for_ssh` | `true` | Wait for SSH on port 22 of `ansible_host` when `started`. |
|
||||
| `pve_lxc_manage_disk` | `false` | Grow the root disk to the size in `pve_lxc_disk`. |
|
||||
| `pve_lxc_reboot_if_required` | `true` | Restart the container after its root filesystem was grown. |
|
||||
| `pve_lxc_pubkey` | `""` | Public keys for root, one per line. |
|
||||
| `pve_lxc_features` | `[]` | Container features, for example `nesting=1`. Omitted when empty. |
|
||||
| `pve_lxc_restart_on_config_change` | `false` | Restart after a configuration update reports a change. |
|
||||
| `pve_lxc_cmode` | `tty` | Console mode sent on update. |
|
||||
| `pve_lxc_raw_config` | `[]` | Raw `lxc.*` lines, one per item. See Notes. |
|
||||
| `pve_lxc_onboot` | `true` | Start on node boot, for `started` and `present`. A `stopped` container always gets `onboot=0`. |
|
||||
| `pve_lxc_node`, `pve_lxc_vmid` | none | Inventory name of the Proxmox node and container id. |
|
||||
| `pve_lxc_ostemplate` | none | Template volume, for example `local:vztmpl/<template>.tar.zst`. Read on creation only. |
|
||||
| `pve_lxc_disk` | none | Root disk as `<storage>:<size in GB>`. |
|
||||
| `pve_lxc_memory` | none | Memory in MB. |
|
||||
| `pve_lxc_cores`, `pve_lxc_swap`, `pve_lxc_nameserver` | none | Omitted when undefined. |
|
||||
| `pve_lxc_net` | none | Mapping with `bridge`, `gw` and `tag`, used to build `net0`. |
|
||||
| `pve_lxc_net_interface` | `eth0` | Interface name in `net0`. |
|
||||
| `pve_lxc_net_prefix` | `""` (asserted) | Prefix length (1 to 32) of `ansible_host` in `net0`. Environment-specific, so it has no real default. |
|
||||
| `pve_lxc_api_user` | `""` (asserted) | API user without realm; `@<pve_lxc_api_realm>` is appended. |
|
||||
| `pve_lxc_api_realm` | `pam` | Realm of the API user. |
|
||||
| `pve_lxc_api_token_id` | `<pve_lxc_api_user>-token` | API token id. |
|
||||
| `pve_lxc_api_token_secret` | none (asserted) | API token secret, normally vaulted. No default. `no_log`. |
|
||||
| `pve_lxc_api_host` | `ansible_host` of `pve_lxc_node`, empty without it | Proxmox API address (port 8006). |
|
||||
| `pve_lxc_firewall` | `false` | Opt-in guest firewall: `firewall=1` on `net0` and `/etc/pve/firewall/<vmid>.fw`. See Notes. |
|
||||
| `pve_lxc_firewall_policy_in`, `pve_lxc_firewall_policy_out` | `DROP` | Policy for unmatched traffic: `ACCEPT`, `DROP` or `REJECT`. |
|
||||
| `pve_lxc_firewall_rules` | `[]` | Proxmox rule lines, in order, first match wins, each starting with `IN` or `OUT` and `ACCEPT`, `DROP` or `REJECT`. |
|
||||
|
||||
The `pve_lxc_api_*` inputs are applied through `module_defaults` inside the block that holds every API call of the role, and the `uri` calls send the header `PVEAPIToken=<user>@<realm>!<token_id>=<secret>`, derived in `vars/main.yml`.
|
||||
|
||||
## Variables set by the role
|
||||
|
||||
- `pve_lxc_exists`: the container exists on the node.
|
||||
- `pve_lxc_present`: the container exists and `pve_lxc_state` is not `absent`. With `pve_lxc_manage_lifecycle: false` both are `true`.
|
||||
|
||||
## Tags
|
||||
|
||||
The input validation (`tasks/validate.yml`) carries `always`, so it runs whatever tags are selected. No other task is tagged, so only a play-level tag applies to them.
|
||||
|
||||
## Example play
|
||||
|
||||
```yaml
|
||||
- name: Provision containers
|
||||
hosts: containers
|
||||
gather_facts: false
|
||||
roles:
|
||||
- role: mortis.kamino.pve_lxc
|
||||
vars:
|
||||
pve_lxc_state: started
|
||||
pve_lxc_node: pve1
|
||||
pve_lxc_vmid: 120
|
||||
pve_lxc_ostemplate: local:vztmpl/ubuntu-24.04-standard_24.04-2_amd64.tar.zst
|
||||
pve_lxc_disk: local-lvm:8
|
||||
pve_lxc_memory: 1024
|
||||
pve_lxc_net:
|
||||
bridge: vmbr0
|
||||
gw: 192.0.2.1
|
||||
tag: 20
|
||||
pve_lxc_net_prefix: 24
|
||||
pve_lxc_manage_disk: true
|
||||
pve_lxc_api_user: ansible
|
||||
pve_lxc_api_token_secret: "{{ vault_pve_api_token_secret }}"
|
||||
```
|
||||
|
||||
## 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 (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
|
||||
|
||||
- Idempotent: yes for the node-side files, which the scenario checks; the API update relies on `community.proxmox` reporting no change, which is not tested.
|
||||
- Check mode: `--check` is the supported preview; a play-level `check_mode: true` is not supported. Under `--check` the creation is skipped, so a container that does not exist yet is not updated or configured in that run; `pve_lxc_raw_config` is still validated.
|
||||
- Raw config: `pve_lxc_raw_config` owns the whole `lxc.*` namespace of the main section of `/etc/pve/lxc/<vmid>.conf`. Other `lxc.*` lines, including hand-written ones, are removed, and an empty list removes them all. Each item must be one line starting with `lxc.`. Order counts. Snapshot sections are never edited. A change restarts the container unless `pve_lxc_state` is `stopped`, independent of `pve_lxc_restart_on_config_change`. Ansible backup copies of the file (`<vmid>.conf.*~`) are removed.
|
||||
- Disk: the disk only grows. When `pve_lxc_manage_disk` is true and `pve_lxc_disk` is larger, the role resizes through the API, fails if Proxmox did not apply it, runs `pct resize` on the node and restarts the container when `pve_lxc_reboot_if_required` is true.
|
||||
- `net0` is `name=<pve_lxc_net_interface>,bridge=<bridge>,ip=<ansible_host>/<pve_lxc_net_prefix>,gw=<gw>,tag=<tag>`, plus `,firewall=1` only when `pve_lxc_firewall` is true.
|
||||
- The container is created without a root password: root gets only `pve_lxc_pubkey`.
|
||||
- Guest firewall: for a container whose root cannot be trusted, a firewall inside it is useless, so the Proxmox firewall on the node filters its `net0`. With `pve_lxc_firewall: true` the role writes `/etc/pve/firewall/<vmid>.fw` on the node before the container is created (`pve-firewall` reloads it by itself) with `enable: 1`, `ipfilter: 1` (the container cannot use another address than its `net0` one), `macfilter: 1`, the two policies and the rules. False leaves `net0` and the firewall files untouched; a file written earlier stays but is inert, since the NIC loses its firewall flag. Proxmox skips a rule line it cannot parse, so the role only checks each line's shape; prove the syntax with `pve-firewall compile` on the node.
|
||||
- The guest rules filter only while the datacenter firewall is enabled (`/etc/pve/firewall/cluster.fw`, `enable: 1`), which the role does not manage. Enabling it with Proxmox's defaults sets the nodes' input policy to DROP and allows only SSH and port 8006 from the cluster network, which can lock out the controller. A way to enable it with host traffic unfiltered: keep a node console open; on every node create `/etc/pve/nodes/<node>/host.fw` with `[OPTIONS]` and `enable: 0`; then create `cluster.fw` with `[OPTIONS]`, `enable: 1`, `policy_in: ACCEPT`, `policy_out: ACCEPT`. Check `pve-firewall status` on each node. Enabling it also sends bridged traffic of guests without a firewall through the `PVEFW-FORWARD` chain, which drops conntrack-invalid packets. Roll back with `enable: 0` in `cluster.fw`.
|
||||
- TLS certificates of the API are not verified.
|
||||
- `no_log` is set on every task that carries the API token.
|
||||
@@ -0,0 +1,53 @@
|
||||
---
|
||||
pve_lxc_state: present # present | started | stopped | absent
|
||||
pve_lxc_manage_disk: false # disk resizing is explicit
|
||||
pve_lxc_wait_for_ssh: true
|
||||
pve_lxc_allow_destroy: false
|
||||
# false = the LXC lives on a Proxmox node Ansible does not manage; skip the
|
||||
# lifecycle tasks and treat the guest as present so it is still configured.
|
||||
pve_lxc_manage_lifecycle: true
|
||||
pve_lxc_onboot: true
|
||||
# Restart the container after its root filesystem was grown.
|
||||
pve_lxc_reboot_if_required: true
|
||||
|
||||
pve_lxc_pubkey: ""
|
||||
|
||||
# e.g. ["nesting=1", "keyctl=1"] to allow Docker/nested containers inside
|
||||
# an unprivileged LXC. See https://pve.proxmox.com/wiki/Linux_Container#pct_options.
|
||||
pve_lxc_features: []
|
||||
|
||||
# Proxmox applies some changes (features) only on the next start. Off by default, so routine
|
||||
# config drift (netif, nameserver ...) does not restart guests.
|
||||
pve_lxc_restart_on_config_change: false
|
||||
|
||||
pve_lxc_raw_config: []
|
||||
|
||||
# Console mode sent on update (tasks/update.yml says why it is sent explicitly).
|
||||
pve_lxc_cmode: tty
|
||||
|
||||
# Proxmox API credentials. Only read when the LXC lifecycle is managed
|
||||
# (pve_lxc_manage_lifecycle true); tasks/validate.yml then asserts that the user and
|
||||
# the token secret are set. The user is the bare name: the role appends
|
||||
# @<pve_lxc_api_realm>. The token secret, pve_lxc_api_token_secret, is a secret
|
||||
# input with no default, normally vaulted.
|
||||
pve_lxc_api_user: ""
|
||||
pve_lxc_api_realm: pam
|
||||
pve_lxc_api_token_id: "{{ pve_lxc_api_user }}-token"
|
||||
# The Proxmox node's address. Guarded so the default templates to '' (and the
|
||||
# argument validation passes) on a host without pve_lxc_node.
|
||||
pve_lxc_api_host: "{{ hostvars[pve_lxc_node].ansible_host if pve_lxc_node is defined else '' }}"
|
||||
|
||||
# Container network interface name.
|
||||
pve_lxc_net_interface: eth0
|
||||
# Prefix length of ansible_host in net0. Environment-specific, so there is no
|
||||
# real default: empty here, asserted in tasks/validate.yml.
|
||||
pve_lxc_net_prefix: ""
|
||||
|
||||
# Proxmox guest firewall on net0, opt-in. Off: net0 carries no firewall flag
|
||||
# and no /etc/pve/firewall/<vmid>.fw is written, so other containers are unchanged.
|
||||
# The rules only filter while the datacenter firewall is enabled (README).
|
||||
pve_lxc_firewall: false
|
||||
pve_lxc_firewall_policy_in: DROP
|
||||
pve_lxc_firewall_policy_out: DROP
|
||||
# Proxmox rule lines, evaluated in order, e.g. "IN ACCEPT -source 192.0.2.5 -p tcp -dport 22".
|
||||
pve_lxc_firewall_rules: []
|
||||
@@ -0,0 +1,227 @@
|
||||
---
|
||||
argument_specs:
|
||||
main:
|
||||
short_description: Manage a Proxmox LXC container
|
||||
description:
|
||||
- >-
|
||||
Detects the container through the Proxmox API, validates C(pve_lxc_raw_config), deletes the container when C(pve_lxc_state)
|
||||
is absent and C(pve_lxc_allow_destroy) is true, otherwise creates it when missing, updates its configuration and disk,
|
||||
reconciles the raw C(lxc.*) lines in C(/etc/pve/lxc/<vmid>.conf), applies the power state and waits for SSH when
|
||||
the container is started.
|
||||
- >-
|
||||
When C(pve_lxc_manage_lifecycle) is false the role only sets C(pve_lxc_exists) and C(pve_lxc_present) to true and does nothing
|
||||
else, so none of the Proxmox inputs below is read. This is how a container on a node Ansible does not manage is
|
||||
handled.
|
||||
- >-
|
||||
API calls run on localhost and authenticate with C(pve_lxc_api_user) (bare user name, C(@<pve_lxc_api_realm>) is
|
||||
appended), C(pve_lxc_api_token_id), C(pve_lxc_api_token_secret) and C(pve_lxc_api_host), applied through
|
||||
C(module_defaults), and with the header C(PVEAPIToken=<user>@<realm>!<token_id>=<secret>) for the C(uri) calls,
|
||||
which the role derives from them in C(vars/main.yml) (internal, not an input).
|
||||
The user and the token secret have no usable default: they are asserted non-empty in the input validation,
|
||||
only for a container with C(pve_lxc_manage_lifecycle) true. The caller sets them.
|
||||
The raw config, disk filesystem resize and the C(pct) call are delegated to C(pve_lxc_node) with become.
|
||||
C(community.proxmox) and, on the controller, the Python library C(proxmoxer) must be installed. TLS certificates
|
||||
are not verified.
|
||||
- >-
|
||||
Also reads C(ansible_host) (container address and SSH wait), C(inventory_hostname) (container hostname) and
|
||||
C(ansible_check_mode). The role sets the facts C(pve_lxc_exists) and C(pve_lxc_present) for later plays. C(pve_lxc_present) is
|
||||
true only while the container exists and C(pve_lxc_state) is not absent.
|
||||
options:
|
||||
pve_lxc_state:
|
||||
type: str
|
||||
default: present
|
||||
choices: [present, started, stopped, absent]
|
||||
description:
|
||||
- >-
|
||||
C(present) keeps the container configured without touching its power state. C(started) and C(stopped) also
|
||||
apply the power state, and C(started) additionally waits for SSH when C(pve_lxc_wait_for_ssh) is true. C(absent)
|
||||
deletes the container, but only when C(pve_lxc_allow_destroy) is true.
|
||||
pve_lxc_manage_lifecycle:
|
||||
type: bool
|
||||
default: true
|
||||
description:
|
||||
- >-
|
||||
When false the container is treated as present and every lifecycle task is skipped. Set it for containers on
|
||||
a node Ansible does not manage.
|
||||
pve_lxc_allow_destroy:
|
||||
type: bool
|
||||
default: false
|
||||
description:
|
||||
- Safety switch required before C(pve_lxc_state=absent) deletes the container.
|
||||
pve_lxc_wait_for_ssh:
|
||||
type: bool
|
||||
default: true
|
||||
description:
|
||||
- When true and C(pve_lxc_state) is started, wait for SSH on port 22 of C(ansible_host).
|
||||
pve_lxc_manage_disk:
|
||||
type: bool
|
||||
default: false
|
||||
description:
|
||||
- >-
|
||||
Allow the root disk to be grown to the size in C(pve_lxc_disk). Growing fails the play when Proxmox does not apply it,
|
||||
and runs C(pct resize) on C(pve_lxc_node).
|
||||
pve_lxc_pubkey:
|
||||
type: str
|
||||
default: ""
|
||||
description:
|
||||
- Public keys installed for root by the container creation and update, one per line.
|
||||
pve_lxc_features:
|
||||
type: list
|
||||
elements: str
|
||||
default: []
|
||||
description:
|
||||
- >-
|
||||
Proxmox container features such as C(nesting=1) or C(keyctl=1). Omitted when empty. Proxmox applies a change
|
||||
only on the next start, and lets an API user other than C(root@pam) change only some of them, such as
|
||||
C(nesting).
|
||||
pve_lxc_restart_on_config_change:
|
||||
type: bool
|
||||
default: false
|
||||
description:
|
||||
- Restart the container when the configuration update reports a change. Off by default so routine drift does not restart guests.
|
||||
pve_lxc_cmode:
|
||||
type: str
|
||||
default: tty
|
||||
description:
|
||||
- Console mode sent on update. Sent explicitly because community.proxmox 2.0.0 otherwise forwarded a value Proxmox rejects.
|
||||
pve_lxc_raw_config:
|
||||
type: raw
|
||||
default: []
|
||||
description:
|
||||
- >-
|
||||
Raw C(lxc.*) lines for the container config, one per list item, each a single line starting with C(lxc.).
|
||||
The role default is an empty list. Anything that is not a list of such strings fails the play, except an empty
|
||||
or null value, which is treated as an empty list and removes every C(lxc.*) line that is present. The
|
||||
validation also runs in check mode on a container that does not exist yet. A change restarts the container (outside
|
||||
check mode, unless C(pve_lxc_state) is stopped), independent of C(pve_lxc_restart_on_config_change).
|
||||
pve_lxc_onboot:
|
||||
type: bool
|
||||
default: true
|
||||
description:
|
||||
- >-
|
||||
Start the container when the node boots, for a container whose C(pve_lxc_state) is C(started) or C(present).
|
||||
A C(stopped) container always gets C(onboot=0), whatever this says, so a node reboot does not start it.
|
||||
Sent on create and on update.
|
||||
pve_lxc_reboot_if_required:
|
||||
type: bool
|
||||
default: true
|
||||
description:
|
||||
- Restart the container after its root filesystem was grown.
|
||||
pve_lxc_node:
|
||||
type: str
|
||||
description:
|
||||
- >-
|
||||
Inventory name of the Proxmox host that runs the container. Must be a host in the inventory; its
|
||||
C(ansible_host) is the default of C(pve_lxc_api_host). Not read when C(pve_lxc_manage_lifecycle) is false.
|
||||
pve_lxc_vmid:
|
||||
type: int
|
||||
description:
|
||||
- Container id on the Proxmox node. Not read when C(pve_lxc_manage_lifecycle) is false.
|
||||
pve_lxc_ostemplate:
|
||||
type: str
|
||||
description:
|
||||
- Template volume the container is created from, for example C(local:vztmpl/<template>.tar.zst). Only read on creation.
|
||||
pve_lxc_disk:
|
||||
type: raw
|
||||
description:
|
||||
- >-
|
||||
Root disk as C(<storage>:<size in GB>), for example C(local-lvm:8). The number after the last colon is the
|
||||
desired size in GB. Only read on creation, on update and for disk detection.
|
||||
pve_lxc_memory:
|
||||
type: raw
|
||||
description:
|
||||
- Memory in MB. Read on creation and on update.
|
||||
pve_lxc_cores:
|
||||
type: raw
|
||||
description:
|
||||
- CPU cores. Omitted when undefined.
|
||||
pve_lxc_swap:
|
||||
type: raw
|
||||
description:
|
||||
- Swap in MB. Omitted when undefined.
|
||||
pve_lxc_nameserver:
|
||||
type: str
|
||||
description:
|
||||
- Nameserver for the container. Omitted when undefined.
|
||||
pve_lxc_net:
|
||||
type: raw
|
||||
description:
|
||||
- >-
|
||||
Mapping with C(bridge), C(gw) and C(tag). The role builds C(net0) from it as
|
||||
C(name=<pve_lxc_net_interface>,bridge=<bridge>,ip=<ansible_host>/<pve_lxc_net_prefix>,gw=<gw>,tag=<tag>),
|
||||
plus C(,firewall=1) when C(pve_lxc_firewall) is true.
|
||||
pve_lxc_firewall:
|
||||
type: bool
|
||||
default: false
|
||||
description:
|
||||
- >-
|
||||
Opt-in Proxmox guest firewall. When true, C(firewall=1) is appended to C(net0) and
|
||||
C(/etc/pve/firewall/<vmid>.fw) is written on C(pve_lxc_node) before the container is created, with
|
||||
C(enable), C(ipfilter) and C(macfilter) on, the two policies and C(pve_lxc_firewall_rules). When false
|
||||
neither is touched, so C(net0) is unchanged; a file written earlier is left in place but inert, since
|
||||
the NIC no longer has the firewall flag. The rules only filter while the datacenter firewall is enabled.
|
||||
pve_lxc_firewall_policy_in:
|
||||
type: str
|
||||
default: DROP
|
||||
choices: [ACCEPT, DROP, REJECT]
|
||||
description:
|
||||
- Policy for inbound traffic that no rule matches.
|
||||
pve_lxc_firewall_policy_out:
|
||||
type: str
|
||||
default: DROP
|
||||
choices: [ACCEPT, DROP, REJECT]
|
||||
description:
|
||||
- Policy for outbound traffic that no rule matches.
|
||||
pve_lxc_firewall_rules:
|
||||
type: list
|
||||
elements: str
|
||||
default: []
|
||||
description:
|
||||
- >-
|
||||
Proxmox firewall rule lines, evaluated in order, first match wins, each a single line starting with
|
||||
C(IN) or C(OUT) and C(ACCEPT), C(DROP) or C(REJECT), for example C(IN ACCEPT -source 192.0.2.5 -p tcp -dport 22).
|
||||
Only the shape is checked; Proxmox skips a line it cannot parse.
|
||||
pve_lxc_api_user:
|
||||
type: str
|
||||
default: ""
|
||||
description:
|
||||
- >-
|
||||
Proxmox API user, the bare name without realm (C(@<pve_lxc_api_realm>) is appended). Required when
|
||||
C(pve_lxc_manage_lifecycle) is true: the role asserts it is non-empty before any change.
|
||||
pve_lxc_api_realm:
|
||||
type: str
|
||||
default: pam
|
||||
description:
|
||||
- Authentication realm of C(pve_lxc_api_user), appended as C(@<realm>) in C(module_defaults) and in the C(uri) header.
|
||||
pve_lxc_api_token_id:
|
||||
type: str
|
||||
description:
|
||||
- >-
|
||||
API token id, without the user part. Role default C(<pve_lxc_api_user>-token), a Jinja expression in
|
||||
C(defaults/main.yml), so it is not repeated here.
|
||||
pve_lxc_api_token_secret:
|
||||
type: str
|
||||
no_log: true
|
||||
description:
|
||||
- >-
|
||||
API token secret, normally vaulted. No default. Required when C(pve_lxc_manage_lifecycle) is true: the role
|
||||
asserts it is set and non-empty before any change. Every task that carries it is C(no_log).
|
||||
pve_lxc_api_host:
|
||||
type: str
|
||||
description:
|
||||
- >-
|
||||
Address of the Proxmox API (port 8006). Role default the C(ansible_host) of C(pve_lxc_node), or empty when
|
||||
C(pve_lxc_node) is undefined; a Jinja expression in C(defaults/main.yml), so it is not repeated here.
|
||||
pve_lxc_net_interface:
|
||||
type: str
|
||||
default: eth0
|
||||
description:
|
||||
- Name of the container network interface in C(net0).
|
||||
pve_lxc_net_prefix:
|
||||
type: raw
|
||||
default: ""
|
||||
description:
|
||||
- >-
|
||||
Prefix length (1 to 32) appended to C(ansible_host) in C(net0). Environment-specific, so the empty default
|
||||
is a placeholder: the role fails with a clear message while it is unset and the LXC lifecycle is managed
|
||||
with C(pve_lxc_state) other than C(absent).
|
||||
@@ -0,0 +1,18 @@
|
||||
---
|
||||
galaxy_info:
|
||||
role_name: pve_lxc
|
||||
namespace: mortis
|
||||
author: Defame1297
|
||||
license: GPL-3.0-or-later
|
||||
description: Manage Proxmox VE LXC containers through the Proxmox API, with raw lxc.* config lines and a guest firewall file on the node.
|
||||
min_ansible_version: "2.22"
|
||||
platforms:
|
||||
- name: Debian
|
||||
versions:
|
||||
- trixie
|
||||
galaxy_tags:
|
||||
- proxmox
|
||||
- lxc
|
||||
- container
|
||||
- provisioning
|
||||
dependencies: []
|
||||
@@ -0,0 +1,21 @@
|
||||
---
|
||||
# The validation and the node-side task files only, in main.yml's order: main.yml would also call the
|
||||
# Proxmox API to detect the container, which the scenario does not exercise (README, Tests).
|
||||
- name: Converge
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: Validate the inputs
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.pve_lxc
|
||||
tasks_from: validate
|
||||
|
||||
- name: Write the guest firewall file
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.pve_lxc
|
||||
tasks_from: firewall
|
||||
|
||||
- name: Reconcile the raw config lines
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.pve_lxc
|
||||
tasks_from: raw_config
|
||||
@@ -0,0 +1,73 @@
|
||||
---
|
||||
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404 image
|
||||
# (MOLECULE_IMAGE, the pin in .gitea/workflows/molecule.yml). The container stands in for the
|
||||
# Proxmox node: the role's node-side task files (raw config reconcile, guest firewall file) and
|
||||
# its input validation run against it. Nothing calls the Proxmox API (README, Tests).
|
||||
# The container runs systemd as PID 1 with a writable cgroup; no privileged mode.
|
||||
driver:
|
||||
name: docker
|
||||
platforms:
|
||||
- name: ${KAMINO_RUN_ID:-local}-pve-lxc-instance
|
||||
labels:
|
||||
net.rkdr.mortis.molecule-run: "${KAMINO_RUN_ID:-local}"
|
||||
image: ${MOLECULE_IMAGE}
|
||||
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:
|
||||
name: ansible
|
||||
# One source for every play, so the converge and the negative tests in verify.yml start from
|
||||
# the same valid input.
|
||||
inventory:
|
||||
group_vars:
|
||||
all:
|
||||
pve_lxc_node: "{{ inventory_hostname }}"
|
||||
pve_lxc_vmid: 9100
|
||||
# The docker connection sets no ansible_host, from which the role defaults the API address;
|
||||
# argument validation templates that default, so main would fail on it instead.
|
||||
pve_lxc_api_host: 192.0.2.1
|
||||
# Valid inputs for validate.yml; a negative case empties the one under test.
|
||||
pve_lxc_api_user: molecule
|
||||
pve_lxc_api_token_secret: not-a-secret
|
||||
pve_lxc_net_prefix: 24
|
||||
# stopped: the role never restarts a stopped container, so the raw config change makes
|
||||
# no API call.
|
||||
pve_lxc_state: stopped
|
||||
pve_lxc_raw_config:
|
||||
- "lxc.cgroup2.devices.allow: c 226:0 rwm"
|
||||
- "lxc.mount.entry: /dev/dri dev/dri none bind,optional,create=dir 0 0"
|
||||
- "lxc.mount.entry: /srv/data srv/data none bind,create=dir 0 0"
|
||||
pve_lxc_firewall: true
|
||||
# not the defaults, so verify proves the variables reach the file
|
||||
pve_lxc_firewall_policy_in: REJECT
|
||||
pve_lxc_firewall_policy_out: ACCEPT
|
||||
pve_lxc_firewall_rules:
|
||||
- IN ACCEPT -source 192.0.2.10 -p tcp -dport 22
|
||||
- OUT DROP -dest 198.51.100.0/24
|
||||
verifier:
|
||||
name: ansible
|
||||
scenario:
|
||||
# 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),
|
||||
# plus a check before the converge (fresh host) and one after it (configured host).
|
||||
test_sequence:
|
||||
- dependency
|
||||
- cleanup
|
||||
- syntax
|
||||
- create
|
||||
- prepare
|
||||
- check
|
||||
- converge
|
||||
- check
|
||||
- idempotence
|
||||
- side_effect
|
||||
- verify
|
||||
- cleanup
|
||||
@@ -0,0 +1,46 @@
|
||||
---
|
||||
# Seeds the node-side files the converge reconciles: a container config with stale lxc.* lines,
|
||||
# blockinfile markers of an earlier block and a snapshot section, plus backup copies of this
|
||||
# container's config and of another one's.
|
||||
- name: Prepare
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: Create the Proxmox config directories
|
||||
ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
mode: "0755"
|
||||
loop:
|
||||
- /etc/pve/lxc
|
||||
- /etc/pve/firewall
|
||||
|
||||
- name: Seed the container config
|
||||
ansible.builtin.copy:
|
||||
dest: /etc/pve/lxc/9100.conf
|
||||
mode: "0640"
|
||||
content: |
|
||||
#molecule test container
|
||||
arch: amd64
|
||||
cores: 1
|
||||
lxc.cgroup2.devices.allow: c 10:200 rwm
|
||||
# BEGIN ANSIBLE MANAGED BLOCK (lxc_raw_config)
|
||||
lxc.mount.entry: /srv/old srv/old none bind,create=dir 0 0
|
||||
# END ANSIBLE MANAGED BLOCK (lxc_raw_config)
|
||||
memory: 512
|
||||
net0: name=eth0,bridge=vmbr0,ip=192.0.2.20/24,gw=192.0.2.1
|
||||
rootfs: local-lvm:vm-9100-disk-0,size=8G
|
||||
|
||||
[before-upgrade]
|
||||
arch: amd64
|
||||
lxc.mount.entry: /srv/snap srv/snap none bind,create=dir 0 0
|
||||
memory: 512
|
||||
|
||||
- name: Seed backup copies of two container configs
|
||||
ansible.builtin.copy:
|
||||
dest: "/etc/pve/lxc/{{ item }}"
|
||||
mode: "0640"
|
||||
content: "stale\n"
|
||||
loop:
|
||||
- "9100.conf.1234.2026-01-01@00:00:00~"
|
||||
- "9101.conf.1234.2026-01-01@00:00:00~"
|
||||
@@ -0,0 +1,22 @@
|
||||
---
|
||||
# One failing run: includes the role's task file named by the case, with the inputs the caller
|
||||
# sets on the include, and asserts that the expected message, not something else, stopped it.
|
||||
# Input: pve_lxc_test_case (name, tasks_from, expect).
|
||||
- name: "Run the role, case {{ pve_lxc_test_case.name }}"
|
||||
block:
|
||||
- name: "Include the role, case {{ pve_lxc_test_case.name }}"
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.pve_lxc
|
||||
tasks_from: "{{ pve_lxc_test_case.tasks_from }}"
|
||||
|
||||
# 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.
|
||||
- name: "Fail because the include returned, case {{ pve_lxc_test_case.name }}"
|
||||
ansible.builtin.fail:
|
||||
msg: The role accepted the input
|
||||
rescue:
|
||||
- name: "The expected failure stopped the run, case {{ pve_lxc_test_case.name }}"
|
||||
ansible.builtin.assert:
|
||||
that: pve_lxc_test_case.expect in (ansible_failed_result.msg | default(''))
|
||||
fail_msg: "Expected '{{ pve_lxc_test_case.expect }}', got: {{ ansible_failed_result.msg | default('') }}"
|
||||
quiet: true
|
||||
@@ -0,0 +1,175 @@
|
||||
---
|
||||
# The refusal cases run first: each fails before any change, so the file assertions after them
|
||||
# also show the node unchanged by them.
|
||||
- name: Refuse invalid input
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: Refuse a state outside the argument spec choices
|
||||
ansible.builtin.include_tasks: tasks/failed_run.yml
|
||||
vars:
|
||||
pve_lxc_state: running
|
||||
pve_lxc_test_case:
|
||||
name: state-choice
|
||||
tasks_from: main
|
||||
expect: pve_lxc_state must be one of
|
||||
|
||||
- name: Refuse a managed lifecycle without API credentials
|
||||
ansible.builtin.include_tasks: tasks/failed_run.yml
|
||||
vars:
|
||||
pve_lxc_api_user: ""
|
||||
pve_lxc_test_case:
|
||||
name: no-credentials
|
||||
tasks_from: main
|
||||
expect: The Proxmox API calls need pve_lxc_api_user
|
||||
|
||||
- name: Refuse a managed lifecycle without an API token secret
|
||||
ansible.builtin.include_tasks: tasks/failed_run.yml
|
||||
vars:
|
||||
pve_lxc_api_token_secret: ""
|
||||
pve_lxc_test_case:
|
||||
name: no-token-secret
|
||||
tasks_from: main
|
||||
expect: The Proxmox API calls need pve_lxc_api_user
|
||||
|
||||
- name: Refuse a managed lifecycle without a network prefix
|
||||
ansible.builtin.include_tasks: tasks/failed_run.yml
|
||||
vars:
|
||||
pve_lxc_net_prefix: ""
|
||||
pve_lxc_test_case:
|
||||
name: no-prefix
|
||||
tasks_from: main
|
||||
expect: pve_lxc_net_prefix must be the subnet prefix length
|
||||
|
||||
- name: Refuse raw config given as a string
|
||||
ansible.builtin.include_tasks: tasks/failed_run.yml
|
||||
vars:
|
||||
pve_lxc_raw_config: "lxc.mount.entry: /srv/a srv/a none bind 0 0"
|
||||
pve_lxc_test_case:
|
||||
name: raw-config-string
|
||||
tasks_from: validate
|
||||
expect: pve_lxc_raw_config must be a YAML list of strings
|
||||
|
||||
- name: Refuse a raw config line outside the lxc. namespace
|
||||
ansible.builtin.include_tasks: tasks/failed_run.yml
|
||||
vars:
|
||||
pve_lxc_raw_config:
|
||||
- "memory: 1024"
|
||||
pve_lxc_test_case:
|
||||
name: raw-config-prefix
|
||||
tasks_from: validate
|
||||
expect: "Offending entries: ['memory: 1024']"
|
||||
|
||||
- name: Refuse a raw config item holding two lines
|
||||
ansible.builtin.include_tasks: tasks/failed_run.yml
|
||||
vars:
|
||||
pve_lxc_raw_config:
|
||||
- "lxc.mount.entry: /srv/a srv/a none bind 0 0\nlxc.mount.entry: /srv/b srv/b none bind 0 0"
|
||||
pve_lxc_test_case:
|
||||
name: raw-config-newline
|
||||
tasks_from: validate
|
||||
expect: Offending entries
|
||||
|
||||
- name: Refuse a firewall rule of the wrong shape
|
||||
ansible.builtin.include_tasks: tasks/failed_run.yml
|
||||
vars:
|
||||
pve_lxc_firewall_rules:
|
||||
- ACCEPT IN -p tcp -dport 22
|
||||
pve_lxc_test_case:
|
||||
name: firewall-rule
|
||||
tasks_from: validate
|
||||
expect: single-line Proxmox rules
|
||||
|
||||
- name: Refuse a firewall policy outside ACCEPT, DROP and REJECT
|
||||
ansible.builtin.include_tasks: tasks/failed_run.yml
|
||||
vars:
|
||||
pve_lxc_firewall_policy_in: ALLOW
|
||||
pve_lxc_test_case:
|
||||
name: firewall-policy
|
||||
tasks_from: validate
|
||||
expect: must be ACCEPT, DROP or REJECT
|
||||
|
||||
- name: Treat a container on an unmanaged node as present
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: Run the role with the lifecycle unmanaged
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.pve_lxc
|
||||
vars:
|
||||
pve_lxc_manage_lifecycle: false
|
||||
|
||||
- name: Assert the presence facts
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- pve_lxc_exists
|
||||
- pve_lxc_present
|
||||
quiet: true
|
||||
|
||||
- name: Verify
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
vars:
|
||||
# Proxmox's own lines first, in order, then the desired lxc.* lines, then the snapshot
|
||||
# section byte for byte: no stale lxc.* line and no marker left.
|
||||
pve_lxc_test_expected_config: |
|
||||
#molecule test container
|
||||
arch: amd64
|
||||
cores: 1
|
||||
memory: 512
|
||||
net0: name=eth0,bridge=vmbr0,ip=192.0.2.20/24,gw=192.0.2.1
|
||||
rootfs: local-lvm:vm-9100-disk-0,size=8G
|
||||
|
||||
lxc.cgroup2.devices.allow: c 226:0 rwm
|
||||
lxc.mount.entry: /dev/dri dev/dri none bind,optional,create=dir 0 0
|
||||
lxc.mount.entry: /srv/data srv/data none bind,create=dir 0 0
|
||||
[before-upgrade]
|
||||
arch: amd64
|
||||
lxc.mount.entry: /srv/snap srv/snap none bind,create=dir 0 0
|
||||
memory: 512
|
||||
pve_lxc_test_expected_firewall: |
|
||||
[OPTIONS]
|
||||
enable: 1
|
||||
ipfilter: 1
|
||||
macfilter: 1
|
||||
policy_in: REJECT
|
||||
policy_out: ACCEPT
|
||||
|
||||
[RULES]
|
||||
IN ACCEPT -source 192.0.2.10 -p tcp -dport 22
|
||||
OUT DROP -dest 198.51.100.0/24
|
||||
tasks:
|
||||
- name: Read the container config
|
||||
ansible.builtin.slurp:
|
||||
src: /etc/pve/lxc/9100.conf
|
||||
register: pve_lxc_test_config
|
||||
|
||||
- name: Assert the raw config lines were reconciled
|
||||
ansible.builtin.assert:
|
||||
that: (pve_lxc_test_config.content | b64decode) == pve_lxc_test_expected_config
|
||||
fail_msg: "Unexpected config: {{ pve_lxc_test_config.content | b64decode }}"
|
||||
quiet: true
|
||||
|
||||
- name: Read the guest firewall file
|
||||
ansible.builtin.slurp:
|
||||
src: /etc/pve/firewall/9100.fw
|
||||
register: pve_lxc_test_firewall
|
||||
|
||||
- name: Assert the guest firewall file
|
||||
ansible.builtin.assert:
|
||||
that: (pve_lxc_test_firewall.content | b64decode) == pve_lxc_test_expected_firewall
|
||||
fail_msg: "Unexpected firewall file: {{ pve_lxc_test_firewall.content | b64decode }}"
|
||||
quiet: true
|
||||
|
||||
- name: Find the config backups left
|
||||
ansible.builtin.find:
|
||||
paths: /etc/pve/lxc
|
||||
patterns: "*~"
|
||||
register: pve_lxc_test_backups
|
||||
|
||||
- name: Assert only the other container's backup is left
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- pve_lxc_test_backups.files | map(attribute='path') | map('basename') | list
|
||||
== ['9101.conf.1234.2026-01-01@00:00:00~']
|
||||
quiet: true
|
||||
@@ -0,0 +1,25 @@
|
||||
---
|
||||
- name: Create LXC if it does not exist
|
||||
# No root password: root gets only the keys in pve_lxc_pubkey.
|
||||
no_log: true # defence in depth: the module already masks the API token secret
|
||||
delegate_to: localhost
|
||||
community.proxmox.proxmox:
|
||||
vmid: "{{ pve_lxc_vmid }}"
|
||||
node: "{{ pve_lxc_node }}"
|
||||
hostname: "{{ inventory_hostname }}"
|
||||
ostemplate: "{{ pve_lxc_ostemplate }}"
|
||||
disk: "{{ pve_lxc_disk }}"
|
||||
memory: "{{ pve_lxc_memory }}"
|
||||
cores: "{{ pve_lxc_cores | default(omit) }}"
|
||||
swap: "{{ pve_lxc_swap | default(omit) }}"
|
||||
nameserver: "{{ pve_lxc_nameserver | default(omit) }}"
|
||||
netif:
|
||||
net0: >-
|
||||
{{ (['name=' ~ pve_lxc_net_interface, 'bridge=' ~ pve_lxc_net.bridge,
|
||||
'ip=' ~ ansible_host ~ '/' ~ pve_lxc_net_prefix, 'gw=' ~ pve_lxc_net.gw,
|
||||
'tag=' ~ pve_lxc_net.tag] + (['firewall=1'] if pve_lxc_firewall | bool else []))
|
||||
| join(',') }}
|
||||
pubkey: "{{ pve_lxc_pubkey }}"
|
||||
features: "{{ pve_lxc_features if (pve_lxc_features | length > 0) else omit }}"
|
||||
onboot: "{{ __pve_lxc_effective_onboot }}"
|
||||
state: present
|
||||
@@ -0,0 +1,30 @@
|
||||
---
|
||||
- name: Stop LXC before deletion (if running)
|
||||
no_log: true # defence in depth: the module already masks the API token secret
|
||||
delegate_to: localhost
|
||||
community.proxmox.proxmox:
|
||||
vmid: "{{ pve_lxc_vmid }}"
|
||||
node: "{{ pve_lxc_node }}"
|
||||
state: stopped
|
||||
when:
|
||||
- pve_lxc_exists
|
||||
- not ansible_check_mode
|
||||
|
||||
- name: Delete LXC
|
||||
no_log: true # defence in depth: the module already masks the API token secret
|
||||
delegate_to: localhost
|
||||
community.proxmox.proxmox:
|
||||
vmid: "{{ pve_lxc_vmid }}"
|
||||
node: "{{ pve_lxc_node }}"
|
||||
state: absent
|
||||
when:
|
||||
- pve_lxc_exists
|
||||
- not ansible_check_mode
|
||||
register: __pve_lxc_delete
|
||||
|
||||
- name: Update LXC presence after deletion
|
||||
ansible.builtin.set_fact:
|
||||
pve_lxc_present: false
|
||||
when:
|
||||
- __pve_lxc_delete is defined
|
||||
- __pve_lxc_delete.changed
|
||||
@@ -0,0 +1,20 @@
|
||||
---
|
||||
- name: Check if LXC exists
|
||||
no_log: true # Authorization header carries the API token
|
||||
delegate_to: localhost
|
||||
ansible.builtin.uri:
|
||||
url: "https://{{ pve_lxc_api_host }}:8006/api2/json/nodes/{{ pve_lxc_node }}/lxc/{{ pve_lxc_vmid }}/config"
|
||||
method: GET
|
||||
headers:
|
||||
Authorization: "{{ __pve_lxc_api_auth_header }}"
|
||||
status_code: [200, 404, 500]
|
||||
register: __pve_lxc_config
|
||||
check_mode: false
|
||||
|
||||
- name: Set LXC existence fact
|
||||
ansible.builtin.set_fact:
|
||||
pve_lxc_exists: "{{ __pve_lxc_config.status == 200 }}"
|
||||
|
||||
- name: Set public LXC presence API
|
||||
ansible.builtin.set_fact:
|
||||
pve_lxc_present: "{{ pve_lxc_exists and pve_lxc_state != 'absent' }}"
|
||||
@@ -0,0 +1,37 @@
|
||||
---
|
||||
- name: Get current LXC config
|
||||
no_log: true # Authorization header carries the API token
|
||||
delegate_to: localhost
|
||||
ansible.builtin.uri:
|
||||
url: "https://{{ pve_lxc_api_host }}:8006/api2/json/nodes/{{ pve_lxc_node }}/lxc/{{ pve_lxc_vmid }}/config"
|
||||
method: GET
|
||||
headers:
|
||||
Authorization: "{{ __pve_lxc_api_auth_header }}"
|
||||
register: __pve_lxc_config
|
||||
when: pve_lxc_exists
|
||||
|
||||
- name: Extract rootfs string
|
||||
ansible.builtin.set_fact:
|
||||
__pve_lxc_rootfs_str: "{{ __pve_lxc_config.json.data.rootfs | default('') }}"
|
||||
|
||||
- name: Extract current disk number and unit properly
|
||||
ansible.builtin.set_fact:
|
||||
__pve_lxc_disk_parts: "{{ __pve_lxc_rootfs_str | regex_findall('size=(\\d+)([GM])') | first | default(['0', 'G']) | list }}"
|
||||
|
||||
- name: Extract current disk number
|
||||
ansible.builtin.set_fact:
|
||||
__pve_lxc_current_disk_number: "{{ __pve_lxc_disk_parts[0] | int }}"
|
||||
__pve_lxc_current_disk_unit: "{{ __pve_lxc_disk_parts[1] }}"
|
||||
|
||||
- name: Convert current disk size to GB
|
||||
ansible.builtin.set_fact:
|
||||
__pve_lxc_current_disk: "{{ __pve_lxc_current_disk_number if __pve_lxc_current_disk_unit == 'G' else (__pve_lxc_current_disk_number / 1024) }}"
|
||||
|
||||
- name: Extract desired disk size (GB)
|
||||
ansible.builtin.set_fact:
|
||||
__pve_lxc_desired_disk_size: "{{ (pve_lxc_disk.split(':')[-1] | int) }}"
|
||||
|
||||
- name: Determine if disk resize is needed
|
||||
ansible.builtin.set_fact:
|
||||
__pve_lxc_resize_disk: "{{ __pve_lxc_desired_disk_size | int > __pve_lxc_current_disk | int }}"
|
||||
when: pve_lxc_exists
|
||||
@@ -0,0 +1,21 @@
|
||||
---
|
||||
# Written before the container is created, so its rules exist before net0 first comes up with
|
||||
# firewall=1; pve-firewall picks up the change by itself. pmxcfs refuses a chmod to any mode but
|
||||
# 0640, and template cannot create a new file there (its atomic move chmods the 0600 staging file).
|
||||
# Over an existing file it keeps that file's 0640, so the file is created empty first: touch is a
|
||||
# plain open(), and preserving the timestamps keeps it idempotent. Mode omitted: pmxcfs sets it.
|
||||
- name: Create the guest firewall config file # noqa: risky-file-permissions
|
||||
delegate_to: "{{ pve_lxc_node }}"
|
||||
become: true
|
||||
ansible.builtin.file:
|
||||
path: "/etc/pve/firewall/{{ pve_lxc_vmid }}.fw"
|
||||
state: touch
|
||||
modification_time: preserve
|
||||
access_time: preserve
|
||||
|
||||
- name: Write the guest firewall config # noqa: risky-file-permissions
|
||||
delegate_to: "{{ pve_lxc_node }}"
|
||||
become: true
|
||||
ansible.builtin.template:
|
||||
src: firewall.fw.j2
|
||||
dest: "/etc/pve/firewall/{{ pve_lxc_vmid }}.fw"
|
||||
Loaded 100 of 180 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user