Author SHA1 Message Date
Defame1297 27c4ca14c4 chore(release): 3.0.0
Build / build (pull_request) Successful in 1m11s
Lint / lint (pull_request) Successful in 5m26s
Molecule / molecule (pull_request) Successful in 1m56s
Major release: the roles declare exactly the Ubuntu releases they pass
Molecule on in CI. Ubuntu 26.04 (resolute) is added next to 24.04
(noble); 22.04 (jammy) is dropped from five roles and docker narrows
from every Ubuntu release to noble and resolute.

Assisted-by: Claude Code
2026-11-26 08:11:04 +00:00
Defame1297 7a4e9f161e Merge pull request 'chore(deps): update dependency apm-cli to v0.38.0' (#392) from renovate/apm-cli-0.x into main
Images / image (0.1, Dockerfile, ubuntu:24.04@sha256:9c7f200c07e3d4a03e7249d2c16bf66a51120fb876aa2242cf31451412543289, molecule-ubuntu2404, images/molecule-ubuntu2404) (push) Successful in 53s
Images / image (0.1, Dockerfile, ubuntu:26.04@sha256:d66b366dac61b575bee2aef07e9c26e8070096fbe84a3d4d3eb0da069b5d76db, molecule-ubuntu2604, images/molecule-ubuntu2604) (push) Successful in 2m20s
Images / image (0.2, images/ci/Dockerfile, ubuntu:26.04@sha256:d66b366dac61b575bee2aef07e9c26e8070096fbe84a3d4d3eb0da069b5d76db, ci, ) (push) Successful in 7m37s
Reviewed-on: #392
2026-11-26 07:59:18 +00:00
Defame1297 11c5e1987f Merge branch 'main' into renovate/apm-cli-0.x
Build / build (pull_request) Successful in 24s
Molecule / molecule (pull_request) Successful in 56s
Lint / lint (pull_request) Successful in 1m49s
2026-11-26 07:57:23 +00:00
Defame1297 6fe3970f23 Merge pull request 'test(roles): run the Ubuntu roles on 24.04 and 26.04 and declare exactly those' (#381) from test/133-ubuntu-2404-2604 into main
Reviewed-on: #381
2026-11-26 07:46:31 +00:00
Defame1297 042c926058 Merge remote-tracking branch 'origin/main' into test/133-ubuntu-2404-2604
Build / build (pull_request) Successful in 32s
Lint / lint (pull_request) Successful in 3m10s
Molecule / molecule (pull_request) Successful in 35m55s
2026-11-26 06:40:49 +00:00
renovate-bot 6ab8b82fba chore(deps): update dependency apm-cli to v0.38.0
renovate/stability-days Updates have met minimum release age requirement
Build / build (pull_request) Successful in 21s
Molecule / molecule (pull_request) Successful in 1m2s
Lint / lint (pull_request) Successful in 1m52s
2026-11-26 03:18:34 +00:00
Defame1297 cda8677256 Merge pull request 'chore(release): 2.2.0' (#391) from chore/release-2.2.0 into main
Build / build (push) Successful in 15s
Reviewed-on: #391
2026-11-26 00:07:33 +00:00
Defame1297 84ea8213e7 chore(release): 2.2.0
Build / build (pull_request) Successful in 29s
Molecule / molecule (pull_request) Successful in 4s
Lint / lint (pull_request) Successful in 1m30s
Minor release: adds the pve_lxc role and declares community.proxmox
(>=2.1.0) as a Collection dependency; its modules need proxmoxer 2.3 or
later on the controller.

Assisted-by: Claude Code:claude-opus-5-5
2026-11-25 23:44:22 +00:00
Defame1297 7f05d067c8 Merge pull request 'feat(pve_lxc): add the pve_lxc role' (#389) from feat/386-pve-lxc-role into main
Reviewed-on: #389
2026-11-25 23:41:14 +00:00
Defame1297 02d6f9a83e Merge branch 'main' into feat/386-pve-lxc-role
Build / build (pull_request) Successful in 28s
Molecule / molecule (pull_request) Successful in 1m5s
Lint / lint (pull_request) Successful in 1m53s
2026-11-25 23:39:16 +00:00
Defame1297 875e97ff3e Merge pull request 'chore(deps): update git.rkdr.net/mortis/ci docker tag to v0.2.45' (#390) from renovate/git.rkdr.net-mortis-ci-0.x into main
Reviewed-on: #390
2026-11-25 23:37:58 +00:00
renovate-bot 0e15b3457e chore(deps): update git.rkdr.net/mortis/ci docker tag to v0.2.45
renovate/stability-days Updates have met minimum release age requirement
Gitea release key / check (pull_request) Successful in 48s
Build / build (pull_request) Successful in 59s
Lint / lint (pull_request) Successful in 2m39s
Molecule / molecule (pull_request) Successful in 18m29s
2026-11-25 23:18:24 +00:00
Defame1297 7d1f6df3d6 Merge pull request 'build(deps): add community.proxmox and proxmoxer for pve_lxc' (#388) from build/386-proxmox-deps into main
Images / image (0.1, Dockerfile, ubuntu:24.04@sha256:9c7f200c07e3d4a03e7249d2c16bf66a51120fb876aa2242cf31451412543289, molecule-ubuntu2404, images/molecule-ubuntu2404) (push) Successful in 12s
Images / image (0.1, Dockerfile, ubuntu:26.04@sha256:d66b366dac61b575bee2aef07e9c26e8070096fbe84a3d4d3eb0da069b5d76db, molecule-ubuntu2604, images/molecule-ubuntu2604) (push) Successful in 12s
Images / image (0.2, images/ci/Dockerfile, ubuntu:26.04@sha256:d66b366dac61b575bee2aef07e9c26e8070096fbe84a3d4d3eb0da069b5d76db, ci, ) (push) Successful in 5m13s
Reviewed-on: #388
Reviewed-by: Defame1297 <[email protected]>
2026-11-25 23:12:16 +00:00
Defame1297 318229bdb3 feat(pve_lxc): add the pve_lxc role
Build / build (pull_request) Successful in 48s
Lint / lint (pull_request) Failing after 3m17s
Molecule / molecule (pull_request) Failing after 4m2s
Add pve_lxc, which manages the lifecycle of 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. It keeps the pve_lxc_* interface and carries no legacy-name guard.
The input asserts run from tasks/validate.yml before any change, and the
API token secret has no default.

The molecule scenario runs the validation and the node-side task files
against a container standing in for the node; the API lifecycle is not
exercised. Debian trixie is declared, untested.

Refs #386

Assisted-by: Claude Code:claude-opus-5-5
2026-11-25 22:55:25 +00:00
Defame1297 ee129a2982 Merge branch 'main' into build/386-proxmox-deps
Build / build (pull_request) Successful in 22s
Lint / lint (pull_request) Successful in 2m2s
Molecule / molecule (pull_request) Successful in 20m23s
2026-11-25 22:50:40 +00:00
Defame1297 35cedf5163 Merge pull request 'chore(deps): update git.rkdr.net/mortis/ci docker tag to v0.2.44' (#387) from renovate/git.rkdr.net-mortis-ci-0.x into main
Reviewed-on: #387
2026-11-25 22:50:13 +00:00
Defame1297 a6b8bc150d test(roles): run docker and gitea on 26.04 and check become in its smoke scenario
Build / build (pull_request) Successful in 46s
Molecule / molecule (pull_request) Canceled after 30s
Lint / lint (pull_request) Canceled after 44s
molecule-ubuntu2604 0.1.7 lets become from root through and ships gnupg,
so docker and gitea declare resolute like the other Ubuntu roles and the
accepted exception goes. The 26.04 image-smoke scenario now checks
become and gnupg, so a regression fails the image's own pin pull request.

Assisted-by: Claude Code
2026-11-25 22:33:59 +00:00
Defame1297 bb0bf78964 build(deps): add community.proxmox and proxmoxer for pve_lxc
Build / build (pull_request) Successful in 59s
Lint / lint (pull_request) Successful in 4m2s
Molecule / molecule (pull_request) Canceled after 13m29s
The pve_lxc role (#386) manages Proxmox VE guests through community.proxmox,
whose modules import proxmoxer on the controller.

- galaxy.yml: depend on community.proxmox >=2.1.0 (the X.Y.0 of the tested pin,
  like the other dependencies); requirements.yml pins 2.1.0.
- requirements-dev.txt/.lock: pin proxmoxer 2.3.0, the floor community.proxmox
  2.1.0 enforces, so the dev venv and the ci image carry it.
- README: name the new dependency and the controller-side proxmoxer floor.
- ci image: label and doc list the new contents; the changed pin files
  rebuild it on main.

Refs #386

Assisted-by: Claude Code:claude-opus-5-5
2026-11-25 22:29:21 +00:00
Defame1297 5f936962e0 Merge remote-tracking branch 'origin/main' into test/133-ubuntu-2404-2604 2026-11-25 22:26:07 +00:00
renovate-bot dc7d3bdfd9 chore(deps): update git.rkdr.net/mortis/ci docker tag to v0.2.44
renovate/stability-days Updates have met minimum release age requirement
Gitea release key / check (pull_request) Successful in 45s
Build / build (pull_request) Successful in 1m13s
Lint / lint (pull_request) Successful in 2m36s
Molecule / molecule (pull_request) Successful in 26m4s
2026-11-25 22:22:48 +00:00
Defame1297 6f73021d3f Merge pull request 'chore(deps): update dependency antsibull-changelog to v0.38.0' (#385) from renovate/antsibull-changelog-0.x into main
Images / image (0.1, Dockerfile, ubuntu:24.04@sha256:9c7f200c07e3d4a03e7249d2c16bf66a51120fb876aa2242cf31451412543289, molecule-ubuntu2404, images/molecule-ubuntu2404) (push) Successful in 20s
Images / image (0.1, Dockerfile, ubuntu:26.04@sha256:d66b366dac61b575bee2aef07e9c26e8070096fbe84a3d4d3eb0da069b5d76db, molecule-ubuntu2604, images/molecule-ubuntu2604) (push) Successful in 18s
Images / image (0.2, images/ci/Dockerfile, ubuntu:26.04@sha256:d66b366dac61b575bee2aef07e9c26e8070096fbe84a3d4d3eb0da069b5d76db, ci, ) (push) Successful in 5m5s
Reviewed-on: #385
2026-11-25 22:16:17 +00:00
Defame1297 9d365f14ae Merge branch 'main' into renovate/antsibull-changelog-0.x
Build / build (pull_request) Successful in 27s
Molecule / molecule (pull_request) Successful in 1m8s
Lint / lint (pull_request) Successful in 1m50s
2026-11-25 22:14:07 +00:00
Defame1297 44cd287d41 Merge pull request 'chore(deps): update git.rkdr.net/mortis/molecule-ubuntu2604 docker tag to v0.1.7' (#384) from renovate/git.rkdr.net-mortis-molecule-ubuntu2604-0.x into main
Reviewed-on: #384
Reviewed-by: Defame1297 <[email protected]>
2026-11-25 22:12:40 +00:00
renovate-bot 8def6cf274 chore(deps): update dependency antsibull-changelog to v0.38.0
renovate/stability-days Updates have met minimum release age requirement
Build / build (pull_request) Successful in 43s
Lint / lint (pull_request) Successful in 3m49s
Molecule / molecule (pull_request) Successful in 2m20s
2026-11-25 21:52:13 +00:00
renovate-bot da76e995b6 chore(deps): update git.rkdr.net/mortis/molecule-ubuntu2604 docker tag to v0.1.7
renovate/stability-days Updates have met minimum release age requirement
Build / build (pull_request) Successful in 21s
Lint / lint (pull_request) Successful in 2m37s
Molecule / molecule (pull_request) Successful in 20m12s
2026-11-25 21:51:52 +00:00
Defame1297 0d0fc3d1ec Merge pull request 'fix(images): let become work on molecule-ubuntu2604 and add gnupg' (#382) from fix/376-2604-become into main
Images / image (0.1, Dockerfile, ubuntu:24.04@sha256:9c7f200c07e3d4a03e7249d2c16bf66a51120fb876aa2242cf31451412543289, molecule-ubuntu2404, images/molecule-ubuntu2404) (push) Successful in 12s
Images / image (0.1, Dockerfile, ubuntu:26.04@sha256:d66b366dac61b575bee2aef07e9c26e8070096fbe84a3d4d3eb0da069b5d76db, molecule-ubuntu2604, images/molecule-ubuntu2604) (push) Successful in 40s
Images / image (0.2, images/ci/Dockerfile, ubuntu:26.04@sha256:d66b366dac61b575bee2aef07e9c26e8070096fbe84a3d4d3eb0da069b5d76db, ci, ) (push) Successful in 15s
Reviewed-on: #382
Reviewed-by: Defame1297 <[email protected]>
2026-11-25 21:50:14 +00:00
Defame1297 87b87dbcef test(images): check become on 26.04 after the fixed image is pinned
Build / build (pull_request) Successful in 30s
Molecule / molecule (pull_request) Successful in 38s
Lint / lint (pull_request) Successful in 1m40s
The 26.04 smoke checks run against the pinned image, which gains the
fix only after this change is built and pinned; they follow with the
pin.

Assisted-by: Claude Code
2026-11-25 21:47:15 +00:00
Defame1297 efd3a550c5 fix(images): let become work on molecule-ubuntu2604 and add gnupg
Build / build (pull_request) Successful in 30s
Molecule / molecule (pull_request) Failing after 1m4s
Lint / lint (pull_request) Successful in 1m56s
In the booted 26.04 container, pam_unix's account check for sudo runs
the unix_chkpwd helper, which fails there, so become from root fails
with "account validation failure". /etc/pam.d/sudo now lets root
through with pam_rootok before common-account; a non-root caller still
goes through pam_unix. The build fails if the line does not apply.

gnupg joins the image, as in the 24.04 image: the docker and gitea
scenarios need it on the target. The temporary diagnostics are removed.

Closes #376

Assisted-by: Claude Code
2026-11-25 21:42:58 +00:00
Defame1297 5364f18728 test(images): try pam_rootok for become on 26.04 (temporary diagnostics)
Build / build (pull_request) Successful in 29s
Molecule / molecule (pull_request) Successful in 1m4s
Lint / lint (pull_request) Successful in 1m56s
Assisted-by: Claude Code
2026-11-25 21:32:18 +00:00
Defame1297 62ffae7764 test(images): check become in the image-smoke scenarios
Build / build (pull_request) Successful in 30s
Molecule / molecule (pull_request) Failing after 1m20s
Lint / lint (pull_request) Failing after 1m50s
Both smoke scenarios now run a become task, as every role scenario does,
so a molecule image where become fails no longer passes its own pin pull
request. The 26.04 scenario also carries temporary diagnostics for #376.

Assisted-by: Claude Code
2026-11-25 21:28:25 +00:00
Defame1297 1f27f02f13 test(roles): accept both prohibit-password names and declare pihole on 26.04
Build / build (pull_request) Successful in 32s
Lint / lint (pull_request) Successful in 3m0s
Molecule / molecule (pull_request) Failing after 13m34s
sshd -T prints prohibit-password as without-password on OpenSSH 9 and
as prohibit-password on OpenSSH 10 (Ubuntu 26.04). pihole shipped in
2.1.0 on noble only, so gaining resolute is a minor change. The docker
and gitea exception now points at the image fix, #376.

Assisted-by: Claude Code
2026-11-25 21:09:12 +00:00
Defame1297 df06260b27 Merge remote-tracking branch 'origin/main' into test/133-ubuntu-2404-2604
# Conflicts:
#	changelogs/fragments/pihole-role.yml
2026-11-25 21:09:00 +00:00
Defame1297 2e1ad033e4 test(roles): run the Ubuntu roles on 24.04 and 26.04 and declare exactly those
Build / build (pull_request) Successful in 51s
Lint / lint (pull_request) Successful in 3m42s
Molecule / molecule (pull_request) Failing after 20m50s
Every role except network_interfaces runs its molecule scenarios on the
24.04 and 26.04 images and declares Ubuntu noble and resolute; jammy and
Ubuntu all are dropped. trixie stays declared until the Debian 13 image
(#226) tests it. docker and gitea stay on noble until the 26.04 image
ships gnupg (#378).

Closes #133

Assisted-by: Claude Code
2026-11-25 20:17:53 +00:00
83 changed files with 1841 additions and 150 deletions

No files matched your search

+1 -1
View File
@@ -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.45@sha256:922febf5bdccbc773a4f7f52cf118498d029f27a7c56b33c9b6f43ac2b6c2d32
env:
PIP_DISABLE_PIP_VERSION_CHECK: "1"
steps:
+1 -1
View File
@@ -44,7 +44,7 @@ jobs:
# The ci image (images/ci, built by image.yml), at the pin of lint.yml: tag for the
# 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.45@sha256:922febf5bdccbc773a4f7f52cf118498d029f27a7c56b33c9b6f43ac2b6c2d32
steps:
# The container has no Node, so JavaScript actions such as actions/checkout
# cannot run; clone with git and the job token.
+1 -1
View File
@@ -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.45@sha256:922febf5bdccbc773a4f7f52cf118498d029f27a7c56b33c9b6f43ac2b6c2d32
env:
PIP_DISABLE_PIP_VERSION_CHECK: "1"
PRE_COMMIT_HOME: /opt/pre-commit
+2 -2
View File
@@ -54,7 +54,7 @@ jobs:
env:
# The tools and collections molecule runs with: the image Lint and Build use.
CI_IMAGE: >-
git.rkdr.net/mortis/ci:0.2.43@sha256:373c3ba69e3cdccdf6acf96d9c1cbfa173d2db0fbda441f4256eb46bd3ce6b99
git.rkdr.net/mortis/ci:0.2.45@sha256:922febf5bdccbc773a4f7f52cf118498d029f27a7c56b33c9b6f43ac2b6c2d32
# Used by the scenarios as `image: ${MOLECULE_IMAGE}`; set it the same way to run
# one locally.
MOLECULE_IMAGE: >-
@@ -62,7 +62,7 @@ jobs:
# 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 }}
+23
View File
@@ -4,6 +4,29 @@ mortis.kamino Release Notes
.. contents:: Topics
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
======
+8 -6
View File
@@ -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`, `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.0.0 holds the `cloudflared`, `docker`, `fail2ban`, `gitea`, `gitea_runner`, `network_interfaces`, `pihole`, `pve_lxc`, `sshd`, `system_baseline`, `systemd_hardening`, `traefik`, `ufw` and `user_management` roles (and the internal `_binary_update`, which `cloudflared`, `gitea`, `gitea_runner` and `traefik` call).
## 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.0.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`, `tailscale`.
- Wave 3: `rke2`, `proxmox_host`.
- Later, wave not yet assigned: `opnsense`, `proxmox_firewall`.
+7 -1
View File
@@ -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
@@ -65,6 +69,8 @@ plugins:
callback: {}
cliconf: {}
connection: {}
eda_event_filter: {}
eda_event_source: {}
filter: {}
httpapi: {}
inventory: {}
@@ -75,4 +81,4 @@ plugins:
strategy: {}
test: {}
vars: {}
version: 2.1.0
version: 3.0.0
+32
View File
@@ -414,3 +414,35 @@ 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 -2
View File
@@ -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`
+4 -2
View File
@@ -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
View File
@@ -1,14 +1,14 @@
---
namespace: mortis
name: kamino
version: 2.1.0
version: 3.0.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, 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
+3 -3
View File
@@ -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 \
+11 -4
View File
@@ -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"]
+15 -6
View File
@@ -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.0 \
--hash=sha256:6dfac2fdc8ab68586afb2b1a5a6db3c1b7ab569ff0edc525448aa85d0f92bd38 \
--hash=sha256:aa51a98867ae6aef11e92143dd9ca2a994d3dd6cbd7224eae58fb7b8078fc3b1
# 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
+5 -2
View File
@@ -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.0
+2
View File
@@ -11,3 +11,5 @@ collections:
version: 14.0.1
- name: ansible.posix
version: 2.2.2
- name: community.proxmox
version: 2.1.0
+2 -3
View File
@@ -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.
+7 -3
View File
@@ -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,9 +66,10 @@ 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
and checks that nothing changed. The calling roles' own scenarios cover a real upstream binary.
+1
View File
@@ -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:
+2 -2
View File
@@ -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.
@@ -106,7 +106,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.
## Notes
+1
View File
@@ -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
+2 -4
View File
@@ -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_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).
@@ -88,7 +86,7 @@ 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` 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.
What it shows, with the role's tasks running unchanged:
+2 -1
View File
@@ -9,7 +9,8 @@ galaxy_info:
platforms:
- name: Ubuntu
versions:
- all
- noble
- resolute
galaxy_tags:
- docker
- containers
+23 -5
View File
@@ -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:
+2 -2
View File
@@ -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). The sequence runs prepare, converge, idempotence, side effect and verify; it has no check-mode step.
- 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.
+1
View File
@@ -10,6 +10,7 @@ galaxy_info:
- name: Ubuntu
versions:
- noble
- resolute
galaxy_tags:
- fail2ban
- security
+21 -3
View File
@@ -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:
+2 -2
View File
@@ -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,7 +142,7 @@ 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.
+1
View File
@@ -10,6 +10,7 @@ galaxy_info:
- name: Ubuntu
versions:
- noble
- resolute
galaxy_tags:
- gitea
- git
+26 -9
View File
@@ -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:
+2 -2
View File
@@ -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.
@@ -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.
## Notes
+1
View File
@@ -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
+2 -4
View File
@@ -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 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.
## Notes
+1
View File
@@ -10,6 +10,7 @@ galaxy_info:
- name: Ubuntu
versions:
- noble
- resolute
galaxy_tags:
- pihole
- dns
+21 -5
View File
@@ -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
+108
View File
@@ -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 and after the idempotence run. Negative tests cover a state outside the spec, missing API credentials and a missing network prefix through `main`, and raw config given as a string, outside the `lxc.` namespace or with two lines in one item, a malformed firewall rule and an unknown policy through `validate`; a run with `pve_lxc_manage_lifecycle: false` checks the presence facts. No Proxmox service runs, so pmxcfs's handling of the files and `pve-firewall` loading the rules are not verified.
## 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.
+53
View File
@@ -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: []
+227
View File
@@ -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).
+18
View File
@@ -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 two check steps: one before the converge (first-run preview), one after the idempotence run.
test_sequence:
- dependency
- cleanup
- syntax
- create
- prepare
- check
- converge
- idempotence
- check
- 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
+175
View File
@@ -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
+25
View File
@@ -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
+30
View File
@@ -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
+20
View File
@@ -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' }}"
+37
View File
@@ -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
+21
View File
@@ -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"
+105
View File
@@ -0,0 +1,105 @@
---
# Validation first, under always, so a bad input fails before any change whatever tags the run
# selects.
- name: Validate the role inputs
ansible.builtin.import_tasks: validate.yml
tags: always
- name: Treat externally hosted LXC as present
ansible.builtin.set_fact:
pve_lxc_exists: true
pve_lxc_present: true
when: not pve_lxc_manage_lifecycle | bool
# Every Proxmox API call of the role is inside this block, so the credentials are set once here
# and never read when pve_lxc_manage_lifecycle is false (validate.yml asserts them otherwise). The uri tasks (detect, detect_disk) take
# host and header explicitly.
- name: Manage Proxmox LXC lifecycle
when: pve_lxc_manage_lifecycle | bool
module_defaults:
community.proxmox.proxmox:
api_user: "{{ pve_lxc_api_user }}@{{ pve_lxc_api_realm }}"
api_token_id: "{{ pve_lxc_api_token_id }}"
api_token_secret: "{{ pve_lxc_api_token_secret }}"
api_host: "{{ pve_lxc_api_host }}"
validate_certs: false
ansible.builtin.uri:
validate_certs: false
block:
- name: Detect LXC existence
ansible.builtin.include_tasks: detect.yml
- name: Delete LXC (explicit)
ansible.builtin.include_tasks: delete.yml
when:
- pve_lxc_state == "absent"
- pve_lxc_allow_destroy | bool
- pve_lxc_exists
- name: Abort play after deletion
ansible.builtin.meta: end_host
when:
- pve_lxc_state == "absent"
- pve_lxc_allow_destroy | bool
- pve_lxc_exists
- name: Detect disk size (only if exists)
ansible.builtin.include_tasks: detect_disk.yml
when:
- pve_lxc_exists
- pve_lxc_state != "absent"
- name: Manage the guest firewall
ansible.builtin.include_tasks: firewall.yml
when:
- pve_lxc_state != "absent"
- pve_lxc_firewall | bool
- name: Create LXC (only if missing)
ansible.builtin.include_tasks: create.yml
when:
- pve_lxc_state != "absent"
- not pve_lxc_exists
- not ansible_check_mode
# Gated on the existence detected before the create, so a container created in this run is
# first updated on the next run.
- name: Update LXC (only if exists)
ansible.builtin.include_tasks: update.yml
when:
- pve_lxc_state != "absent"
- pve_lxc_exists
# A create that did not fail leaves the container existing: set the facts locally, so the raw
# config below is applied in the same run without another API call.
- name: Mark LXC as existing after creation
ansible.builtin.set_fact:
pve_lxc_exists: true
pve_lxc_present: true
when:
- pve_lxc_state != "absent"
- not pve_lxc_exists
- not ansible_check_mode
# Not gated on pve_lxc_raw_config being non-empty: an emptied list must still remove the
# lxc.* lines an earlier run wrote. Gated on existence: no config file exists before the
# container does.
- name: Apply raw LXC config lines
ansible.builtin.include_tasks: raw_config.yml
when:
- pve_lxc_state != "absent"
- pve_lxc_exists
- name: Detect LXC existence
ansible.builtin.include_tasks: detect.yml
- name: Ensure LXC runtime state
ansible.builtin.include_tasks: state.yml
when:
- pve_lxc_state in ["started", "stopped"]
- name: Wait for SSH
ansible.builtin.include_tasks: wait.yml
when:
- pve_lxc_state == "started"
- pve_lxc_wait_for_ssh
+114
View File
@@ -0,0 +1,114 @@
---
# Reconciles the raw lxc.* lines of /etc/pve/lxc/<vmid>.conf with pve_lxc_raw_config.
#
# A blockinfile marker block does not work here: when Proxmox re-saves the file it folds bare "#"
# lines into the container's description, so the markers vanish and every run would insert the
# block again, duplicating the lines and restarting the container. Instead the role owns the whole
# "lxc." namespace, which no Proxmox-managed property uses (arch, cores, memory, net0, rootfs ...):
# the lines of the main section are split into lxc.* lines and the rest, and when the lxc.* lines
# differ from the desired list, in content or order, the file is rewritten in one copy with the
# other lines first, in their order, and the desired list after them. lxc.* lines written by hand
# or by another tool are therefore removed. Marker lines of an earlier blockinfile block
# ("# BEGIN/END ANSIBLE MANAGED BLOCK (lxc_raw_config)") are removed in the same rewrite.
#
# Snapshot sections ("[name]" headers, each with its own copy of the config) are kept byte for
# byte after the main section: a stored snapshot is never edited.
- name: Slurp raw LXC config file
delegate_to: "{{ pve_lxc_node }}"
become: true
ansible.builtin.slurp:
src: "/etc/pve/lxc/{{ pve_lxc_vmid }}.conf"
register: __pve_lxc_raw_config_slurp
- name: Split raw LXC config file into lines
ansible.builtin.set_fact:
__pve_lxc_raw_config_lines: "{{ (__pve_lxc_raw_config_slurp.content | b64decode).splitlines() }}"
# default(..., true): an explicit null or "" becomes [], as in validate.yml.
__pve_lxc_raw_config_desired: "{{ pve_lxc_raw_config | default([], true) }}"
- name: Determine end of main config section (before first PVE snapshot header)
ansible.builtin.set_fact:
__pve_lxc_raw_config_main_section_end: >-
{%- set ns = namespace(idx=-1) -%}
{%- for line in __pve_lxc_raw_config_lines -%}
{%- if ns.idx == -1 and (line is match(__pve_lxc_raw_config_section_header_pattern)) -%}
{%- set ns.idx = loop.index0 -%}
{%- endif -%}
{%- endfor -%}
{{ __pve_lxc_raw_config_lines | length if ns.idx == -1 else ns.idx }}
- name: Split main config section from any PVE snapshot sections
ansible.builtin.set_fact:
__pve_lxc_raw_config_main_lines: "{{ __pve_lxc_raw_config_lines[: (__pve_lxc_raw_config_main_section_end | int)] }}"
__pve_lxc_raw_config_snapshot_lines: "{{ __pve_lxc_raw_config_lines[(__pve_lxc_raw_config_main_section_end | int) :] }}"
- name: Determine whether raw LXC config lines need reconciling
ansible.builtin.set_fact:
__pve_lxc_raw_config_existing: "{{ __pve_lxc_raw_config_main_lines | select('match', __pve_lxc_raw_config_prefix_pattern) | list }}"
__pve_lxc_raw_config_legacy_markers: "{{ __pve_lxc_raw_config_main_lines | select('match', __pve_lxc_raw_config_legacy_marker_pattern) | list }}"
__pve_lxc_raw_config_preserved_lines: >-
{{
__pve_lxc_raw_config_main_lines
| reject('match', __pve_lxc_raw_config_prefix_pattern)
| reject('match', __pve_lxc_raw_config_legacy_marker_pattern)
| list
}}
# Order-sensitive on purpose: LXC evaluates these lines in order, so a reorder is a change.
- name: Set raw LXC config dirty flag
ansible.builtin.set_fact:
__pve_lxc_raw_config_dirty: "{{ __pve_lxc_raw_config_existing != __pve_lxc_raw_config_desired }}"
- name: Set raw LXC config file rewrite flag
ansible.builtin.set_fact:
__pve_lxc_raw_config_needs_rewrite: "{{ __pve_lxc_raw_config_dirty or (__pve_lxc_raw_config_legacy_markers | length > 0) }}"
# One copy (temporary file and rename), so an interrupted run leaves the old or the new content,
# never a file without its lxc.* lines. Mode omitted: the file exists already and copy keeps its
# mode, which Proxmox owns. No backup: pmxcfs is small and replicated to every node.
- name: Reconcile raw LXC config file atomically (namespace-exclusive sync) # noqa: risky-file-permissions
delegate_to: "{{ pve_lxc_node }}"
become: true
ansible.builtin.copy:
dest: "/etc/pve/lxc/{{ pve_lxc_vmid }}.conf"
# Double-quoted: in a folded scalar Jinja would receive a literal backslash-n, not a newline.
content: "{{ (__pve_lxc_raw_config_preserved_lines + __pve_lxc_raw_config_desired + __pve_lxc_raw_config_snapshot_lines) | join('\n') + '\n' }}"
when:
- __pve_lxc_raw_config_needs_rewrite
# Ansible backup copies (<vmid>.conf.<pid>.<timestamp>~) must not pile up on pmxcfs.
- name: Find stale raw LXC config backups
delegate_to: "{{ pve_lxc_node }}"
become: true
ansible.builtin.find:
paths: /etc/pve/lxc
patterns: "{{ pve_lxc_vmid }}.conf.*~"
register: __pve_lxc_raw_config_backups
- name: Remove stale raw LXC config backups
delegate_to: "{{ pve_lxc_node }}"
become: true
ansible.builtin.file:
path: "{{ __pve_lxc_backup.path }}"
state: absent
loop: "{{ __pve_lxc_raw_config_backups.files }}"
loop_control:
loop_var: __pve_lxc_backup
label: "{{ __pve_lxc_backup.path }}"
# Skipped for a stopped container, so a config change never starts it; the new lines take
# effect on its next start.
- name: Restart LXC if raw config changed
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 }}"
state: restarted
timeout: 300
when:
- __pve_lxc_raw_config_dirty
- not ansible_check_mode
- pve_lxc_state != "stopped"
+8
View File
@@ -0,0 +1,8 @@
---
- name: Ensure LXC state
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: "{{ pve_lxc_state }}"
+113
View File
@@ -0,0 +1,113 @@
---
- name: Update LXC config (no restart)
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 }}"
# Sent explicitly: community.proxmox 2.0.0 forwarded its argspec default "default" on
# update, which Proxmox rejects (2.1.0 drops it).
cmode: "{{ pve_lxc_cmode | default('tty') }}"
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
update: true
register: __pve_lxc_config_update
- name: Restart LXC if config changed and restart-on-change is enabled
no_log: true # defence in depth: the module already masks the API token secret
# Proxmox only applies some config (e.g. `features`) on next container
# start, not live via pct set.
delegate_to: localhost
community.proxmox.proxmox:
vmid: "{{ pve_lxc_vmid }}"
node: "{{ pve_lxc_node }}"
hostname: "{{ inventory_hostname }}"
state: restarted
timeout: 300
when:
- __pve_lxc_config_update.changed | default(false)
- pve_lxc_restart_on_config_change
- not ansible_check_mode
- name: Resize disk if desired size is larger
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 }}"
disk: "{{ pve_lxc_disk }}"
state: present
update: true
when:
- pve_lxc_manage_disk
- __pve_lxc_resize_disk
- not ansible_check_mode
register: __pve_lxc_disk_resize
- name: Set disk resize API flag
ansible.builtin.set_fact:
__pve_lxc_disk_resized: >-
{{
(__pve_lxc_disk_resized | default(false))
or (__pve_lxc_disk_resize.changed | default(false))
}}
- name: Fail if disk resize was requested but not applied
ansible.builtin.fail:
msg: "Disk resize requested but Proxmox did not apply it"
when:
- pve_lxc_manage_disk
- __pve_lxc_resize_disk
- not __pve_lxc_disk_resized
- not ansible_check_mode
# Resize the filesystem inside the container using pct resize
- name: Resize filesystem inside container
delegate_to: "{{ pve_lxc_node }}"
become: true
ansible.builtin.command: >
pct resize {{ pve_lxc_vmid }} rootfs {{ __pve_lxc_desired_disk_size }}G
when:
- pve_lxc_manage_disk
- __pve_lxc_resize_disk
- __pve_lxc_disk_resized | default(false)
- not ansible_check_mode
register: __pve_lxc_pct_resize_result
changed_when: >
__pve_lxc_pct_resize_result.rc == 0 and
(
'successfully resized' in __pve_lxc_pct_resize_result.stdout | lower or
'size of logical volume' in __pve_lxc_pct_resize_result.stdout | lower
)
failed_when: >
__pve_lxc_pct_resize_result.rc != 0 and
'no resize needed' not in (__pve_lxc_pct_resize_result.stderr | lower)
- name: Restart LXC if disk was resized
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 }}"
state: restarted
timeout: 300
when:
- __pve_lxc_pct_resize_result is defined
- __pve_lxc_pct_resize_result.changed
- not ansible_check_mode
- pve_lxc_reboot_if_required | bool
+88
View File
@@ -0,0 +1,88 @@
---
# The input rules the argument spec cannot express. main.yml imports this file under
# tags: always, before any change; each assert keeps the condition under which its input is read.
- name: Assert the Proxmox API credentials are set
ansible.builtin.assert:
that:
- pve_lxc_api_user | length > 0
- pve_lxc_api_token_secret is defined and pve_lxc_api_token_secret | length > 0
fail_msg: >-
The Proxmox API calls need pve_lxc_api_user (bare user name, the role appends
@<pve_lxc_api_realm>) and pve_lxc_api_token_secret (normally vaulted). Neither has a usable
default: set them in the inventory, or set pve_lxc_manage_lifecycle to false for a container
whose node Ansible does not manage.
quiet: true
when: pve_lxc_manage_lifecycle | bool
- name: Assert the network prefix length is set
ansible.builtin.assert:
that:
- pve_lxc_net_prefix | string is match('^([1-9]|[12][0-9]|3[0-2])$')
fail_msg: >-
pve_lxc_net_prefix must be the subnet prefix length of the container network (1 to 32),
for example 24. It has no role default because it is environment-specific: set it in the
inventory.
quiet: true
when:
- pve_lxc_manage_lifecycle | bool
- pve_lxc_state != "absent"
# Reads only the variable, so a malformed list also fails under --check on a container that does
# not exist yet. A bare string would be checked character by character, with a meaningless message.
- name: Fail if pve_lxc_raw_config is set but not a list
ansible.builtin.fail:
msg: >-
pve_lxc_raw_config must be a YAML list of strings (one raw config line per
item), not a bare string or mapping -- a plain string is iterated
character-by-character by the checks below, which produces a
nonsensical error. Got type: {{ pve_lxc_raw_config | type_debug }}.
when:
- pve_lxc_manage_lifecycle | bool
- pve_lxc_state != "absent"
- pve_lxc_raw_config is defined
- pve_lxc_raw_config is truthy
- (pve_lxc_raw_config is string) or (pve_lxc_raw_config is not sequence)
- name: Determine malformed pve_lxc_raw_config entries
ansible.builtin.set_fact:
# default(..., true) also turns an explicit null or "" into [], which the reconcile's list
# concatenation needs. The pattern is anchored at both ends: an item holding two lines would be
# written as two and never match the desired list on read-back, restarting the container on
# every run.
__pve_lxc_raw_config_malformed: "{{ pve_lxc_raw_config | default([], true) | reject('match', __pve_lxc_raw_config_prefix_pattern) | list }}"
when:
- pve_lxc_manage_lifecycle | bool
- pve_lxc_state != "absent"
- name: Fail on malformed pve_lxc_raw_config entries
ansible.builtin.fail:
msg: >-
pve_lxc_raw_config entries must be a single line starting with the literal
prefix "lxc." (no leading whitespace, comments, other directives, or
embedded newlines) so the namespace-exclusive sync below can safely
treat "^lxc\." as its ownership boundary. Offending entries:
{{ __pve_lxc_raw_config_malformed }}
when:
- pve_lxc_manage_lifecycle | bool
- pve_lxc_state != "absent"
- __pve_lxc_raw_config_malformed | length > 0
# Proxmox skips a rule line it cannot parse, so a malformed DROP would silently open what it was
# meant to close. Only the shape is checked; `pve-firewall compile` on the node proves the syntax.
- name: Validate guest firewall inputs
ansible.builtin.assert:
that:
- pve_lxc_firewall_policy_in in ['ACCEPT', 'DROP', 'REJECT']
- pve_lxc_firewall_policy_out in ['ACCEPT', 'DROP', 'REJECT']
- pve_lxc_firewall_rules is sequence
- pve_lxc_firewall_rules is not string
- pve_lxc_firewall_rules | reject('match', '^(IN|OUT) (ACCEPT|DROP|REJECT)( [^\n]*)?$') | list | length == 0
fail_msg: >-
pve_lxc_firewall_policy_in/_out must be ACCEPT, DROP or REJECT and pve_lxc_firewall_rules a list of
single-line Proxmox rules starting with "IN|OUT ACCEPT|DROP|REJECT".
quiet: true
when:
- pve_lxc_manage_lifecycle | bool
- pve_lxc_state != "absent"
- pve_lxc_firewall | bool
+7
View File
@@ -0,0 +1,7 @@
---
- name: Wait for SSH to become available
delegate_to: localhost
ansible.builtin.wait_for:
host: "{{ ansible_host }}"
port: 22
timeout: 3600
+11
View File
@@ -0,0 +1,11 @@
[OPTIONS]
enable: 1
ipfilter: 1
macfilter: 1
policy_in: {{ pve_lxc_firewall_policy_in }}
policy_out: {{ pve_lxc_firewall_policy_out }}
[RULES]
{% for __pve_lxc_firewall_rule in pve_lxc_firewall_rules %}
{{ __pve_lxc_firewall_rule }}
{% endfor %}
+11
View File
@@ -0,0 +1,11 @@
---
# The onboot flag sent to Proxmox on create and update. Derived from the desired state, not an
# input: a container meant to be stopped must not start when its node reboots, so stopped forces
# false even when pve_lxc_onboot is true. absent never reaches the create or update task.
__pve_lxc_effective_onboot: "{{ (pve_lxc_onboot | bool) and pve_lxc_state != 'stopped' }}"
# Authorization header of the ansible.builtin.uri calls, derived from the pve_lxc_api_* inputs.
__pve_lxc_api_auth_header: "PVEAPIToken={{ pve_lxc_api_user }}@{{ pve_lxc_api_realm }}!{{ pve_lxc_api_token_id }}={{ pve_lxc_api_token_secret }}"
# Raw config line patterns, read by validate.yml and raw_config.yml.
__pve_lxc_raw_config_prefix_pattern: '^lxc\.[^\n]*$'
__pve_lxc_raw_config_legacy_marker_pattern: '^# (BEGIN|END) ANSIBLE MANAGED BLOCK \(lxc_raw_config\)$'
__pve_lxc_raw_config_section_header_pattern: '^\[.*\]$'
+3 -3
View File
@@ -4,9 +4,9 @@ Writes a hardened sshd drop-in, selected by a profile, and refuses configuration
## Supported platforms
Ubuntu 24.04 (noble), the platform the molecule scenario runs on.
Ubuntu 24.04 (noble) and 26.04 (resolute), the platforms the molecule scenario runs on.
Untested platforms: Ubuntu 22.04 (jammy) and Debian trixie (Proxmox VE 9 nodes, the `pve` profile), listed in `meta/main.yml` but not converged by a test.
Untested platforms: Debian trixie (Proxmox VE 9 nodes, the `pve` profile), listed in `meta/main.yml` but not converged by a test.
The role targets Ubuntu guests (the `ubuntu_lxc` and `ubuntu_vm` profiles) and Proxmox VE nodes (the `pve` profile).
@@ -59,7 +59,7 @@ The role defines none.
## Tests
The scenario `molecule/default/`, run by the Collection's CI, runs on one platform: `${MOLECULE_IMAGE}`, an Ubuntu 24.04 (noble) container that ships openssh-server. The sequence runs converge, idempotence and verify; it has no check-mode step.
The scenario `molecule/default/` runs in CI only, on two platforms: `${MOLECULE_IMAGE}` (Ubuntu 24.04) and `${MOLECULE_IMAGE_2604}` (Ubuntu 26.04). Both images ship openssh-server. The sequence runs converge, idempotence and verify; it has no check-mode step.
- Converge applies the `ubuntu_lxc` profile. It then loads the defaults through `tasks_from: validate.yml` without changing the host: every profile (`pve`, `ubuntu_lxc`, `ubuntu_vm`) passes validation and keeps its root login policy and key algorithms, a consumer `sshd_settings` override wins over the profile, and the `pve` guard accepts each value that allows root key login.
- Verify first checks the refusals: a run without `sshd_profile`, `PubkeyAuthentication no` (lock-out), a `pve` profile with `PermitRootLogin no` or `forced-commands-only`, a `pve` profile without `rsa-sha2-512`, SHA-1 `ssh-rsa`, and an unknown profile. Each but the missing profile is matched on its message.
+1 -1
View File
@@ -9,8 +9,8 @@ galaxy_info:
platforms:
- name: Ubuntu
versions:
- jammy
- noble
- resolute
- name: Debian
versions:
- trixie
+1 -1
View File
@@ -1,5 +1,5 @@
---
# The production profile: Ubuntu 24.04 LXCs. Only the profile name and the user are supplied.
# The production profile: Ubuntu LXCs. Only the profile name and the user are supplied.
- name: Converge the role with a valid profile
hosts: all
vars:
+21 -4
View File
@@ -1,8 +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), which ships openssh-server. No
# privileged mode: systemd needs a writable cgroup; NET_ADMIN keeps the container the same as
# the other role scenarios.
# 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; both ship openssh-server. No privileged mode: systemd
# needs a writable cgroup; NET_ADMIN keeps the container the same as the other role scenarios.
driver:
name: docker
platforms:
@@ -23,6 +23,23 @@ platforms:
- NET_ADMIN
security_opts:
- apparmor=unconfined
- name: ${KAMINO_RUN_ID:-local}-sshd-2604-instance
labels:
net.rkdr.mortis.molecule-run: "${KAMINO_RUN_ID:-local}"
image: ${MOLECULE_IMAGE_2604}
pre_build_image: true
pull: true
command: /sbin/init
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
tmpfs:
- /run
- /run/lock
capabilities:
- NET_ADMIN
security_opts:
- apparmor=unconfined
provisioner:
name: ansible
verifier:
+4 -2
View File
@@ -237,8 +237,10 @@
- name: Root logs in with keys only, passwords stay off
ansible.builtin.assert:
that:
# sshd -T prints the first alias in its table for prohibit-password: without-password.
- sshd_verify_pve_effective.stdout_lines is contains('permitrootlogin without-password')
# sshd -T prints prohibit-password under one of its names, by OpenSSH version.
- >-
'permitrootlogin prohibit-password' in sshd_verify_pve_effective.stdout_lines
or 'permitrootlogin without-password' in sshd_verify_pve_effective.stdout_lines
- sshd_verify_pve_effective.stdout_lines is contains('passwordauthentication no')
- sshd_verify_pve_effective.stdout_lines is contains('pubkeyauthentication yes')
quiet: true
+3 -3
View File
@@ -4,9 +4,9 @@ Applies an OS baseline chosen by `system_baseline_system_type`: apt upgrade, pac
## Supported platforms
Ubuntu 24.04 (noble) passes the molecule scenario. The tasks use apt and the reboot check is limited to the Debian family. See `meta/main.yml`.
Ubuntu 24.04 (noble) and 26.04 (resolute), the platforms the molecule scenario runs on. The tasks use apt and the reboot check is limited to the Debian family. See `meta/main.yml`.
Untested platforms: Debian 13 (trixie, Proxmox hosts), not verified by a test; Ubuntu 22.04 (jammy), listed in `meta/main.yml` but neither supported nor tested.
Untested platforms: Debian 13 (trixie, Proxmox hosts), listed in `meta/main.yml` but not verified by a test.
The role targets Ubuntu guests (the `ubuntu_lxc` and `ubuntu_vm` profiles) and Proxmox VE hosts on Debian (the `pve` profile).
@@ -124,7 +124,7 @@ The two task files besides `main` are a supported interface, for a caller that d
## Tests
The scenario `molecule/default/` runs in CI only, on one platform: `${MOLECULE_IMAGE}`, an Ubuntu 24.04 (noble) container. It installs packages from the Ubuntu mirrors, so the runner needs outbound network. The sequence runs prepare, converge, idempotence and verify; it has no check-mode step.
The scenario `molecule/default/` runs in CI only, on two platforms: `${MOLECULE_IMAGE}` (Ubuntu 24.04) and `${MOLECULE_IMAGE_2604}` (Ubuntu 26.04). It installs packages from the Ubuntu mirrors, so the runner needs outbound network. The sequence runs prepare, converge, idempotence and verify; it has no check-mode step.
- Converge first checks that the role refuses a bad input with its own message before any change: an unknown `system_baseline_system_type`, an unknown `system_baseline_apt_upgrade` (main flow and `update` entry point), a negative reboot throttle or a negative or boolean post-reboot delay (main flow and `reboot` entry point), a line break in `system_baseline_apt_daily_timeout`, and a bad package blacklist (a quote, a null item, a bare string).
- Converge then applies the `ubuntu_lxc` profile, with tmux autostart and `system_baseline_apt_daily_timeout: 1h`, and only resolves the `pve` and `ubuntu_vm` profiles and a consumer override, asserting the resolved inputs.
+1 -1
View File
@@ -9,8 +9,8 @@ galaxy_info:
platforms:
- name: Ubuntu
versions:
- jammy
- noble
- resolute
- name: Debian
versions:
- trixie
@@ -1,10 +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). Unlike the other scenarios
# this one installs packages (the role's system_baseline_essential_packages list) from the Ubuntu
# mirrors during prepare and converge, so the runner needs outbound network. 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. Unlike the other scenarios this one installs packages (the
# role's system_baseline_essential_packages list) from the Ubuntu mirrors during prepare and
# converge, so the runner needs outbound network. No privileged mode: systemd needs a writable
# cgroup and the firewall tools need NET_ADMIN, nothing else.
driver:
name: docker
platforms:
@@ -25,6 +25,23 @@ platforms:
- NET_ADMIN
security_opts:
- apparmor=unconfined
- name: ${KAMINO_RUN_ID:-local}-system-baseline-2604-instance
labels:
net.rkdr.mortis.molecule-run: "${KAMINO_RUN_ID:-local}"
image: ${MOLECULE_IMAGE_2604}
pre_build_image: true
pull: true
command: /sbin/init
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
tmpfs:
- /run
- /run/lock
capabilities:
- NET_ADMIN
security_opts:
- apparmor=unconfined
provisioner:
name: ansible
options:
+3 -3
View File
@@ -4,9 +4,9 @@ Disables and masks risky services, writes a systemd manager hardening drop-in an
## Supported platforms
The molecule scenario passes on Ubuntu 24.04 (noble); see [Tests](#tests). The role is meant for hosts with systemd: Ubuntu 24.04 (noble) LXCs, Ubuntu VMs and Debian 13 (trixie) Proxmox hosts. The role is applied to the three system types in `systemd_hardening_profiles`: `pve` (Proxmox hosts), `ubuntu_lxc` and `ubuntu_vm`.
Ubuntu 24.04 (noble) and 26.04 (resolute), the platforms the molecule scenario runs on; see [Tests](#tests). The role is meant for hosts with systemd: Ubuntu LXCs, Ubuntu VMs and Debian 13 (trixie) Proxmox hosts. The role is applied to the three system types in `systemd_hardening_profiles`: `pve` (Proxmox hosts), `ubuntu_lxc` and `ubuntu_vm`.
Untested platforms: Debian 13 (trixie), and Ubuntu 22.04 (jammy), which is listed in `meta/main.yml` but neither supported nor tested.
Untested platforms: Debian 13 (trixie), listed in `meta/main.yml` but not verified by a test.
## Requirements and run order
@@ -52,7 +52,7 @@ Only `always` (the `systemd_hardening_system_type` assert) works as intended. `d
## Tests
`molecule/default` runs in CI only, on one platform: Ubuntu 24.04 (noble), the `molecule-ubuntu2404` image (`${MOLECULE_IMAGE}`). It runs the `ubuntu_lxc` profile against stub unit files (a socket and a service for the ones that ship both, a service only and a socket only for the others), because the test image installs none of the services the role disables or masks. It checks that the stub sockets and services end up stopped and disabled or masked, that a listed unit that does not exist is skipped, the manager and service drop-ins (loaded by systemd after the reload) and the refusals: a missing or unknown `systemd_hardening_system_type`, and a `systemd_hardening_services` entry or value that is not a mapping. It cannot show that a real `rpcbind` or similar stops. The `pve` and `ubuntu_vm` profiles and Debian 13 are not verified by a test.
`molecule/default` runs in CI only, on two platforms: `${MOLECULE_IMAGE}` (Ubuntu 24.04) and `${MOLECULE_IMAGE_2604}` (Ubuntu 26.04). It runs the `ubuntu_lxc` profile against stub unit files (a socket and a service for the ones that ship both, a service only and a socket only for the others), because the test images install none of the services the role disables or masks. It checks that the stub sockets and services end up stopped and disabled or masked, that a listed unit that does not exist is skipped, the manager and service drop-ins (loaded by systemd after the reload) and the refusals: a missing or unknown `systemd_hardening_system_type`, and a `systemd_hardening_services` entry or value that is not a mapping. It cannot show that a real `rpcbind` or similar stops. The `pve` and `ubuntu_vm` profiles and Debian 13 are not verified by a test.
## Notes
+1 -1
View File
@@ -9,8 +9,8 @@ galaxy_info:
platforms:
- name: Ubuntu
versions:
- jammy
- noble
- resolute
- name: Debian
versions:
- trixie
@@ -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}-systemd-hardening-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:
+2 -2
View File
@@ -4,7 +4,7 @@ Installs the Traefik reverse proxy as a systemd-managed binary, renders its stat
## 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 github.com for the release archive and checksum file. Only `traefik_install_type: binary` exists.
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 github.com for the release archive and checksum file. Only `traefik_install_type: binary` exists.
The role targets Ubuntu hosts that run the reverse proxy, not Proxmox nodes, so it does not cover Debian trixie.
@@ -79,7 +79,7 @@ Update or remove: pass `-e traefik_update=true`, or `-e "traefik_remove=true tra
## Tests
The `default` molecule scenario runs on one platform, Ubuntu 24.04 (noble) (`${MOLECULE_IMAGE}`). It needs outbound network: the role installs packages with apt and downloads real Traefik releases from GitHub. Converge runs `mortis.kamino.ufw`, then the role. Verify covers:
The `default` molecule scenario runs in CI only, on two platforms: `${MOLECULE_IMAGE}` (Ubuntu 24.04) and `${MOLECULE_IMAGE_2604}` (Ubuntu 26.04). It needs outbound network: the role installs packages with apt and downloads real Traefik releases from GitHub. Converge runs `mortis.kamino.ufw`, then the role. Verify covers:
- The input guards, first: one play expects the failure message containing `unauthenticated Traefik dashboard` (the dashboard guard: enabled without valid `user:hash` users); the next expects `collides with the middleware`, raised by the dashboard-auth collision assert, which runs whenever users are set, also with the dashboard off.
- The install: the pinned version runs, and only the binary is left from the archive.
+1
View File
@@ -10,6 +10,7 @@ galaxy_info:
- name: Ubuntu
versions:
- noble
- resolute
galaxy_tags:
- traefik
- reverseproxy
+22 -4
View File
@@ -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 outbound network, unlike most
# scenarios: the role installs packages with apt and downloads Traefik releases from GitHub. No
# privileged mode: systemd needs a writable cgroup and the firewall tools need NET_ADMIN.
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404
# (MOLECULE_IMAGE) and molecule-ubuntu2604 (MOLECULE_IMAGE_2604) images, pinned in
# .gitea/workflows/molecule.yml. Needs outbound network, unlike most scenarios: the role installs
# packages with apt and downloads Traefik releases from GitHub. No privileged mode: systemd needs a
# writable cgroup and the firewall tools need NET_ADMIN.
driver:
name: docker
platforms:
@@ -23,6 +24,23 @@ platforms:
- NET_ADMIN
security_opts:
- apparmor=unconfined
- name: ${KAMINO_RUN_ID:-local}-traefik-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
# One source for every play in converge.yml and verify.yml. The role renders traefik.yml before
+2 -4
View File
@@ -4,9 +4,7 @@ Installs UFW and applies sysctl overrides, `/etc/ufw/before.rules`, default poli
## Supported platforms
Ubuntu 24.04 (noble), the platform the molecule scenario runs on.
Untested platforms: Ubuntu 22.04 (jammy), listed in `meta/main.yml` but not verified by a test.
Ubuntu 24.04 (noble) and 26.04 (resolute), the platforms the molecule scenario runs on.
Ubuntu hosts only: the role firewalls Ubuntu guests; the `pve` profile of `system_baseline` does not install ufw, so Proxmox hosts are not targeted.
@@ -138,7 +136,7 @@ Skipping `ufw_aggregate` leaves the lists the later tasks read (`ufw_aggregated_
## Tests
The scenario `molecule/default/` runs in CI only, on one platform: `${MOLECULE_IMAGE}`, an Ubuntu 24.04 (noble) container with `NET_ADMIN`. The sequence runs prepare, converge, idempotence and verify; it has no check-mode step.
The scenario `molecule/default/` runs in CI only, on two platforms: `${MOLECULE_IMAGE}` (Ubuntu 24.04) and `${MOLECULE_IMAGE_2604}` (Ubuntu 26.04). Both containers get `NET_ADMIN`. The sequence runs prepare, converge, idempotence and verify; it has no check-mode step.
- Prepare installs ufw and stores rules the role must handle: an untagged manual rule, a manual rule the base list deletes, and tagged rules of service owners that are stale, removed or orphaned, some of them looking like an SSH path (port 22 with a source, no port, a range, an application profile named like SSH).
- Converge applies the base `ufw_rules` (one entry with `delete: true`), then calls `service_rules` for several owners (purge on, purge off, `absent`), and `orphan_rules` with no list, an empty list, report only and purge.
+1 -1
View File
@@ -9,8 +9,8 @@ galaxy_info:
platforms:
- name: Ubuntu
versions:
- jammy
- noble
- resolute
galaxy_tags:
- firewall
- ufw
+21 -3
View File
@@ -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}-ufw-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:
+3 -3
View File
@@ -4,9 +4,9 @@ Manages the primary ansible user and additional users, their `authorized_keys`,
## Supported platforms
Ubuntu 24.04 (noble), the only platform converged by a test (see [Tests](#tests)). The role installs sudo with apt.
Ubuntu 24.04 (noble) and 26.04 (resolute), the platforms the molecule scenario runs on (see [Tests](#tests)). The role installs sudo with apt.
Untested platforms: Ubuntu 22.04 (jammy) and Debian trixie (Proxmox VE nodes), listed in `meta/main.yml`.
Untested platforms: Debian trixie (Proxmox VE nodes), listed in `meta/main.yml`.
## Requirements and run order
@@ -64,7 +64,7 @@ Both are set under the `always` tag.
## Tests
`molecule/default` runs in the Collection's CI, on one platform: Ubuntu 24.04 (noble), the `molecule-ubuntu2404` image (`${MOLECULE_IMAGE}`). Prepare creates a stale user to remove, plants an extra key in an existing user's `authorized_keys` for authoritative mode to drop, and sets root's password before converge; the role then locks it. The converge sets the primary user explicitly instead of through the `{{ ansible_user }}` default.
`molecule/default` runs in CI only, on two platforms: `${MOLECULE_IMAGE}` (Ubuntu 24.04) and `${MOLECULE_IMAGE_2604}` (Ubuntu 26.04). Prepare creates a stale user to remove, plants an extra key in an existing user's `authorized_keys` for authoritative mode to drop, and sets root's password before converge; the role then locks it. The converge sets the primary user explicitly instead of through the `{{ ansible_user }}` default.
Verify checks:
+1 -1
View File
@@ -9,8 +9,8 @@ galaxy_info:
platforms:
- name: Ubuntu
versions:
- jammy
- noble
- resolute
- name: Debian
versions:
- trixie
@@ -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; NET_ADMIN keeps the container the same as the other role scenarios.
# 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; NET_ADMIN
# keeps the container the same as the other role scenarios.
driver:
name: docker
platforms:
@@ -22,6 +23,23 @@ platforms:
- NET_ADMIN
security_opts:
- apparmor=unconfined
- name: ${KAMINO_RUN_ID:-local}-user-management-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: