Author SHA1 Message Date
renovate-bot 38e5e6dc46 chore(deps): update git.rkdr.net/mortis/molecule-ubuntu2404 docker tag to v0.1.11
renovate/stability-days Updates have met minimum release age requirement
Build / build (pull_request) Successful in 58s
Molecule / molecule (pull_request) Canceled after 0s
Lint / lint (pull_request) Canceled after 2m33s
2026-11-27 09:57:42 +00:00
142 changed files with 992 additions and 4774 deletions

No files matched your search

-24
View File
@@ -1,24 +0,0 @@
---
# Merged under every scenario's molecule.yml. prerun off: the CI wrapper puts this checkout
# first on ANSIBLE_COLLECTIONS_PATH, so molecule's per-scenario install is unused.
prerun: false
provisioner:
# Merged over the docker driver's own connection vars, for the container hosts only: localhost
# keeps the controller's Python.
connection_options:
# Both molecule images ship it; a fixed path skips interpreter discovery in every playbook run.
ansible_python_interpreter: /usr/bin/python3
config_options:
connection:
# Pipe each module over stdin: without it every task pays extra docker exec and docker cp
# calls to make a temp dir, copy the module in and clean up.
pipelining: true
defaults:
# Gather each host's facts once per playbook run, not in every play.
gathering: smart
# Per-task timings, to see what a scenario's time goes to; ansible.posix is in the ci image
# and in requirements.yml, so the controller always has these callbacks.
callbacks_enabled: ansible.posix.profile_tasks, ansible.posix.timer
callback_profile_tasks:
summary_only: true
task_output_limit: 20
+11 -25
View File
@@ -80,25 +80,19 @@ issue.
- **What a pull request runs is chosen by `scripts/select_molecule_scenarios.py`:** the scenarios
of the roles it changes and of the roles that use them (any file naming
`mortis.kamino.<role>`, transitively), none for a diff of only IGNORED paths, a failure for a
changed role with no scenario, for a `.gitea/workflows/molecule.yml` diff of only comments
(outside `run:` scripts) or image pins the scenarios that name a changed `MOLECULE_IMAGE*` pin
(every scenario for `CI_IMAGE`, or when a shared molecule file names the pin), and every
scenario for any other file. *Why:* a full run takes
changed role with no scenario, and every scenario for any other file. *Why:* a full run takes
the single runner slot for a long time. *Held:* control: the selector and its tests.
- **A role named in an include, import, play `roles:` entry or meta dependency is written out in
full**, never bare or templated. *Why:* the selector finds dependent roles by their FQCN.
*Held:* control: a selector test fails a bare or templated name.
- **Scenarios load `mortis.kamino` from the checkout, never from an installed copy, so
`galaxy.yml` is on IGNORED.** *Why:* the checkout is first on `ANSIBLE_COLLECTIONS_PATH` and the
shared base config `.config/molecule/config.yml` turns off molecule's install of the collection
(`prerun: false`), so changes to `galaxy.yml`
- **Scenarios load `mortis.kamino` from the checkout, never from molecule's installed copy, so
`galaxy.yml` is on IGNORED.** *Why:* molecule installs the collection from `galaxy.yml` into
each scenario's `ANSIBLE_HOME`, which is not on `ANSIBLE_COLLECTIONS_PATH`, so its changes
(release versions, `build_ignore`) do not change what a scenario runs, and the Build check
proves the collection builds; they had caused about a third of full pull request runs and their
minutes (#338). *Held:* control: `scripts/check_scenarios_load_checkout.py`, which
`run_molecule_in_ci_image.sh` runs on the selected scenarios before they start, fails the run
when the environment molecule gives `ansible-playbook` resolves `mortis.kamino` anywhere else,
or when `prerun` is not off once the base config is merged as molecule's CLI merges it (a
scenario turns it on, or the base config is moved or turns it on).
when the environment molecule gives `ansible-playbook` resolves `mortis.kamino` anywhere else.
A pull request that selects no scenario runs no check; the next one that does, and the nightly
run, catch a change that broke the rule.
- **A new file outside `roles/<role>/` runs every scenario until it is added to IGNORED, and it
@@ -112,20 +106,12 @@ issue.
concurrency group of its own.** Runs may overlap on the runner's Docker daemon: every container
is named and labelled by its run (`KAMINO_RUN_ID`). The job first removes labelled containers
older than its timeout, which a cancelled run left, and finally its own. The scenarios of one
run overlap (`scripts/run_molecule_scenarios.sh`, `MOLECULE_LANES` at a time, 2 unless a manual
dispatch sets its `lanes` input), so no two scenarios may share a platform name. They start
longest first by the script's list of last full-run times, an unlisted one first; the logs stay
in selection order. A scenario still running at the script's per-scenario limit is stopped and
fails. *Why:* a cancelled run is killed before it can remove its instances, a younger container
may belong to a run still going, a long scenario started late sets the end of the run, and a
hang that fails alone inside the job timeout still lets every scenario's log print. *Held:*
review; control: the start order by `test_the_longest_scenarios_start_first` and the input by
`LanesInputTest`, both in `tests/scripts/test_run_molecule_scenarios.py`; control: the names and
labels by the test the `test_sequence` rule below names, and the sweep's age bound equal to the
job timeout by `test_the_sweep_spares_containers_younger_than_the_job_timeout` in
`tests/scripts/test_run_molecule_scenarios.py`; control: the limit by
`test_a_scenario_past_its_time_limit_fails_alone` and
`test_the_default_time_limit_is_inside_the_job_timeout`, in the same file.
run overlap (`scripts/run_molecule_scenarios.sh`, `MOLECULE_LANES` at a time), so no two
scenarios may share a platform name. *Why:* a cancelled run is killed before it can remove its
instances, and a younger container may belong to a run still going. *Held:* review; control:
the names and labels by the test the `test_sequence` rule below names, and the sweep's age bound
equal to the job timeout by `test_the_sweep_spares_containers_younger_than_the_job_timeout` in
`tests/scripts/test_run_molecule_scenarios.py`.
- **Molecule tests the pull request's pins, as Lint and Build do.** It runs molecule in the pinned
`ci` image and, when a pin file differs from `/opt/ci-pins.sha256`, installs the pull request's
tools and the collections of `requirements.yml` and `extensions/molecule/requirements.yml` first.
+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.48@sha256:d1c6653255abf366462c0265d9372626d5b59095084fe74ae95b9ebe7414007d
image: git.rkdr.net/mortis/ci:0.2.46@sha256:a03015cc2177bdd6ef7f348f245a89f361893c7c64edc1264d9f9c1387d9defc
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.48@sha256:d1c6653255abf366462c0265d9372626d5b59095084fe74ae95b9ebe7414007d
image: git.rkdr.net/mortis/ci:0.2.46@sha256:a03015cc2177bdd6ef7f348f245a89f361893c7c64edc1264d9f9c1387d9defc
steps:
# The container has no Node, so JavaScript actions such as actions/checkout
# cannot run; clone with git and the job token.
+1 -1
View File
@@ -79,7 +79,7 @@ jobs:
base: "0.1"
subpath: images/molecule-ubuntu2404
dockerfile: Dockerfile
job_image: ubuntu:24.04@sha256:562111b88caa79c71391c0c4d3c2114a7d5c35915c20561fd893cb1e07929e6b
job_image: ubuntu:24.04@sha256:9c7f200c07e3d4a03e7249d2c16bf66a51120fb876aa2242cf31451412543289
- name: molecule-ubuntu2604
base: "0.1"
subpath: images/molecule-ubuntu2604
+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.48@sha256:d1c6653255abf366462c0265d9372626d5b59095084fe74ae95b9ebe7414007d
image: git.rkdr.net/mortis/ci:0.2.46@sha256:a03015cc2177bdd6ef7f348f245a89f361893c7c64edc1264d9f9c1387d9defc
env:
PIP_DISABLE_PIP_VERSION_CHECK: "1"
PRE_COMMIT_HOME: /opt/pre-commit
+3 -11
View File
@@ -24,13 +24,7 @@ on: # yamllint disable-line rule:truthy
# drift in the others (a package mirror) would otherwise go unseen. After Renovate's 03:17 run.
schedule:
- cron: "43 4 * * *"
workflow_dispatch:
inputs:
lanes:
description: Scenarios run at a time (empty for the default of run_molecule_scenarios.sh)
required: false
type: string
default: ""
workflow_dispatch: {}
permissions:
contents: read
@@ -59,7 +53,7 @@ jobs:
env:
# The tools and collections molecule runs with: the image Lint and Build use.
CI_IMAGE: >-
git.rkdr.net/mortis/ci:0.2.48@sha256:d1c6653255abf366462c0265d9372626d5b59095084fe74ae95b9ebe7414007d
git.rkdr.net/mortis/ci:0.2.46@sha256:a03015cc2177bdd6ef7f348f245a89f361893c7c64edc1264d9f9c1387d9defc
# Used by the scenarios as `image: ${MOLECULE_IMAGE}`; set it the same way to run
# one locally.
MOLECULE_IMAGE: >-
@@ -129,8 +123,6 @@ jobs:
EVENT_NAME: ${{ github.event_name }}
# The workflow only runs for pull requests to main; lint.yml uses the same constant.
BASE_REF: origin/main
# Empty outside a dispatch, which the run script reads as its default.
MOLECULE_LANES: ${{ inputs.lanes }}
run: |
# The selector comes from the base branch, so a pull request cannot edit the rules it is
# judged by (lint.yml does the same for check_bot_pr_diff.py); the first pull request that
@@ -162,7 +154,7 @@ jobs:
-v /var/run/docker.sock:/var/run/docker.sock -v "$docker_cli:/usr/local/bin/docker:ro" \
-v "$ac_root:$ac_root" -v "$ac_root/passwd:/etc/passwd:ro" -w "$PWD" \
-e "AC_ROOT=$ac_root" -e "HOME=$ac_root/home" -e "USER=$(id -un)" \
-e MOLECULE_IMAGE -e MOLECULE_IMAGE_2604 -e KAMINO_RUN_ID -e MOLECULE_LANES \
-e MOLECULE_IMAGE -e MOLECULE_IMAGE_2604 -e KAMINO_RUN_ID \
"$CI_IMAGE" scripts/run_molecule_in_ci_image.sh <<< "$selected"
# A cancelled run can leave its containers running when the docker client is killed.
+1 -2
View File
@@ -13,11 +13,10 @@ vault-pass*
gitleaks-report.json
# galaxy-importer output
importer_result.json
# APM: apm_modules/ is the dependency cache. Deployed skills, agents and commands stay out
# APM: apm_modules/ is the dependency cache. Deployed skills and agents stay out
# while their source is private; deployed hooks are committed for review.
apm_modules/
.claude/skills/
.claude/agents/
.claude/commands/
# Claude Code: personal settings and allowlists, never shared
.claude/settings.local.json
-21
View File
@@ -4,27 +4,6 @@ mortis.kamino Release Notes
.. contents:: Topics
v3.2.0
======
Minor Changes
-------------
- cloudflared - New input ``cloudflared_tunnel_lookup_delay``, the seconds between the three retries of a 404 from the tunnel lookup while a new tunnel may not be visible yet. The default is 5, as before.
- docker, system_baseline - The install tasks that only use the distribution's sources (docker's prerequisites, system_baseline's packages) refresh the APT cache only when it is older than an hour; before, every run refreshed it. Installs from a role's own APT source still refresh it on every run.
- system_baseline - Add ``system_baseline_extra_packages`` and ``system_baseline_extra_remove_packages`` (lists, default empty), which append to the resolved package lists, where setting ``system_baseline_essential_packages`` or ``system_baseline_remove_packages`` replaces the profile's whole list. An extra ``tmux`` or ``unattended-upgrades`` enables the matching task like a profile package. A package that one input installs and another purges stops the run before any change. With both inputs left at their default the role behaves as before.
- system_baseline - Add the input ``system_baseline_skip_upgrade_during_vzdump`` (default ``false``). With ``true`` on the ``pve`` system type, the main flow and the ``update`` entry point skip the apt upgrade while ``pvesh get /nodes/localhost/tasks --source active`` lists a ``vzdump`` task, and say so. With the default no ``pvesh`` command runs and the upgrade is unchanged.
- system_baseline - ``system_baseline_journal_max_use`` can be empty to leave journald alone: the role then writes no drop-in and does not restart ``systemd-journald``. The default stays ``200M``.
- system_baseline - ``system_baseline_journal_max_use`` is checked before any change: it must be empty or a size journald reads, a number with an optional upper-case ``B``, ``K``, ``M``, ``G``, ``T``, ``P`` or ``E``. A value journald rejects, which the role used to write into the drop-in as it was and journald then ignored (``infinity``, a lower-case unit, a line break), now stops the run; an empty value used to write an empty ``SystemMaxUse=``.
- traefik - New input ``traefik_release_url`` sets where the release archive and checksums are downloaded from, for a mirror (default: the GitHub releases, as before).
Bugfixes
--------
- docker - Read the distribution release through ``ansible_facts['distribution_release']`` for the APT source line, so the role works with ``inject_facts_as_vars`` set to false and in the ansible-core release that stops injecting facts as variables. The source line is unchanged.
- gitea_runner - Read the timestamp of the forced re-registration backup through ``ansible_facts['date_time']``, so the role works with ``inject_facts_as_vars`` set to false and in the ansible-core release that stops injecting facts as variables. The backup name is unchanged.
- system_baseline - Read the OS family through ``ansible_facts['os_family']`` in the reboot check, so the role (and its ``reboot`` entry point) works with ``inject_facts_as_vars`` set to false and in the ansible-core release that stops injecting facts as variables. Before, the task failed with ``'ansible_os_family' is undefined`` there.
v3.1.0
======
+6 -4
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`,
`nfs_client`, `pihole`, `pve_lxc`, `pve_vm`, `sshd`, `system_baseline`, `systemd_hardening`, `tailscale`, `traefik`,
`ufw` and `user_management`, plus the internal `_binary_update`. Roles still to come are listed under [Roadmap](#roadmap).
`pihole`, `pve_lxc`, `sshd`, `system_baseline`, `systemd_hardening`, `tailscale`, `traefik`, `ufw` and
`user_management`, plus the internal `_binary_update`. Roles still to come are listed under [Roadmap](#roadmap).
Status: roles arrive in waves. Release 3.2.0 holds the `cloudflared`, `docker`, `fail2ban`, `gitea`, `gitea_runner`, `network_interfaces`, `pihole`, `pve_lxc`, `sshd`, `system_baseline`, `systemd_hardening`, `tailscale`, `traefik`, `ufw` and `user_management` roles (and the internal `_binary_update`, which `cloudflared`, `gitea`, `gitea_runner` and `traefik` call). `nfs_client` and `pve_vm` are on `main` for the next release.
Status: roles arrive in waves. Release 3.1.0 holds the `cloudflared`, `docker`, `fail2ban`, `gitea`, `gitea_runner`, `network_interfaces`, `pihole`, `pve_lxc`, `sshd`, `system_baseline`, `systemd_hardening`, `tailscale`, `traefik`, `ufw` and `user_management` roles (and the internal `_binary_update`, which `cloudflared`, `gitea`, `gitea_runner` and `traefik` call).
## Consuming
@@ -17,7 +17,7 @@ name (FQCN) only, `mortis.kamino.<role>`:
collections:
- name: https://git.rkdr.net/mortis/kamino.git
type: git
version: v3.2.0
version: v3.1.0
```
Its dependencies (`community.general`, `ansible.posix`, `community.proxmox`) are declared in `galaxy.yml`, so
@@ -41,7 +41,9 @@ when its own prerequisites (tests, a safe cutover wherever the role already runs
Still to come:
- Wave 2: `pve_vm`.
- Wave 3: `rke2`, `proxmox_host`.
- Later, wave not yet assigned: `opnsense`, `proxmox_firewall`.
Will not be extracted (they serve one lab or install that lab's own tool pins):
`k8s_manage`, `k8s_localhost`, `k8s_lint_tools`, `minecraft_server`, `dragonwilds_server`,
+28 -227
View File
@@ -1,13 +1,11 @@
lockfile_version: '4'
generated_at: '2026-11-29T13:12:37.842657+00:00'
apm_version: 0.38.1
manifest_targets:
- claude
lockfile_version: '1'
generated_at: '2026-11-22T17:33:38.751913+00:00'
apm_version: 0.36.1
dependencies:
- repo_url: Mortis/Holocron
name: git
host: git.rkdr.net
resolved_commit: 219a084c252f1dfe229f1bc55e1323b4cd197516
resolved_commit: 67803f84f21bb4bae91144c46d39a0fae6754ef5
version: 1.3.9
virtual_path: plugins/git
is_virtual: true
@@ -135,11 +133,7 @@ dependencies:
.claude/skills/pc-run/references/failure-patterns.md: sha256:c760a933a937d5c33206f918089a49afd8335de3854093f5c32494e71019378c
.claude/skills/pc-run/references/install.md: sha256:71ec08d58b8797b09574a827ea06d2c9656e3394d40534860fdaf333f5c19070
.claude/skills/pc-run/references/sources.md: sha256:ed47302b3fa003ca203cf6677905032f687ff5e07e3d551593865116d9ce11f1
content_hash: sha256:db45863914da8edc054526af825a3c2354584340f1e46d123b407053587cf05a
package_targets:
- claude
- codex
- copilot
content_hash: sha256:3fe59051e46ae66e09a62b121342e619720f3a669f9c25b2c1ed7bf7a537f646
declared_license: MIT
carried_licenses:
- path: .apm/skills/git-branches/LICENSE
@@ -175,75 +169,17 @@ dependencies:
- repo_url: Mortis/Holocron
name: mattpocock
host: git.rkdr.net
resolved_commit: 219a084c252f1dfe229f1bc55e1323b4cd197516
version: 0.5.0
resolved_commit: 67803f84f21bb4bae91144c46d39a0fae6754ef5
version: 0.4.0
virtual_path: plugins/mattpocock
is_virtual: true
package_type: apm_package
content_hash: sha256:dc4bda559aea7d4001b9491d781ffe073e00e339d6a4db70cd4922b365e588ef
package_targets:
- claude
- codex
- copilot
content_hash: sha256:91649428cf594bd911beb982282f92f7b732908db649d484e420c0ba1d6b6b7b
declared_license: MIT
carried_licenses:
- path: LICENSE
source: LICENSE
hash: sha256:9d3692e6b35e0e43b81e096352f11c6b884e7004d78d3dcd92768232c6704525
- repo_url: Mortis/Holocron
name: plan
host: git.rkdr.net
resolved_commit: 219a084c252f1dfe229f1bc55e1323b4cd197516
version: 0.4.0
virtual_path: plugins/plan
is_virtual: true
package_type: apm_package
deployed_files:
- .claude/agents/plan-gate.md
- .claude/agents/plan-recorder.md
- .claude/agents/plan-researcher.md
- .claude/agents/plan-validator.md
- .claude/commands/next.md
- .claude/commands/plan.md
- .claude/commands/ship.md
- .claude/skills/plan-track
- .claude/skills/plan-track/LICENSE
- .claude/skills/plan-track/SKILL.md
- .claude/skills/research-docs
- .claude/skills/research-docs/LICENSE
- .claude/skills/research-docs/SKILL.md
- .claude/skills/research-docs/references/file-format.md
- .claude/skills/research-docs/references/topics.md
deployed_file_hashes:
.claude/agents/plan-gate.md: sha256:c1c89bae5dd59de122603c2caf1907e8eaf38244cf007dd1942df8cea616a8ca
.claude/agents/plan-recorder.md: sha256:a5283798a574900d4b78dbbbcdf78b9ae0997e8496f5971f0085cfad87c1fea0
.claude/agents/plan-researcher.md: sha256:eda0457d2007cf0c6cb4745383a0369d03a26ed252d7251a1f5250003a89ef85
.claude/agents/plan-validator.md: sha256:a56e7a710fd9e7a9dd9e2601f1f2701b98fd229f3e014bba4bda4dfe5977ecae
.claude/commands/next.md: sha256:8e16330ec0f16dbbc86d44fca94699e33e393c9a8af76f45d3f3bd2b9c8bfa1f
.claude/commands/plan.md: sha256:2538b3dbb3860ebe93a39cad95cd5a1adcbeded19f404a84201b3e8aa7ce91c7
.claude/commands/ship.md: sha256:f108f73e60a884f46285955027fba47d6309fed6a89812948f577e27be180af8
.claude/skills/plan-track/LICENSE: sha256:9d3692e6b35e0e43b81e096352f11c6b884e7004d78d3dcd92768232c6704525
.claude/skills/plan-track/SKILL.md: sha256:fee5062c8c63b49f66368b290c8ebd8cfff744137670d0c037da1a49c455c047
.claude/skills/research-docs/LICENSE: sha256:9d3692e6b35e0e43b81e096352f11c6b884e7004d78d3dcd92768232c6704525
.claude/skills/research-docs/SKILL.md: sha256:93023786f71dac5a77e60eca0be09e6510dfd45509f5e8cbc755395fe8774539
.claude/skills/research-docs/references/file-format.md: sha256:29d5583beaa531d26895c54def112039730490c312401648a6bdb7dd5278fb3c
.claude/skills/research-docs/references/topics.md: sha256:757abb7b6be44c3d3c0dd1f4818a344e08877810d36bf8be60ea7189cba8d12f
content_hash: sha256:7f7e9f5e4a2e6be218b9dc157f9f4a069457500c5ef78ff2ad137c8af7e98e8f
package_targets:
- claude
- codex
- copilot
declared_license: MIT
carried_licenses:
- path: .apm/skills/plan-track/LICENSE
source: LICENSE
hash: sha256:9d3692e6b35e0e43b81e096352f11c6b884e7004d78d3dcd92768232c6704525
- path: .apm/skills/research-docs/LICENSE
source: LICENSE
hash: sha256:9d3692e6b35e0e43b81e096352f11c6b884e7004d78d3dcd92768232c6704525
- path: LICENSE
source: LICENSE
hash: sha256:9d3692e6b35e0e43b81e096352f11c6b884e7004d78d3dcd92768232c6704525
- repo_url: mattpocock/skills
name: code-review
host: github.com
@@ -264,7 +200,7 @@ dependencies:
.claude/skills/code-review/LICENSE: sha256:0e7ac423bf2c6e223b7c5b156f8cf72da49d748e56a1641402c31f22ad07dbb5
.claude/skills/code-review/SKILL.md: sha256:9c921a8d88138a41401d8897ca1bb852088ab1b7b605cdd04edc13e3e8aab6dd
.claude/skills/code-review/agents/openai.yaml: sha256:8229ca854e11dc8e6aef2131ee03f31fb1561cf905fab9ccc325180cf3331352
content_hash: sha256:e14d83d727f514a484858272f5a45d83d42ba7f84c078758a0341ffe6e8832e5
content_hash: sha256:cf233fee7275f8d00b5d2f11da948738531eee9ae7cc8d5b13f815f39fef1c9f
carried_licenses:
- path: LICENSE
source: LICENSE
@@ -293,7 +229,7 @@ dependencies:
.claude/skills/codebase-design/LICENSE: sha256:0e7ac423bf2c6e223b7c5b156f8cf72da49d748e56a1641402c31f22ad07dbb5
.claude/skills/codebase-design/SKILL.md: sha256:2c20617f87ec8af6a434859f381b2f061a69b530444e74eb39e78bb016a6d1e2
.claude/skills/codebase-design/agents/openai.yaml: sha256:edebc9e4fcfe102114012575eaa9600b9b5fd08c311664f389c36e7bc717740f
content_hash: sha256:0eece2d6148eede9eebea3989944ea6215b809204352ca82a3a83203b79b78b4
content_hash: sha256:667012327c54634ddc0fea22ccdf5d43c797b97038a6d4aadc09de29d50d0185
carried_licenses:
- path: LICENSE
source: LICENSE
@@ -320,7 +256,7 @@ dependencies:
.claude/skills/diagnosing-bugs/SKILL.md: sha256:849198df88cdb65fd0d97236604c1fca7ff2f22d2f705f9724a800d0266b118d
.claude/skills/diagnosing-bugs/agents/openai.yaml: sha256:3e430dbe4334a87597488c060cb3dc3786bb00c9182877d6f5ec41f62490e90b
.claude/skills/diagnosing-bugs/scripts/hitl-loop.template.sh: sha256:35103539fc36873eea36074769ad454f9379d6fc8b2dc0e26ce987fd3bfe5503
content_hash: sha256:eb364bd413d5b65ec3360466dfc8fe36a2f6c6de6a2c84a3b39bbf60fdbc120d
content_hash: sha256:9b24ecaf15dd8d5594f973c590c6904d90dd3b50f8853fefd2341b7fd4a156bf
carried_licenses:
- path: LICENSE
source: LICENSE
@@ -349,7 +285,7 @@ dependencies:
.claude/skills/domain-modeling/LICENSE: sha256:0e7ac423bf2c6e223b7c5b156f8cf72da49d748e56a1641402c31f22ad07dbb5
.claude/skills/domain-modeling/SKILL.md: sha256:7b925d7b1e341a2eeae33ad68a8a8c0ab889a38ddd22a7598e4c240e5a7556a3
.claude/skills/domain-modeling/agents/openai.yaml: sha256:f6bf2aa996c6e6f53fdd0708e18a0d16a56aed8322cca59fedbe3c0d2c75f06b
content_hash: sha256:ab7acbca5aaf6e976caef1ccd1c14bac9459702f5b8e9d6d96e5a8ca8e3c7ee9
content_hash: sha256:467f5e92529c2a4637440dce99841814b0864a8528714188ec91b78d900df540
carried_licenses:
- path: LICENSE
source: LICENSE
@@ -374,7 +310,7 @@ dependencies:
.claude/skills/grill-with-docs/LICENSE: sha256:0e7ac423bf2c6e223b7c5b156f8cf72da49d748e56a1641402c31f22ad07dbb5
.claude/skills/grill-with-docs/SKILL.md: sha256:7de372c13488f1ee96cc11cd8907b56b6809cc93eef776eeddd37de6b6cbe3fe
.claude/skills/grill-with-docs/agents/openai.yaml: sha256:94cd0ab161fb468a836349f5ed482ba58ce8e709a05c57ce533d739dbd35cca9
content_hash: sha256:8973c3d9463fc9dd708adc36a0f97b01aab4ae7d6a0217c2aa0f0a7ef206b83c
content_hash: sha256:9e8f732b806727978f1ad8d2fb9ce4467da68f7482d63c4bb5a73f2b1a0c797c
carried_licenses:
- path: LICENSE
source: LICENSE
@@ -399,7 +335,7 @@ dependencies:
.claude/skills/implement/LICENSE: sha256:0e7ac423bf2c6e223b7c5b156f8cf72da49d748e56a1641402c31f22ad07dbb5
.claude/skills/implement/SKILL.md: sha256:483bdc4ccf4ac31d86ac7beeaa0d0db80313e71e120bb8c59b3196ae5decd53d
.claude/skills/implement/agents/openai.yaml: sha256:8970a8596ade0c28ab427f41a4ea242d6bdf6186c59ebf55e1238dbecaab79dc
content_hash: sha256:3465060b2e4776f9e791293720a66869f265c83f9a5323e3ab0115f0558cc65b
content_hash: sha256:c7c4d38c8dd9a05fcad046f79aeb275c7f31a87d7bceb4f3a133f125e6f4bfbb
carried_licenses:
- path: LICENSE
source: LICENSE
@@ -424,7 +360,7 @@ dependencies:
.claude/skills/implement-spec/LICENSE: sha256:0e7ac423bf2c6e223b7c5b156f8cf72da49d748e56a1641402c31f22ad07dbb5
.claude/skills/implement-spec/SKILL.md: sha256:8d8300f7f12325dbfc99cad124a4bcc96ac0d02d0b2d73dfb348e9262afacfc4
.claude/skills/implement-spec/agents/openai.yaml: sha256:fd41efb42c60c96320d6531be7e4bf15cbf5518cd652d57dff27ccffa46988e9
content_hash: sha256:e4d15f81cc620dc479ffe852de453e47090f79edde7dcfe912de64018b183256
content_hash: sha256:254a8c69719a6644fc462085569251b3fc8365770428738fc7bbb5398a3aa1fb
carried_licenses:
- path: LICENSE
source: LICENSE
@@ -451,7 +387,7 @@ dependencies:
.claude/skills/improve-codebase-architecture/LICENSE: sha256:0e7ac423bf2c6e223b7c5b156f8cf72da49d748e56a1641402c31f22ad07dbb5
.claude/skills/improve-codebase-architecture/SKILL.md: sha256:35b03a3db61e0f5aa333ea59b54963e45a3d2ace6649b2ef4f9576603e2582a6
.claude/skills/improve-codebase-architecture/agents/openai.yaml: sha256:c8cb20f68ebf0edb4e497bc11ae5fcaa196004e661cd189015b04f4109ced7f1
content_hash: sha256:3c72a8a3852beda9b28b6a14ce665506ea57a59a76568cf826873ec17d798c5a
content_hash: sha256:499043a54914592b8d40160e0ecae3787452869aed4fce50c3e574c1926329d8
carried_licenses:
- path: LICENSE
source: LICENSE
@@ -480,7 +416,7 @@ dependencies:
.claude/skills/prototype/SKILL.md: sha256:714de632d116bb73f65cdb5a882db15b9369a6713b9a47c0fad827848f0bfbe3
.claude/skills/prototype/UI.md: sha256:723211e878acbc7b6ff09755263f3295cde724ba902ff0064da41eed51d45ad3
.claude/skills/prototype/agents/openai.yaml: sha256:5af65e43ab41a350436697b81e27b7f848d36782043b73c322bb2c9fa9cc55dc
content_hash: sha256:6890ef757ada4b0b571e74c28b69fda697ba2e18f564860f4c9373cbbe50535c
content_hash: sha256:090ae76b97353255ca29be783d69bcc1029e0195bdf43118d0b6f7ea9acc89b0
carried_licenses:
- path: LICENSE
source: LICENSE
@@ -505,7 +441,7 @@ dependencies:
.claude/skills/research/LICENSE: sha256:0e7ac423bf2c6e223b7c5b156f8cf72da49d748e56a1641402c31f22ad07dbb5
.claude/skills/research/SKILL.md: sha256:1f629e18ab899412683bc6a1c4efb4339999e27c2fdac328f26ee10a8c031d33
.claude/skills/research/agents/openai.yaml: sha256:9b4c470d63221c1f68f22df70b83e2f12401b317babe0d1b7b5f24a974474d0d
content_hash: sha256:4a52e8e17a984526a0f3f25bc138097b4ca8b5f15e35b7c318fa024c6b04e0fd
content_hash: sha256:34a7c3808288b05ea422affe978ee4d301239817d822f4f50687f1957c17cf9a
carried_licenses:
- path: LICENSE
source: LICENSE
@@ -530,7 +466,7 @@ dependencies:
.claude/skills/retro/LICENSE: sha256:0e7ac423bf2c6e223b7c5b156f8cf72da49d748e56a1641402c31f22ad07dbb5
.claude/skills/retro/SKILL.md: sha256:33fbc28568e3146f20fd908b12998bc0ab30aa4f4c87288199a40793efa94696
.claude/skills/retro/agents/openai.yaml: sha256:cb6fb9d7e6b4be5975f41f6def1dd00a1255bad5d9b02696b124c924a8b8745c
content_hash: sha256:4d42bb16dc68325fe941153ff3341f8be8f770121479bc41921d477d27a45ad5
content_hash: sha256:e13af4f6dfecd777815adde57811398dc59d0118692a70d996968b59e3d13db8
carried_licenses:
- path: LICENSE
source: LICENSE
@@ -565,7 +501,7 @@ dependencies:
.claude/skills/setup-matt-pocock-skills/issue-tracker-gitlab.md: sha256:947602d33a80f98f939fb990995b8f95a3459b114b919c4221d08bd75d7cffe0
.claude/skills/setup-matt-pocock-skills/issue-tracker-local.md: sha256:7dcda20a2eb4bdc89b95d1143423c0691309921cadae3132e6424f371030506e
.claude/skills/setup-matt-pocock-skills/triage-labels.md: sha256:ae512af838c78b8750471c42cd2b20fa32319553e61d84c9a23d171b40ce14aa
content_hash: sha256:fb96a61c2698a9f4299778861547b92f11719d033d1cd5dea7e95a98fe8e438a
content_hash: sha256:f8f92182cd38f90a66bc50b9408da5de83cbda1e4abaffbb8a7428beabcf6f5d
carried_licenses:
- path: LICENSE
source: LICENSE
@@ -594,7 +530,7 @@ dependencies:
.claude/skills/tdd/agents/openai.yaml: sha256:ea6f01cf1b8c06a4b0f5b649d74b1b8ce8685e72af1b38d70d877693e092af0b
.claude/skills/tdd/mocking.md: sha256:3ceb807fdf4a47d6a93d4d9a891e5ba6d362a6247bd08adc451feebfc17361ef
.claude/skills/tdd/tests.md: sha256:859f9e592c188fda4fc7277dd180e4ce9c7a2e13f6efe1f6f29eccc9d28c106a
content_hash: sha256:cb510a538834fd446bae7cff1e6e46c4b625524d162bfc56c6d64486115a48e3
content_hash: sha256:ef3cbb31aa8b1f8a3f9b6a042c230dc9312019e84cdc6337f60890f177fd5764
carried_licenses:
- path: LICENSE
source: LICENSE
@@ -619,7 +555,7 @@ dependencies:
.claude/skills/to-spec/LICENSE: sha256:0e7ac423bf2c6e223b7c5b156f8cf72da49d748e56a1641402c31f22ad07dbb5
.claude/skills/to-spec/SKILL.md: sha256:43ad9cf318e5e7d3d1fa360253a37021796dc87a0c2e595ad262661a10f85088
.claude/skills/to-spec/agents/openai.yaml: sha256:1c5b4d1e3d8e52287ef19cc2742fdbbfae1914ac75d33af3e4c8174f08cc55bb
content_hash: sha256:7c0ac5892441627cbe76e8587d47cbe3adedc61f779df5c9f82d473588503330
content_hash: sha256:cc5d718c2f810f4c9b081ea888af3ad3eb73bb8db6fc9fa92c3b1729637b7d56
carried_licenses:
- path: LICENSE
source: LICENSE
@@ -644,7 +580,7 @@ dependencies:
.claude/skills/to-tickets/LICENSE: sha256:0e7ac423bf2c6e223b7c5b156f8cf72da49d748e56a1641402c31f22ad07dbb5
.claude/skills/to-tickets/SKILL.md: sha256:56ec23c5b2782785d4e65bff9e315b6d3aeb4ef977c174a219e99489fada1995
.claude/skills/to-tickets/agents/openai.yaml: sha256:21bc6215fffcd7614e9f772bb1760e87cc5fc7dcc707e7d282bc9414267a6090
content_hash: sha256:7e0aa33c2d0ccd99d92a7b45405243f7a948425e161723d4535f178ee0af3d59
content_hash: sha256:7cca8cd2afe55d1cd8bfc986df6a4cb4ad54411452575200804494b03c871ede
carried_licenses:
- path: LICENSE
source: LICENSE
@@ -673,7 +609,7 @@ dependencies:
.claude/skills/triage/OUT-OF-SCOPE.md: sha256:1fbf9b432130c6380aa65813b55553cfda150309b27c595e183f8e335b8a190d
.claude/skills/triage/SKILL.md: sha256:917b0baf74be583e74f110857ed45df2766617f75c00baf61fd136d7af515edf
.claude/skills/triage/agents/openai.yaml: sha256:2e683717720cf456d165d0bb1a68bb600d0b6a8ccb61841c172e50d26f95351c
content_hash: sha256:cc3930f2f501738b67c5d3397518d537ffaf252c679bded57b090f2d31de0a22
content_hash: sha256:bf09f37fa24ab64324497772a25a1e0a9b22d06ccb238fefd0cfb12eee473c3d
carried_licenses:
- path: LICENSE
source: LICENSE
@@ -698,7 +634,7 @@ dependencies:
.claude/skills/wayfinder/LICENSE: sha256:0e7ac423bf2c6e223b7c5b156f8cf72da49d748e56a1641402c31f22ad07dbb5
.claude/skills/wayfinder/SKILL.md: sha256:0c9fa96791aebf3b7d654cf35c6aadde97d81f57c17b07d13b27c14d9c46561f
.claude/skills/wayfinder/agents/openai.yaml: sha256:88bc81a11a6d52ac67aeaa76b8b619e387020d47c5133a4dd4927fd15c4ad073
content_hash: sha256:92acbe1ee44d0ecd91e8ff08d09d8d78dabf8f2d5fa56ef3d977db1cb2a5457a
content_hash: sha256:eec9b3ec0cd815b708670bf163384d257c7d1350ccb823f66043cbe138794298
carried_licenses:
- path: LICENSE
source: LICENSE
@@ -723,7 +659,7 @@ dependencies:
.claude/skills/grill-me/LICENSE: sha256:0e7ac423bf2c6e223b7c5b156f8cf72da49d748e56a1641402c31f22ad07dbb5
.claude/skills/grill-me/SKILL.md: sha256:caaf8b8de1684f96e26b28f3c29189db5c89cce4b73e1c93d86164f66ef88637
.claude/skills/grill-me/agents/openai.yaml: sha256:c061e39c3e0f9d865fb1b97556d485704af2a8a58f4b8221a8917a5c2074a32b
content_hash: sha256:eb2880386e9259f4ca51167f518c81cea969850d8f45bd8f79f579dcbbad902e
content_hash: sha256:fe33aaa8e8dcd606107b1bfe3109f257b4a7e0f4907afd6506b62ccfb73cd1d3
carried_licenses:
- path: LICENSE
source: LICENSE
@@ -748,7 +684,7 @@ dependencies:
.claude/skills/grilling/LICENSE: sha256:0e7ac423bf2c6e223b7c5b156f8cf72da49d748e56a1641402c31f22ad07dbb5
.claude/skills/grilling/SKILL.md: sha256:a146842ed93ca43d833550fa9adf02e58cb63c83fea9d4b4522995b82242d4e2
.claude/skills/grilling/agents/openai.yaml: sha256:1411d7df7d99b7e621a1ff8283c8133cc2464be63d064e52d8ce169c6800ee9b
content_hash: sha256:e0e4918ef2675bf3bc0e48fa83c40446cd961c107afdf435cbc2daa774cb0efe
content_hash: sha256:823f08ad33368a9626991e6782f7ae14b958e39ef8503f6bdb3b98a58d237a58
carried_licenses:
- path: LICENSE
source: LICENSE
@@ -775,7 +711,7 @@ dependencies:
.claude/skills/writing-for-agents/SKILL-MECHANICS.md: sha256:c768e6307c7c10728c401c213f2c4ba71c542127eeb7ad2956aabd15a0fa0059
.claude/skills/writing-for-agents/SKILL.md: sha256:551adca942227b44192edba88acd4e8db911f0121ce58ad16944ccf6a896a74a
.claude/skills/writing-for-agents/agents/openai.yaml: sha256:eacb24b2a618cfb81dacb0416f4fdd75ddf3a8060f8ddb99aae1b1e301907e4b
content_hash: sha256:dfc57c19e0f7a7e9c371966d765700d74ecae7694377c095095ee94f6fd216b3
content_hash: sha256:8365ebe1d0c343d3d46970526f30fcf7c5e0c5e49fd39a3c882977024626ff3c
carried_licenses:
- path: LICENSE
source: LICENSE
@@ -790,69 +726,6 @@ deployments:
- git.rkdr.net/Mortis/Holocron/plugins/git
active_owner: git.rkdr.net/Mortis/Holocron/plugins/git
content_hash: sha256:c9122bac28dc079efb041acc720dd097c62fdb49d9b1d9a62b15ac5ee6c47032
- kind: project-relative
target: claude
value: .claude/agents/plan-gate.md
runtime: null
scope: project
owners:
- git.rkdr.net/Mortis/Holocron/plugins/plan
active_owner: git.rkdr.net/Mortis/Holocron/plugins/plan
content_hash: sha256:c1c89bae5dd59de122603c2caf1907e8eaf38244cf007dd1942df8cea616a8ca
- kind: project-relative
target: claude
value: .claude/agents/plan-recorder.md
runtime: null
scope: project
owners:
- git.rkdr.net/Mortis/Holocron/plugins/plan
active_owner: git.rkdr.net/Mortis/Holocron/plugins/plan
content_hash: sha256:a5283798a574900d4b78dbbbcdf78b9ae0997e8496f5971f0085cfad87c1fea0
- kind: project-relative
target: claude
value: .claude/agents/plan-researcher.md
runtime: null
scope: project
owners:
- git.rkdr.net/Mortis/Holocron/plugins/plan
active_owner: git.rkdr.net/Mortis/Holocron/plugins/plan
content_hash: sha256:eda0457d2007cf0c6cb4745383a0369d03a26ed252d7251a1f5250003a89ef85
- kind: project-relative
target: claude
value: .claude/agents/plan-validator.md
runtime: null
scope: project
owners:
- git.rkdr.net/Mortis/Holocron/plugins/plan
active_owner: git.rkdr.net/Mortis/Holocron/plugins/plan
content_hash: sha256:a56e7a710fd9e7a9dd9e2601f1f2701b98fd229f3e014bba4bda4dfe5977ecae
- kind: project-relative
target: claude
value: .claude/commands/next.md
runtime: null
scope: project
owners:
- git.rkdr.net/Mortis/Holocron/plugins/plan
active_owner: git.rkdr.net/Mortis/Holocron/plugins/plan
content_hash: sha256:8e16330ec0f16dbbc86d44fca94699e33e393c9a8af76f45d3f3bd2b9c8bfa1f
- kind: project-relative
target: claude
value: .claude/commands/plan.md
runtime: null
scope: project
owners:
- git.rkdr.net/Mortis/Holocron/plugins/plan
active_owner: git.rkdr.net/Mortis/Holocron/plugins/plan
content_hash: sha256:2538b3dbb3860ebe93a39cad95cd5a1adcbeded19f404a84201b3e8aa7ce91c7
- kind: project-relative
target: claude
value: .claude/commands/ship.md
runtime: null
scope: project
owners:
- git.rkdr.net/Mortis/Holocron/plugins/plan
active_owner: git.rkdr.net/Mortis/Holocron/plugins/plan
content_hash: sha256:f108f73e60a884f46285955027fba47d6309fed6a89812948f577e27be180af8
- kind: project-relative
target: claude
value: .claude/skills/code-review
@@ -1843,33 +1716,6 @@ deployments:
- git.rkdr.net/Mortis/Holocron/plugins/git
active_owner: git.rkdr.net/Mortis/Holocron/plugins/git
content_hash: sha256:ed47302b3fa003ca203cf6677905032f687ff5e07e3d551593865116d9ce11f1
- kind: project-relative
target: claude
value: .claude/skills/plan-track
runtime: null
scope: project
owners:
- git.rkdr.net/Mortis/Holocron/plugins/plan
active_owner: git.rkdr.net/Mortis/Holocron/plugins/plan
content_hash: null
- kind: project-relative
target: claude
value: .claude/skills/plan-track/LICENSE
runtime: null
scope: project
owners:
- git.rkdr.net/Mortis/Holocron/plugins/plan
active_owner: git.rkdr.net/Mortis/Holocron/plugins/plan
content_hash: sha256:9d3692e6b35e0e43b81e096352f11c6b884e7004d78d3dcd92768232c6704525
- kind: project-relative
target: claude
value: .claude/skills/plan-track/SKILL.md
runtime: null
scope: project
owners:
- git.rkdr.net/Mortis/Holocron/plugins/plan
active_owner: git.rkdr.net/Mortis/Holocron/plugins/plan
content_hash: sha256:fee5062c8c63b49f66368b290c8ebd8cfff744137670d0c037da1a49c455c047
- kind: project-relative
target: claude
value: .claude/skills/prototype
@@ -1933,51 +1779,6 @@ deployments:
- mattpocock/skills/skills/engineering/research
active_owner: mattpocock/skills/skills/engineering/research
content_hash: null
- kind: project-relative
target: claude
value: .claude/skills/research-docs
runtime: null
scope: project
owners:
- git.rkdr.net/Mortis/Holocron/plugins/plan
active_owner: git.rkdr.net/Mortis/Holocron/plugins/plan
content_hash: null
- kind: project-relative
target: claude
value: .claude/skills/research-docs/LICENSE
runtime: null
scope: project
owners:
- git.rkdr.net/Mortis/Holocron/plugins/plan
active_owner: git.rkdr.net/Mortis/Holocron/plugins/plan
content_hash: sha256:9d3692e6b35e0e43b81e096352f11c6b884e7004d78d3dcd92768232c6704525
- kind: project-relative
target: claude
value: .claude/skills/research-docs/SKILL.md
runtime: null
scope: project
owners:
- git.rkdr.net/Mortis/Holocron/plugins/plan
active_owner: git.rkdr.net/Mortis/Holocron/plugins/plan
content_hash: sha256:93023786f71dac5a77e60eca0be09e6510dfd45509f5e8cbc755395fe8774539
- kind: project-relative
target: claude
value: .claude/skills/research-docs/references/file-format.md
runtime: null
scope: project
owners:
- git.rkdr.net/Mortis/Holocron/plugins/plan
active_owner: git.rkdr.net/Mortis/Holocron/plugins/plan
content_hash: sha256:29d5583beaa531d26895c54def112039730490c312401648a6bdb7dd5278fb3c
- kind: project-relative
target: claude
value: .claude/skills/research-docs/references/topics.md
runtime: null
scope: project
owners:
- git.rkdr.net/Mortis/Holocron/plugins/plan
active_owner: git.rkdr.net/Mortis/Holocron/plugins/plan
content_hash: sha256:757abb7b6be44c3d3c0dd1f4818a344e08877810d36bf8be60ea7189cba8d12f
- kind: project-relative
target: claude
value: .claude/skills/research/LICENSE
+2 -4
View File
@@ -3,8 +3,8 @@ version: 0.1.0
description: Ansible Collection mortis.kamino. Consumer-side apm manifest for holocron skills.
license: GPL-3.0-or-later
# git, mattpocock and plan only (#104): bin and core are unused here, and gitea returns once it
# is rebuilt on the tea CLI.
# git and mattpocock only (#104): bin and core are unused here, and gitea returns once it is
# rebuilt on the tea CLI.
# Hook primitives come from apm; no instruction primitive is deployed until the root AGENTS.md
# has a managed section. `apm approve` writes the executables.allow entry into this file, and it
@@ -17,6 +17,4 @@ dependencies:
path: plugins/git
- git: https://git.rkdr.net/Mortis/Holocron.git
path: plugins/mattpocock
- git: https://git.rkdr.net/Mortis/Holocron.git
path: plugins/plan
mcp: []
+1 -1
View File
@@ -85,4 +85,4 @@ plugins:
strategy: {}
test: {}
vars: {}
version: 3.2.0
version: 3.1.0
-58
View File
@@ -474,61 +474,3 @@ releases:
- 134-check-mode.yml
- tailscale-role.yml
release_date: '2026-11-26'
3.2.0:
changes:
bugfixes:
- docker - Read the distribution release through ``ansible_facts['distribution_release']``
for the APT source line, so the role works with ``inject_facts_as_vars`` set
to false and in the ansible-core release that stops injecting facts as variables.
The source line is unchanged.
- gitea_runner - Read the timestamp of the forced re-registration backup through
``ansible_facts['date_time']``, so the role works with ``inject_facts_as_vars``
set to false and in the ansible-core release that stops injecting facts as
variables. The backup name is unchanged.
- system_baseline - Read the OS family through ``ansible_facts['os_family']``
in the reboot check, so the role (and its ``reboot`` entry point) works with
``inject_facts_as_vars`` set to false and in the ansible-core release that
stops injecting facts as variables. Before, the task failed with ``'ansible_os_family'
is undefined`` there.
minor_changes:
- cloudflared - New input ``cloudflared_tunnel_lookup_delay``, the seconds between
the three retries of a 404 from the tunnel lookup while a new tunnel may not
be visible yet. The default is 5, as before.
- docker, system_baseline - The install tasks that only use the distribution's
sources (docker's prerequisites, system_baseline's packages) refresh the APT
cache only when it is older than an hour; before, every run refreshed it.
Installs from a role's own APT source still refresh it on every run.
- system_baseline - Add ``system_baseline_extra_packages`` and ``system_baseline_extra_remove_packages``
(lists, default empty), which append to the resolved package lists, where
setting ``system_baseline_essential_packages`` or ``system_baseline_remove_packages``
replaces the profile's whole list. An extra ``tmux`` or ``unattended-upgrades``
enables the matching task like a profile package. A package that one input
installs and another purges stops the run before any change. With both inputs
left at their default the role behaves as before.
- system_baseline - Add the input ``system_baseline_skip_upgrade_during_vzdump``
(default ``false``). With ``true`` on the ``pve`` system type, the main flow
and the ``update`` entry point skip the apt upgrade while ``pvesh get /nodes/localhost/tasks
--source active`` lists a ``vzdump`` task, and say so. With the default no
``pvesh`` command runs and the upgrade is unchanged.
- 'system_baseline - ``system_baseline_journal_max_use`` can be empty to leave
journald alone: the role then writes no drop-in and does not restart ``systemd-journald``.
The default stays ``200M``.'
- 'system_baseline - ``system_baseline_journal_max_use`` is checked before any
change: it must be empty or a size journald reads, a number with an optional
upper-case ``B``, ``K``, ``M``, ``G``, ``T``, ``P`` or ``E``. A value journald
rejects, which the role used to write into the drop-in as it was and journald
then ignored (``infinity``, a lower-case unit, a line break), now stops the
run; an empty value used to write an empty ``SystemMaxUse=``.'
- 'traefik - New input ``traefik_release_url`` sets where the release archive
and checksums are downloaded from, for a mirror (default: the GitHub releases,
as before).'
fragments:
- 364-ansible-facts.yml
- 399-extra-packages.yml
- 400-skip-upgrade-during-vzdump.yml
- 401-journal-max-use-empty.yml
- apt-cache-valid-time.yml
- cloudflared-tunnel-lookup-delay.yml
- refusals-in-verify.yml
- traefik-release-url.yml
release_date: '2026-11-27'
@@ -0,0 +1,8 @@
---
minor_changes:
- >-
system_baseline - Add ``system_baseline_extra_packages`` and ``system_baseline_extra_remove_packages`` (lists, default empty), which
append to the resolved package lists, where setting ``system_baseline_essential_packages`` or ``system_baseline_remove_packages``
replaces the profile's whole list. An extra ``tmux`` or ``unattended-upgrades`` enables the matching task like a profile package.
A package that one input installs and another purges stops the run before any change. With both inputs left at their default the
role behaves as before.
@@ -0,0 +1,9 @@
---
minor_changes:
- >-
system_baseline - ``system_baseline_journal_max_use`` can be empty to leave journald alone: the role then writes no drop-in and does not
restart ``systemd-journald``. The default stays ``200M``.
- >-
system_baseline - ``system_baseline_journal_max_use`` is checked before any change: it must be empty, ``infinity`` or a number followed by
``K``, ``M``, ``G`` or ``T``. A value in any other form, which the role used to write into the drop-in as it was (a bare number, ``1.5G``,
a typo, a line break), now stops the run; an empty value used to write an empty ``SystemMaxUse=``.
-8
View File
@@ -1,8 +0,0 @@
---
minor_changes:
- >-
nfs_client - New role. Installs ``nfs-common`` and manages NFS mount entries in ``/etc/fstab`` from ``nfs_client_mounts``
(``src``, ``path``, optional ``opts`` and ``state`` ``present`` or ``absent``), with ``nfs_client_default_opts``
(default ``_netdev,nofail``) for an entry that sets none. It creates each mount point without owner, group or mode,
writes only the fstab line, never mounts or unmounts, and reloads systemd after a change. An ``absent`` entry loses its
line and nothing else. Declares Ubuntu noble and resolute; the molecule scenario never mounts a share.
@@ -1,6 +0,0 @@
---
minor_changes:
- >-
docker - New input ``docker_keyring_checksum``: the Docker APT key is verified against a pinned
sha256, and a changed key fails the install until a person has checked it and updated the hash.
Set ``docker_keyring_checksum`` too when ``docker_gpg_url`` is overridden.
@@ -1,4 +0,0 @@
---
trivial:
- >-
system_baseline - Purge the unwanted packages that are installed in one apt call instead of one call per package.
@@ -1,6 +0,0 @@
---
minor_changes:
- >-
traefik - The prerequisites install refreshes the APT cache only when it is older than an hour;
before, every run refreshed it. A consumer who adds an APT source just before the role must
refresh the cache first.
@@ -1,9 +0,0 @@
---
bugfixes:
- >-
ufw - ``--check`` no longer fails on a host where ufw is not installed yet; the preview reports
the install and skips the tasks that need the ``ufw`` binary.
- >-
fail2ban - ``--check`` no longer fails on a host where fail2ban is not installed yet, through
either entry point; the preview reports the install and skips the configuration, service and
jail tasks.
-11
View File
@@ -1,11 +0,0 @@
---
minor_changes:
- >-
pve_vm - New role. Clones a Proxmox VE QEMU VM from a template through the Proxmox API (``community.proxmox``), sets
its cloud-init user, SSH keys and network, updates an existing VM only on detected drift, grows its boot disk,
applies the power state, waits for SSH and cloud-init and (with ``pve_vm_allow_destroy``) deletes it. It never sets
a cloud-init password and deletes one stored on the VM. Only ``pve_vm_exists`` is set for later plays. The input
checks run under ``tags: always``, so a tag-filtered run also needs ``pve_vm_api_user`` and
``pve_vm_api_token_secret`` (and ``pve_vm_disk_size`` while ``pve_vm_manage_disk`` is true). Declares
Ubuntu noble and resolute guests; the molecule scenario covers the input validation and the drift detection, not
the API lifecycle.
@@ -1,5 +0,0 @@
---
trivial:
- >-
system_baseline - The registered results of the unattended-upgrades check and the reboot-required
check carry the internal ``__system_baseline_`` prefix.
@@ -12,8 +12,6 @@ and pin updates. The choice is hard to undo once every workflow pins an image.
- **We build our own images:** a `ci` image, and one Dockerfile per molecule image (one per Ubuntu
release, and later the Debian 13 one).
[ADR 0003](0003-molecule-controller-image.md) adds a `molecule-controller` image to this set,
which Molecule pins instead of `ci`.
- **The molecule images bake in everything except what a role installs itself.** The test
fixtures a scenario's `prepare.yml` needs are baked in. Packages a role installs are still
downloaded, because that install path is what the test exercises. A converge is not kept off
@@ -1,60 +0,0 @@
# 0003. Molecule runs in its own controller image, not the `ci` image
Status: accepted
## Context
[ADR 0002](0002-self-built-ci-and-molecule-images.md) built one `ci` image that bakes every CI
tool, and Lint, Build and Molecule all pin it. A change to a tool only Lint uses (apm-cli,
antsibull-changelog, a pre-commit hook environment) publishes a new `ci` version, and its pin
pull request moves `CI_IMAGE` in `molecule.yml`. The scenario selector cannot tell what changed
inside an image, so it runs every scenario. 9 of 18 `ci` pin pull requests over two weeks
were Lint-only. Images are built only on push to `main`, so a bump and its pin never share a pull
request.
## Decision
- **Molecule runs in a `molecule-controller` image**, separate from `ci`. It bakes only what
Molecule needs: ansible-core, molecule, molecule-plugins, the Python packages of the Docker
connection, and the collections of `requirements.yml` and
`extensions/molecule/requirements.yml`.
- **Its Python packages come from a requirements file and hash-pinned lock of its own.**
- **`molecule.yml` pins it instead of `ci`**; Lint and Build keep `ci`.
- **It follows ADR 0002 otherwise:** built by `image.yml`, versioned by CI, pinned by
`<version>@sha256:<digest>`, moved by Renovate. This adds to ADR 0002's set of images; the
rest of ADR 0002 stands.
## Reason
A `ci` pin pull request then touches only paths the selector ignores and runs no scenario. A
`molecule-controller` pin pull request still runs every scenario, which is right: it changes
Molecule's tools.
The cost: one more image and lock to maintain, its layers to estimate against the 100 MB limit,
a hand-made first pin, and ansible-core pinned in two locks that must stay equal. A collection
bump is an input of both images, so it publishes two versions and two pin pull requests.
The controller's requirements file and lock must not be on the selector's IGNORED list, so a
bump of ansible-core or molecule there runs every scenario before it merges. Today
`requirements-dev.txt` and `requirements-dev.lock` are on IGNORED, so such a bump selects no
scenario unless it edits `meta/runtime.yml`; this decision does not change that list.
The implementation updates: `image.yml` (matrix, and its push `paths` unless the new files live
under `images/`), `molecule.yml`,
`scripts/run_molecule_in_ci_image.sh` (its pin comparison reads the `ci` image's checksums),
`scripts/check_image_versions.py`, `scripts/check_bot_pr_diff.py` and
`scripts/lock-requirements.sh` (they know only `requirements-dev.lock`), their tests, the
`pip-compile` patterns in `renovate.json`, `images/AGENTS.md` (the consumer list, and "each
molecule image is one Ubuntu release"), the Molecule rules in `.gitea/workflows/AGENTS.md`,
`docs/images/` (a new page, and `ci.md`, which names Molecule as a consumer), the `ci`
Dockerfile's description label, `docs/contributing/setup.md` if the clone's tools change, and the
[Accepted risks](../../SECURITY.md#accepted-risks) entry "Pin bumps first behaviour-tested after
they merge", which counts on the `ci` pin pull request running every scenario.
## Not done
- **The selector classifies the packages a lock change moves, to decide whether a `CI_IMAGE`
bump matters:** a heuristic package list inside a script that judges pull requests.
- **Status quo:** every Lint-only tool change keeps costing a full Molecule run.
- **Grouping pin pull requests only:** adopted separately; it lowers the number of full runs
but not the cause.
-4
View File
@@ -11,10 +11,6 @@ the author sees the change before it merges; aspirational means nothing checks i
- **Status is `accepted` or `superseded by NNNN`, nothing else.** A proposal lives in an issue or
a pull request and is never committed as "proposed". *Why:* a committed ADR is either in force
or replaced; a draft in the tree reads as a decision. *Held:* review.
- **When a later ADR changes part of an earlier one, the earlier one stays `accepted` and as
decided, except for one sentence beside that part naming the later ADR and what it changes;**
the later ADR names the earlier one in its Context. *Why:* neither status fits a partial change,
and a reader of the earlier ADR learns which part no longer holds and where it went. *Held:* review.
- **An ADR is accepted on the maintainer's approval of its pull request, which sets status
`accepted`.** *Why:* an ADR binds every contributor, so the maintainer decides it. *Held:*
control: the `CODEOWNERS` entry for `docs/adr/`, which requires the maintainer's code-owner
+1 -14
View File
@@ -15,23 +15,10 @@ trailers, are in [ai-assistance.md](ai-assistance.md).
*Reason:* every change reaches `main` through the Lint and Build checks and a reviewer.
*Held by:* control: branch protection on `main`.
- **Do not push to someone else's branch or to a bot's branch; put your change in a pull request of
your own.** Updating a branch from `main` with Gitea's update button is allowed under the next
two rules.
your own.** Updating a branch from `main` with Gitea's update button is allowed.
*Reason:* a push changes a head its author already reviewed or scheduled to merge, and a hand-made
commit on a `renovate/` branch makes Renovate stop rebasing it.
*Held by:* aspirational.
- **Update a pull request's branch from `main` only when it is next to merge: reviewed, green on its
previous head, and the only branch being updated. After updating your own pull request, give it a
scheduled merge; merge anyone else's as [reviewing.md](reviewing.md) says.**
*Reason:* `main` blocks an outdated branch, so every update re-runs Lint, Build and Molecule, and
a new head cancels the run in progress; an update made while another pull request merges first is
wasted.
*Held by:* aspirational.
- **Never press the update button on a `renovate/` branch. When a Renovate pull request is next to
merge and behind `main`, tick the rebase/retry checkbox in its description; Renovate rebases it at
its next run.**
*Reason:* the update button adds a hand-made commit, and Renovate stops rebasing that branch.
*Held by:* aspirational.
- **File an issue or open a pull request with the headings of the matching template in `.gitea/`,
also when you file through the API, `tea` or an MCP server.**
*Reason:* those routes skip the templates, and an agent's built-in body leaves out what review needs.
+1 -1
View File
@@ -7,4 +7,4 @@
# Renovate (renovate.json, ansible-galaxy manager) bumps this pin.
collections:
- name: community.docker
version: 5.4.1
version: 5.4.0
+3 -4
View File
@@ -1,13 +1,13 @@
---
namespace: mortis
name: kamino
version: 3.2.0
version: 3.1.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, nfs_client, pihole, pve_lxc, pve_vm, sshd, system_baseline,
gitea, gitea_runner, network_interfaces, pihole, pve_lxc, sshd, system_baseline,
systemd_hardening, tailscale, traefik, ufw, user_management; _binary_update is internal).
license:
- GPL-3.0-or-later
@@ -22,7 +22,7 @@ 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 nfs_client, system_baseline and user_management, community.proxmox by pve_lxc and pve_vm (Proxmox VE guest lifecycle).
# 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:
@@ -39,7 +39,6 @@ build_ignore:
- apm_modules
- .apm-local
- .claude
- .config
- .gitea
- .gitignore
- .pre-commit-config.yaml
+9 -48
View File
@@ -1,6 +1,6 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"description": "Run by .gitea/workflows/renovate.yml on this repository's own runner. Policy: automerge minor and patch, majors by hand. Every bot pull request must pass scripts/check_bot_pr_diff.py (lint workflow), which allows only version, tag, digest and pin lines. Image versions are assigned by the Images workflow when an image's inputs change, so a bot pull request needs no version edit. Updates open on Mondays (UTC), so any Monday run can act; the own image pins and vulnerability fixes found on osv.dev open at any time. The weekly window and the groups bound the volume, so there is no hourly pull request limit. Vulnerability fixes skip the release-age wait, so they are never automerged: a person checks a fix that had no time to be pulled as a compromised release. Base-image bumps are manual: every Dockerfile is FROM ubuntu, grouped with the job containers.",
"description": "Run by .gitea/workflows/renovate.yml on this repository's own runner. Policy: automerge minor and patch, majors by hand. Every bot pull request must pass scripts/check_bot_pr_diff.py (lint workflow), which allows only version, tag, digest and pin lines. Image versions are assigned by the Images workflow when an image's inputs change, so a bot pull request needs no version edit.",
"extends": [
"config:recommended",
":enablePreCommit"
@@ -19,7 +19,7 @@
],
"automerge": true,
"automergeType": "pr",
"prHourlyLimit": 0,
"prHourlyLimit": 5,
"minimumReleaseAge": "3 days",
"minimumReleaseAgeBehaviour": "timestamp-optional",
"timezone": "UTC",
@@ -90,7 +90,7 @@
],
"packageRules": [
{
"description": "Dockerfile base-image tag and digest bumps (images/*/Dockerfile) MAY automerge. Kamino is the untrusted side and the bump pull request's own CI exercises the new image before the merge. Placed first so the major-version rule below still turns automerge off. The merge publishes a new image version. Today every Dockerfile is FROM ubuntu, whose bumps join the manual ubuntu base images group below; this rule is the safety net for a future base image of another kind.",
"description": "Dockerfile base-image tag and digest bumps (images/*/Dockerfile) MAY automerge. Kamino is the untrusted side and the bump pull request's own CI exercises the new image before the merge. Placed first so the major-version rule below still turns automerge off. The merge publishes a new image version.",
"matchManagers": [
"dockerfile"
],
@@ -145,18 +145,12 @@
"allowedVersions": "<=26.10.1"
},
{
"description": "The job containers of image.yml (matrix job_image, ubuntu by digest) hold the org registry push credential while the image job runs: never automerged. Their ubuntu bumps share one branch with the Dockerfile FROM bumps (ubuntu base images rule below), so that pull request is manual too: a group automerges only if every update in it does.",
"description": "The job containers of image.yml (matrix job_image, ubuntu by digest) hold the org registry push credential while the image job runs: never automerged, and kept in their own branch so the Dockerfile base-image bumps are not held back with them.",
"matchFileNames": [
".gitea/workflows/image.yml"
],
"automerge": false
},
{
"description": "The Dockerfile FROM digests and the image.yml job_image digests of one Ubuntu update move in one pull request, so the release pair stays in step and one Images run covers both.",
"matchPackageNames": [
"ubuntu"
],
"groupName": "ubuntu base images"
"automerge": false,
"additionalBranchPrefix": "job-container-"
},
{
"description": "Safety net only: kaniko is pinned by layer digests in image.yml and no Renovate manager reads them, so it is updated by hand. If a manager ever starts to read it, its bumps are not automerged.",
@@ -166,15 +160,11 @@
"automerge": false
},
{
"description": "Pin follow-up for our own images (git.rkdr.net/mortis/*): moves the image:<version>@sha256:<digest> pins of lint.yml, build.yml, molecule.yml and gitea-release-key.yml to the newest published version and its digest, and automerges. The Images workflow's completion starts a Renovate run, so this pull request opens minutes after a new version is pushed. The pull request's own Lint and Build run in the new image before the merge, and scripts/check_bot_pr_diff.py allows only these pin lines. The registry lists tags and digests anonymously, so no hostRules are needed. A major version stays manual (rule above). One pull request moves every image an Images run published (ci and both molecule images), so one Molecule run tests them together. Exempt from the weekly schedule, so the pins on main catch up with a new image within minutes.",
"description": "Pin follow-up for our own images (git.rkdr.net/mortis/*): moves the image:<version>@sha256:<digest> pins of lint.yml, build.yml, molecule.yml and gitea-release-key.yml to the newest published version and its digest, and automerges. The Images workflow's completion starts a Renovate run, so this pull request opens minutes after a new version is pushed. The pull request's own Lint and Build run in the new image before the merge, and scripts/check_bot_pr_diff.py allows only these pin lines. The registry lists tags and digests anonymously, so no hostRules are needed. A major version stays manual (rule above).",
"matchPackageNames": [
"git.rkdr.net/mortis/**"
],
"automerge": true,
"groupName": "own CI images",
"schedule": [
"at any time"
]
"automerge": true
},
{
"description": "Look the pre-commit hook repositories up with git ls-remote (git-tags) instead of the GitHub API. This run has no GitHub token, and the github-tags datasource then either skips every hook (skipReason github-token-required, dry run 3880) or is refused at once with 403 rate limit (githubTokenWarn off, local run). git-tags needs no API and no credential, and it uses the dereferenced hash of an annotated tag, so the new rev is the commit, as pre-commit needs. The `# frozen:` form is kept by the manager's own replace template. It works only together with RENOVATE_GITHUB_TOKEN_WARN=false in renovate.yml: the token check runs after extraction and skips every github-tags dependency before a package rule can change its datasource (local run, Renovate 44.161.0). git-tags has no release timestamps, so minimumReleaseAge cannot delay a hook bump: hook bumps are never automerged, a person reviews each one.",
@@ -187,45 +177,16 @@
"overrideDatasource": "git-tags",
"overridePackageName": "https://github.com/{{{depName}}}",
"automerge": false
},
{
"description": "Lint and build tooling in one weekly pull request across requirements-dev.lock and the ci image's uv pin, so one ci image build instead of one per tool.",
"matchDatasources": [
"pypi"
],
"matchPackageNames": [
"apm-cli",
"antsibull-changelog",
"galaxy-importer",
"reuse",
"pre-commit",
"uv"
],
"groupName": "lint tooling"
},
{
"description": "The pre-commit hooks in one weekly pull request; never automerged (rule above).",
"matchManagers": [
"pre-commit"
],
"groupName": "pre-commit hooks"
}
],
"lockFileMaintenance": {
"enabled": true,
"schedule": [
"on monday"
"before 6am on monday"
],
"automerge": false,
"labels": [
"lock-file-maintenance"
]
},
"schedule": [
"on monday"
],
"osvVulnerabilityAlerts": true,
"vulnerabilityAlerts": {
"automerge": false
}
}
-1
View File
@@ -32,7 +32,6 @@ The role targets Ubuntu hosts that run the tunnel daemon, not Proxmox nodes, so
| `cloudflared_zone_name` | `""` (asserted while `cloudflared_manage_dns`) | Zone of the ingress hostnames. |
| `cloudflared_allow_dns_overwrite` | `[]` | Hostnames whose existing non-tunnel DNS record may be overwritten. |
| `cloudflared_api_base_url` | `https://api.cloudflare.com/client/v4` | Cloudflare API base URL for the role's `uri` calls, no trailing slash. |
| `cloudflared_tunnel_lookup_delay` | `5` | Seconds between the three retries of a 404 from the tunnel lookup, at least 0. |
| `cloudflared_tunnel_name` | `{{ inventory_hostname }}-tunnel` | Tunnel name used by the `mint` entry point. |
| `cloudflared_version` | pinned in `defaults/main.yml` | Release tag, `YYYY.M.P`. |
| `cloudflared_sha256_amd64` | pinned | SHA-256 of the amd64 binary. Update with the version. |
-2
View File
@@ -17,8 +17,6 @@ cloudflared_config_dir: "/etc/cloudflared"
cloudflared_service_unit: "/etc/systemd/system/cloudflared.service"
cloudflared_api_base_url: "https://api.cloudflare.com/client/v4"
# Seconds between the three retries of a 404 from the tunnel lookup.
cloudflared_tunnel_lookup_delay: 5
cloudflared_tunnel_name: "{{ inventory_hostname }}-tunnel"
@@ -102,13 +102,6 @@ argument_specs:
Base URL of the Cloudflare API, without a trailing slash. Prefixed to every request the role makes with
C(ansible.builtin.uri) (tunnel lookup and delete, zone lookup and DNS record listing). The
C(community.general.cloudflare_dns) tasks always use the public endpoint.
cloudflared_tunnel_lookup_delay:
type: int
default: 5
description:
- >-
Seconds between the three retries of the tunnel lookup when Cloudflare answers 404, which right
after a mint can be read-after-write lag rather than a deleted tunnel. At least 0.
cloudflared_tunnel_name:
type: raw
description:
@@ -23,8 +23,6 @@
cloudflared_user: "{{ cloudflared_test_case.vars.cloudflared_user | default('cloudflared') }}"
cloudflared_install_dir: "{{ cloudflared_test_case.vars.cloudflared_install_dir | default('/usr/local/bin') }}"
cloudflared_config_dir: "{{ cloudflared_test_case.vars.cloudflared_config_dir | default('/etc/cloudflared') }}"
# The stub answers at once, so the retries need no wait; they still run.
cloudflared_tunnel_lookup_delay: "{{ cloudflared_test_case.vars.cloudflared_tunnel_lookup_delay | default(0) }}"
# Only reached when the include returned. The message must not contain the expected
# text, so the rescue below cannot mistake it for the failure under test.
@@ -157,9 +157,6 @@
- name: tunnel-id-not-uuid
vars: {cloudflared_tunnel_id: not-a-uuid}
expect: must be a lowercase UUID
- name: lookup-delay-negative
vars: {cloudflared_tunnel_lookup_delay: -1}
expect: cloudflared_tunnel_lookup_delay must be a whole number of seconds, at least 0
- name: tunnel-not-minted
vars: {cloudflared_tunnel_id: ""}
expect: run the mint entry point first
@@ -175,7 +172,7 @@
- name: tunnel-deleted
vars: {cloudflared_tunnel_id: 6f1a6e2c-0000-4000-8000-000000000002}
expect: no longer exists on Cloudflare
# Retried three times (with no delay here) before the 404 is trusted.
# Retried three times, 5 s apart, before the 404 is trusted.
- name: tunnel-unknown
vars: {cloudflared_tunnel_id: 6f1a6e2c-0000-4000-8000-00000000000f}
expect: (HTTP 404)
+1 -1
View File
@@ -20,7 +20,7 @@
# briefly before trusting it.
until: __cloudflared_tunnel_lookup.status | default(0) == 200
retries: 3
delay: "{{ cloudflared_tunnel_lookup_delay }}"
delay: 5
# Running out of retries fails the task whatever its status, and no_log would hide why: the
# two tasks below fail instead, with the re-mint instructions for a 404.
ignore_errors: true # noqa: ignore-errors
-6
View File
@@ -63,12 +63,6 @@
newline or %, and the two directories must be absolute paths.
quiet: true
- name: Require a non-negative tunnel lookup delay
ansible.builtin.assert:
that: cloudflared_tunnel_lookup_delay | int(-1) >= 0
fail_msg: cloudflared_tunnel_lookup_delay must be a whole number of seconds, at least 0.
quiet: true
# The role never creates the tunnel on its main entry point. Defined and empty (or null) counts
# as missing, as in the mint entry point, so the two cannot disagree.
- name: Require the minted tunnel secrets
+4 -6
View File
@@ -4,7 +4,7 @@ Installs Docker Engine from the upstream Docker APT repository, optionally updat
## Supported platforms
Ubuntu 24.04 (noble) and 26.04 (resolute), the platforms the molecule scenario runs on. The key and repository URLs point at `download.docker.com/linux/ubuntu`, and the source line uses `ansible_facts['distribution_release']`. The apt architecture is derived from the host (`x86_64` gives `amd64`, `aarch64` gives `arm64`); any other architecture fails the play until `docker_apt_arch` is set. A limited molecule scenario covers the role's own logic (see [Tests](#tests)); the real Docker Engine is not tested.
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).
@@ -27,7 +27,6 @@ The role targets Ubuntu hosts only: it installs from Docker's Ubuntu repository,
| `docker_keyring_path` | `/etc/apt/keyrings/docker.asc` | no | Repository key location. |
| `docker_apt_list_path` | `/etc/apt/sources.list.d/docker.list` | no | APT source file. |
| `docker_gpg_url` | `https://download.docker.com/linux/ubuntu/gpg` | no | Key URL. |
| `docker_keyring_checksum` | sha256 of the current Docker key | no | Expected sha256 (hex, no `sha256:` prefix) of the key at `docker_gpg_url`; set it too when `docker_gpg_url` is overridden; a mismatch fails the download, so a changed key stops the install until this is updated. |
| `docker_repo_base_url` | `https://download.docker.com/linux/ubuntu` | no | Repository base URL. |
| `docker_apt_arch` | derived from the host | no | Architecture in the APT source. Empty derives it (`x86_64` gives `amd64`, `aarch64` gives `arm64`); another architecture fails until this is set. A value set here is always used; lowercase letters and digits only. |
| `docker_start_missed` | `false` | no | Install a boot unit that starts the containers Docker skipped after a reboot (see [Boot and shutdown units](#boot-and-shutdown-units)). |
@@ -87,18 +86,17 @@ 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 two platforms: `${MOLECULE_IMAGE}` (Ubuntu 24.04) and `${MOLECULE_IMAGE_2604}` (Ubuntu 26.04). A real Docker Engine cannot run there: `dockerd` needs the bridge, iptables rules and a delegated cgroup, and the container has no privileged mode. So the scenario builds a local APT repository, signs it with a throwaway key, and points the role at it with `docker_gpg_url`, `docker_keyring_checksum` (the throwaway key's hash) and `docker_repo_base_url`. The repository holds empty stand-ins for `docker-ce`, `docker-ce-cli` and `containerd.io`. The stand-in `docker-ce` ships a stub `docker.service` (`sleep infinity`) and creates the `docker` group, as the real package does. It runs `check` before the converge (on a fresh host) and after it (on the configured host).
`molecule/default` runs in CI only (`.gitea/workflows/molecule.yml`, no local runner), on two platforms: `${MOLECULE_IMAGE}` (Ubuntu 24.04) and `${MOLECULE_IMAGE_2604}` (Ubuntu 26.04). A real Docker Engine cannot run there: `dockerd` needs the bridge, iptables rules and a delegated cgroup, and the container has no privileged mode. So the scenario builds a local APT repository, signs it with a throwaway key, and points the role at it with `docker_gpg_url` and `docker_repo_base_url`. The repository holds empty stand-ins for `docker-ce`, `docker-ce-cli` and `containerd.io`. The stand-in `docker-ce` ships a stub `docker.service` (`sleep infinity`) and creates the `docker` group, as the real package does. It runs `check` before the converge (on a fresh host) and after it (on the configured host).
What it shows, with the role's tasks running unchanged:
- The key is fetched, checked against `docker_keyring_checksum`, stored at `docker_keyring_path` with mode `0644`, and apt really verifies the repository against it (an unsigned or wrongly signed repository would leave no install candidate).
- The source line has the architecture, the `signed-by` keyring and `ansible_facts['distribution_release']`.
- The key is fetched, stored at `docker_keyring_path` with mode `0644`, and apt really verifies the repository against it (an unsigned or wrongly signed repository would leave no install candidate).
- The source line has the architecture, the `signed-by` keyring and `ansible_distribution_release`.
- The packages are installed from that repository, the unit is enabled and active, and `docker_users` join `docker_group`.
- `docker_remove` with `docker_remove_data` removes the source line, the keyring, the packages, the unit and `/var/lib/docker`.
- Both units are installed, enabled, ordered against `docker.service` as stated, the shutdown unit is active, a unit is removed when its input is `false`, and `docker_remove` removes both.
- With the daemon inputs set, `/etc/docker/daemon.json` is valid JSON with exactly the expected keys, mode `0644` and root-owned. A change with `docker_daemon_restart: false` leaves dockerd running (its start time is unchanged); with `true` it restarts it. A key set both in `docker_daemon_options` and by a dedicated input, and a bad log size, driver or file count, are refused before any change.
- The argument check refuses a mapping for `docker_users`, a non-boolean `docker_remove` and a `docker_stop_at_shutdown_timeout` of 0.
- A key whose hash does not match `docker_keyring_checksum` fails the key download.
- A second run changes nothing (molecule's idempotence check).
What it does not show: what the units do at a real boot or shutdown (the container has no dockerd, no NFS shares and no reboot; the selection logic of `docker-start-missed` is unit-tested in `tests/scripts/test_docker_files.py`), that the upstream repository and key at `download.docker.com` are reachable and valid, that the real packages install, that `dockerd` starts, anything about container networking or iptables, the `docker_update` path (`tasks/update.yml`), and removal without `docker_remove_data` (the removal stops the unit first, so it can run only once per install). It needs the Ubuntu mirrors, for the `curl` the role installs. These gaps are a known residual risk of the role.
-4
View File
@@ -11,10 +11,6 @@ docker_packages:
docker_keyring_path: /etc/apt/keyrings/docker.asc
docker_apt_list_path: /etc/apt/sources.list.d/docker.list
docker_gpg_url: https://download.docker.com/linux/ubuntu/gpg
# sha256 of Docker's package signing key (9DC858229FC7DD38854AE2D88D81803C0EBFCD88), as the ASCII-armored file
# docker_gpg_url serves. Static on purpose: a rotated or re-armored key fails the install until a person has checked the
# new one and updated this hash.
docker_keyring_checksum: "1500c1f56fa9e26b9b8f42452a553675796ade0807cdce11975eb98170b3a570"
docker_repo_base_url: https://download.docker.com/linux/ubuntu
# Architecture written into the APT source. Empty (the default) derives it from the host: x86_64 gives amd64, aarch64 gives arm64, any
+2 -10
View File
@@ -6,7 +6,7 @@ argument_specs:
- >-
Installs Docker Engine from the upstream APT repository, or removes it when C(docker_remove) is true. Optionally updates the packages to
the current candidate versions, then adds C(docker_users) to C(docker_group).
- Needs gathered facts, because the APT source uses C(ansible_facts['distribution_release']).
- Needs gathered facts, because the APT source uses C(ansible_distribution_release).
options:
docker_remove:
type: bool
@@ -49,19 +49,11 @@ argument_specs:
default: https://download.docker.com/linux/ubuntu/gpg
description:
- URL of the repository signing key.
docker_keyring_checksum:
type: str
default: 1500c1f56fa9e26b9b8f42452a553675796ade0807cdce11975eb98170b3a570
description:
- >-
sha256 of the key at C(docker_gpg_url), as the hex digest without the C(sha256:) prefix. The download fails
on a mismatch, so a rotated or re-armored upstream key stops the install until the new key is checked and
the hash updated. Set C(docker_keyring_checksum) too when C(docker_gpg_url) is overridden.
docker_repo_base_url:
type: str
default: https://download.docker.com/linux/ubuntu
description:
- Base URL of the repository. The source line uses C(ansible_facts['distribution_release']) and the C(stable) component.
- Base URL of the repository. The source line uses C(ansible_distribution_release) and the C(stable) component.
docker_apt_arch:
type: str
default: ""
+113 -8
View File
@@ -7,8 +7,6 @@
hosts: all
vars:
docker_gpg_url: file:///srv/docker-stub-repo/docker.asc
# The stand-in key is generated per run, so its hash is read here rather than pinned.
docker_keyring_checksum: "{{ docker_stub_key.stat.checksum }}"
docker_repo_base_url: file:///srv/docker-stub-repo
docker_users: [moleculeuser]
docker_start_missed: true
@@ -20,11 +18,118 @@
docker_log_max_file: "3"
docker_daemon_options:
max-concurrent-downloads: 3
pre_tasks:
- name: Stat the stand-in repository key
ansible.builtin.stat:
path: /srv/docker-stub-repo/docker.asc
checksum_algorithm: sha256
register: docker_stub_key
roles:
- role: mortis.kamino.docker
# The plays below are refusals: argument_specs rejects the wrong types before any task runs,
# so the idempotence run stays clean. A sentinel in the failure message tells "the role
# refused" from "the fail task after the role ran", which a bare rescue cannot.
- name: A docker_users value that is not a list is refused
hosts: all
gather_facts: false
vars:
docker_users:
not: a-list
tasks:
- name: Apply the role with a mapping for docker_users
block:
- name: Include the role
ansible.builtin.include_role:
name: mortis.kamino.docker
- name: Fail when the wrong type was accepted
ansible.builtin.fail:
msg: MOLECULE-ACCEPTED
rescue:
- name: The argument check stopped the play
ansible.builtin.assert:
that:
- "'MOLECULE-ACCEPTED' not in ansible_failed_result.msg | default('')"
- "'docker_users' in ansible_failed_result.msg | default('')"
quiet: true
- name: A docker_remove value that is not a boolean is refused
hosts: all
gather_facts: false
vars:
docker_remove: maybe
tasks:
- name: Apply the role with a non-boolean docker_remove
block:
- name: Include the role
ansible.builtin.include_role:
name: mortis.kamino.docker
- name: Fail when the wrong type was accepted
ansible.builtin.fail:
msg: MOLECULE-ACCEPTED
rescue:
- name: The argument check stopped the play
ansible.builtin.assert:
that:
- "'MOLECULE-ACCEPTED' not in ansible_failed_result.msg | default('')"
- "'docker_remove' in ansible_failed_result.msg | default('')"
quiet: true
# The architecture is written into the one-line apt source, so a value with a space or a bracket is refused before anything
# changes. The derived default is covered by the converge above and verify.yml (the container is x86_64, so the source says amd64).
- name: A docker_apt_arch value that would corrupt the apt source is refused
hosts: all
gather_facts: false
vars:
docker_apt_arch: "bad arch"
tasks:
- name: Apply the role with a bad architecture
block:
- name: Include the role
ansible.builtin.include_role:
name: mortis.kamino.docker
- name: Fail when the bad architecture was accepted
ansible.builtin.fail:
msg: MOLECULE-ACCEPTED
rescue:
- name: The validation stopped the play
ansible.builtin.assert:
that:
- "'MOLECULE-ACCEPTED' not in ansible_failed_result.msg | default('')"
- "'docker_apt_arch' in ansible_failed_result.msg | default('')"
quiet: true
# The unit timings are checked before anything changes.
- name: A docker_stop_at_shutdown_timeout of 0 is refused
hosts: all
gather_facts: false
vars:
docker_stop_at_shutdown_timeout: 0
tasks:
- name: Apply the role with a timeout of 0
block:
- name: Include the role
ansible.builtin.include_role:
name: mortis.kamino.docker
- name: Fail when the timeout was accepted
ansible.builtin.fail:
msg: MOLECULE-ACCEPTED
rescue:
- name: The validation stopped the play
ansible.builtin.assert:
that:
- "'MOLECULE-ACCEPTED' not in ansible_failed_result.msg | default('')"
- "'docker_stop_at_shutdown_timeout' in ansible_failed_result.msg | default('')"
quiet: true
# A key that docker_daemon_options and a dedicated input both set, and a log value dockerd would reject, stop the run before any change.
- name: A bad daemon setting is refused
hosts: all
gather_facts: false
tasks:
- name: Apply the role with each bad setting
ansible.builtin.include_tasks: tasks/refuse_daemon.yml
vars:
docker_refused: "{{ item }}"
loop:
- {docker_live_restore: true, docker_daemon_options: {live-restore: false}}
- {docker_log_driver: local, docker_daemon_options: {log-driver: json-file}}
- {docker_log_max_size: 10m, docker_daemon_options: {log-opts: {max-size: 1m}}}
- {docker_log_driver: Local}
- {docker_log_max_size: ten}
- {docker_log_max_file: "0"}
- {docker_log_max_file: "-1"}
@@ -1,27 +0,0 @@
---
# The zeroed hash matches no file, so the key task must be the one that fails.
- name: Run the role with a checksum the stand-in key does not have
block:
- name: Include the role
ansible.builtin.include_role:
name: mortis.kamino.docker
vars:
docker_gpg_url: file:///srv/docker-stub-repo/docker.asc
docker_repo_base_url: file:///srv/docker-stub-repo
docker_keyring_path: /tmp/docker-refused-key.asc
docker_keyring_checksum: "{{ '0' * 64 }}"
- name: Fail when the wrong key was accepted
ansible.builtin.fail:
msg: MOLECULE-ACCEPTED
rescue:
- name: The key download stopped the play
ansible.builtin.assert:
that:
- ansible_failed_task.name == 'Install Docker APT GPG key'
- "'did not match' in ansible_failed_result.msg | default('')"
quiet: true
always:
- name: Remove the refused key path
ansible.builtin.file:
path: /tmp/docker-refused-key.asc
state: absent
+45 -186
View File
@@ -1,133 +1,4 @@
---
# The refusals need no container, so they run once, on the controller, in check mode so that a
# refusal that regressed cannot change it. The controller has no gathered facts, so a play that
# does not test the architecture sets it. A sentinel in the failure message tells "the role
# refused" from "the fail task after the role ran", which a bare rescue cannot.
- name: A docker_users value that is not a list is refused
hosts: localhost
connection: local
check_mode: true
gather_facts: false
vars:
docker_apt_arch: amd64
docker_users:
not: a-list
tasks:
- name: Apply the role with a mapping for docker_users
block:
- name: Include the role
ansible.builtin.include_role:
name: mortis.kamino.docker
- name: Fail when the wrong type was accepted
ansible.builtin.fail:
msg: MOLECULE-ACCEPTED
rescue:
- name: The argument check stopped the play
ansible.builtin.assert:
that:
- "'MOLECULE-ACCEPTED' not in ansible_failed_result.msg | default('')"
- "'docker_users' in ansible_failed_result.msg | default('')"
quiet: true
- name: A docker_remove value that is not a boolean is refused
hosts: localhost
connection: local
check_mode: true
gather_facts: false
vars:
docker_apt_arch: amd64
docker_remove: maybe
tasks:
- name: Apply the role with a non-boolean docker_remove
block:
- name: Include the role
ansible.builtin.include_role:
name: mortis.kamino.docker
- name: Fail when the wrong type was accepted
ansible.builtin.fail:
msg: MOLECULE-ACCEPTED
rescue:
- name: The argument check stopped the play
ansible.builtin.assert:
that:
- "'MOLECULE-ACCEPTED' not in ansible_failed_result.msg | default('')"
- "'docker_remove' in ansible_failed_result.msg | default('')"
quiet: true
# The architecture is written into the one-line apt source, so a value with a space or a bracket is refused before anything
# changes. The derived default is covered by converge.yml and the plays below (the container is x86_64, so the source says amd64).
- name: A docker_apt_arch value that would corrupt the apt source is refused
hosts: localhost
connection: local
check_mode: true
gather_facts: false
vars:
docker_apt_arch: "bad arch"
tasks:
- name: Apply the role with a bad architecture
block:
- name: Include the role
ansible.builtin.include_role:
name: mortis.kamino.docker
- name: Fail when the bad architecture was accepted
ansible.builtin.fail:
msg: MOLECULE-ACCEPTED
rescue:
- name: The validation stopped the play
ansible.builtin.assert:
that:
- "'MOLECULE-ACCEPTED' not in ansible_failed_result.msg | default('')"
- "'docker_apt_arch' in ansible_failed_result.msg | default('')"
quiet: true
# The unit timings are checked before anything changes.
- name: A docker_stop_at_shutdown_timeout of 0 is refused
hosts: localhost
connection: local
check_mode: true
gather_facts: false
vars:
docker_apt_arch: amd64
docker_stop_at_shutdown_timeout: 0
tasks:
- name: Apply the role with a timeout of 0
block:
- name: Include the role
ansible.builtin.include_role:
name: mortis.kamino.docker
- name: Fail when the timeout was accepted
ansible.builtin.fail:
msg: MOLECULE-ACCEPTED
rescue:
- name: The validation stopped the play
ansible.builtin.assert:
that:
- "'MOLECULE-ACCEPTED' not in ansible_failed_result.msg | default('')"
- "'docker_stop_at_shutdown_timeout' in ansible_failed_result.msg | default('')"
quiet: true
# A key that docker_daemon_options and a dedicated input both set, and a log value dockerd would reject, stop the run before any change.
- name: A bad daemon setting is refused
hosts: localhost
connection: local
check_mode: true
gather_facts: false
vars:
docker_apt_arch: amd64
tasks:
- name: Apply the role with each bad setting
ansible.builtin.include_tasks: tasks/refuse_daemon.yml
vars:
docker_refused: "{{ item }}"
loop:
- {docker_live_restore: true, docker_daemon_options: {live-restore: false}}
- {docker_log_driver: local, docker_daemon_options: {log-driver: json-file}}
- {docker_log_max_size: 10m, docker_daemon_options: {log-opts: {max-size: 1m}}}
- {docker_log_driver: Local}
- {docker_log_max_size: ten}
- {docker_log_max_file: "0"}
- {docker_log_max_file: "-1"}
# What the role is for, as far as stand-in packages can show it: the repository key and the
# source line are in place and apt really used them, the packages are installed from that
# repository, the unit is enabled and running, and the user joined the group. The second play
@@ -297,7 +168,41 @@
changed_when: false
failed_when: docker_verify_start_run.rc != 2
# Converge's daemon.json, read before the role runs below change it.
# Switching an input back to false removes that unit and script and leaves the other alone.
- name: Verify that a unit is removed when its input is false
hosts: all
vars:
docker_gpg_url: file:///srv/docker-stub-repo/docker.asc
docker_repo_base_url: file:///srv/docker-stub-repo
docker_users: [moleculeuser]
docker_start_missed: false
docker_stop_at_shutdown: true
docker_stop_at_shutdown_timeout: 20
tasks:
- name: Apply the role with the boot unit off
ansible.builtin.include_role:
name: mortis.kamino.docker
- name: Stat the boot unit's files and the shutdown unit's script
ansible.builtin.stat:
path: "{{ item }}"
loop:
- /usr/local/sbin/docker-start-missed
- /etc/systemd/system/docker-start-missed.service
- /usr/local/sbin/docker-stop-at-shutdown
register: docker_verify_off
- name: The boot unit is gone and the shutdown unit is still there
ansible.builtin.assert:
that: docker_verify_off.results | map(attribute='stat.exists') | list == [false, false, true]
quiet: true
- name: Apply the role again with both inputs on
ansible.builtin.include_role:
name: mortis.kamino.docker
vars:
docker_start_missed: true
- name: Verify the daemon settings
hosts: all
gather_facts: false
@@ -328,43 +233,31 @@
- docker_verify_daemon_stat.stat.pw_name == 'root'
quiet: true
# The stand-in docker.service runs for real, so a restart shows in its start time. The first run turns the boot unit off and changes
# daemon.json with docker_daemon_restart false: the unit goes, the other stays and dockerd keeps running. The second turns everything
# back on with docker_daemon_restart true: the boot unit returns and dockerd restarts.
- name: Verify the unit inputs and that dockerd restarts only when asked
# The stand-in docker.service runs for real, so a restart shows in its start time: a changed file with docker_daemon_restart false leaves
# it alone, and with true restarts it.
- name: Verify that dockerd restarts only when asked
hosts: all
vars:
docker_gpg_url: file:///srv/docker-stub-repo/docker.asc
docker_keyring_checksum: "{{ docker_stub_key.stat.checksum }}"
docker_repo_base_url: file:///srv/docker-stub-repo
docker_users: [moleculeuser]
docker_start_missed: true
docker_stop_at_shutdown: true
docker_stop_at_shutdown_timeout: 20
docker_log_driver: local
docker_log_max_size: 10m
docker_log_max_file: "3"
docker_live_restore: true
docker_verify_unit_paths:
- /usr/local/sbin/docker-start-missed
- /etc/systemd/system/docker-start-missed.service
- /usr/local/sbin/docker-stop-at-shutdown
tasks:
- name: Stat the stand-in repository key
ansible.builtin.stat:
path: /srv/docker-stub-repo/docker.asc
checksum_algorithm: sha256
register: docker_stub_key
- name: Read the start time of the service
ansible.builtin.command: systemctl show -p ActiveEnterTimestampMonotonic docker.service # noqa: command-instead-of-module
register: docker_verify_before
changed_when: false
- name: Apply the boot unit off and a changed setting with docker_daemon_restart false
- name: Apply a changed setting with docker_daemon_restart false
ansible.builtin.include_role:
name: mortis.kamino.docker
vars:
docker_start_missed: false
docker_daemon_options: {max-concurrent-downloads: 5}
docker_daemon_restart: false
@@ -373,30 +266,10 @@
register: docker_verify_kept
changed_when: false
- name: Stat the boot unit's files and the shutdown unit's script
ansible.builtin.stat:
path: "{{ item }}"
loop: "{{ docker_verify_unit_paths }}"
register: docker_verify_off
- name: Read daemon.json
ansible.builtin.slurp:
src: /etc/docker/daemon.json
register: docker_verify_daemon_kept
- name: The boot unit is gone, the shutdown unit is still there, and the changed file left dockerd running
ansible.builtin.assert:
that:
- docker_verify_off.results | map(attribute='stat.exists') | list == [false, false, true]
- (docker_verify_daemon_kept.content | b64decode | from_json)['max-concurrent-downloads'] == 5
- docker_verify_kept.stdout == docker_verify_before.stdout
quiet: true
- name: Apply both units on and another change with docker_daemon_restart true
- name: Apply another change with docker_daemon_restart true
ansible.builtin.include_role:
name: mortis.kamino.docker
vars:
docker_start_missed: true
docker_daemon_options: {max-concurrent-downloads: 6}
docker_daemon_restart: true
@@ -405,33 +278,19 @@
register: docker_verify_restarted
changed_when: false
- name: Stat the unit files again
ansible.builtin.stat:
path: "{{ item }}"
loop: "{{ docker_verify_unit_paths }}"
register: docker_verify_on
- name: Read daemon.json again
- name: Read daemon.json
ansible.builtin.slurp:
src: /etc/docker/daemon.json
register: docker_verify_daemon_after
- name: Both units are back and the second change restarted dockerd
- name: The first change left dockerd alone and the second restarted it
ansible.builtin.assert:
that:
- docker_verify_on.results | map(attribute='stat.exists') | unique | list == [true]
- (docker_verify_daemon_after.content | b64decode | from_json)['max-concurrent-downloads'] == 6
- docker_verify_kept.stdout == docker_verify_before.stdout
- docker_verify_restarted.stdout != docker_verify_kept.stdout
- (docker_verify_daemon_after.content | b64decode | from_json)['max-concurrent-downloads'] == 6
quiet: true
# A key that does not match docker_keyring_checksum fails at the key download, so the source line and packages are untouched. It goes to a separate path, so
# the installed key stays for the removal below.
- name: A key that does not match the pinned checksum is refused
hosts: all
tasks:
- name: Apply the role with a wrong checksum
ansible.builtin.include_tasks: tasks/refuse_checksum.yml
# docker_remove_data is set, so this also covers the destructive path: the packages are
# purged and /var/lib/docker, seeded in prepare.yml, is deleted. The removal stops the unit
# before the package takes it away, so it can only run once; a second run would fail on the
+1 -4
View File
@@ -7,7 +7,6 @@
- curl
state: present
update_cache: true
cache_valid_time: 3600
tags: [docker, install]
- name: Ensure APT keyrings directory exists
@@ -23,7 +22,6 @@
ansible.builtin.get_url:
url: "{{ docker_gpg_url }}"
dest: "{{ docker_keyring_path }}"
checksum: "sha256:{{ docker_keyring_checksum }}"
mode: "0644"
tags: [docker, install]
@@ -32,7 +30,7 @@
ansible.builtin.copy:
dest: "{{ docker_apt_list_path }}"
content: |
deb [arch={{ __docker_apt_arch }} signed-by={{ docker_keyring_path }}] {{ docker_repo_base_url }} {{ ansible_facts['distribution_release'] }} stable
deb [arch={{ __docker_apt_arch }} signed-by={{ docker_keyring_path }}] {{ docker_repo_base_url }} {{ ansible_distribution_release }} stable
mode: "0644"
register: __docker_apt_source
tags: [docker, install]
@@ -42,7 +40,6 @@
ansible.builtin.apt:
name: "{{ docker_packages }}"
state: present
# Always refreshed: a run that wrote the source line but failed to fetch its lists heals here.
update_cache: true
register: __docker_packages
notify: Restart docker
+2 -4
View File
@@ -89,19 +89,17 @@ The scenario `molecule/default/` runs in CI only, on two platforms: `${MOLECULE_
- Verify checks that the `sshd` jail does not read `/var/log/auth.log`, that `jail.local` holds the configured `ignoreip` in `[DEFAULT]` and none of the refused values, that each service jail has its own `jail.d` file and the refused one left no file, that `fail2ban-client -t` passes, and that the running daemon loaded `sshd`, `svc-a` and `svc-b` and applies the `ignoreip` network to both a base jail and a service jail.
- The side effect bans an address and rewrites `jail.local` with a new `maxretry`; verify checks the new value is active, the ban is still in force and the daemon PID is unchanged, so the change reloaded Fail2Ban instead of restarting it.
The scenario `molecule/check-absent/` runs on the same two platforms: prepare purges fail2ban and refreshes the APT cache, then `check` runs the main entry point and `service_jail` under `--check`, which must pass with fail2ban not installed. Nothing is applied.
Not covered: no failure is sent through a jail, so a ban triggered by `failregex` is not tested, and the reload behaviours read from the Fail2Ban source (see Notes) are not run.
## Notes
- Idempotent: yes.
- Check mode: `--check` is the supported preview; a play-level `check_mode: true` is not supported. On a host without fail2ban the preview reports the install and skips the configuration, the service and the jail tasks, which need `/etc/fail2ban`, `fail2ban-client` and the unit.
- Check mode: `--check` previews a host where fail2ban is already installed; a play-level `check_mode: true` is not supported. On a host without fail2ban it fails at the configuration and service tasks: the package is not installed under `--check`, so `/etc/fail2ban`, `fail2ban-client` and the unit are missing.
- `fail2ban_ignoreip` lives in the `[DEFAULT]` section of `jail.local`, so it also applies to the jails that `service_jail` writes to `jail.d`. The exemption only exists once the main entry point has written `jail.local` on that host: `service_jail` does not read `fail2ban_ignoreip`, so a host that uses only `service_jail` has none.
- `fail2ban_ignoreip` replaces an `ignoreip` set in `jail.conf` or `jail.d/*.conf`, which Fail2Ban reads before `jail.local`; a `jail.d/*.local` file is read after it and can still override it for one jail. Entries must not contain whitespace, `;` or `%` (a `;` after whitespace starts a comment in Fail2Ban's config files and a `%` is interpolation syntax).
- Prefer IP addresses and CIDR networks in `fail2ban_ignoreip`. Fail2Ban resolves a hostname when the jail starts, and a failed lookup leaves that entry ineffective with only a log warning. The validation of `fail2ban_ignoreip` runs under the `fail2ban_validate` tag, so `--tags fail2ban_configure` skips it.
- Changing `jail.local` or a service jail reloads Fail2Ban instead of restarting it. A restart stops every jail, which flushes its bans out of the firewall until they are restored from the database, and forgets failures counted toward `maxretry`; a reload applies the new settings to the running jails. When the whole role runs, the reload comes after `fail2ban-client -t`.
- What a reload does not do, compared with the restart it replaces (read from the Fail2Ban 1.1.0 source, not run here): it does not unban an address that a widened `fail2ban_ignoreip` now covers (only a restart skips ignored addresses when it restores bans, so run `fail2ban-client unban <address>` to release one at once, or wait for the ban to expire); it does not change bans that already exist when `bantime` changes; and it does not apply server-level settings (`loglevel`, `dbfile`, `socket`, `pidfile`), which this role does not write. A changed `backend` restarts that jail by itself.
- With `--tags fail2ban_configure` only, `fail2ban-client -t` does not run before the reload; the reload (`fail2ban-client reload` in the upstream unit) still rejects a bad configuration and leaves the running daemon alone.
- `fail2ban-client -t` runs on every invocation of both entry points, not only when a file changed, so a broken file fails every run until fixed. It also runs in check mode, except on a host without fail2ban.
- `fail2ban-client -t` runs on every invocation of both entry points, not only when a file changed, so a broken file fails every run until fixed. It also runs in check mode.
- `no_log` is not used: the role handles no secrets.
-2
View File
@@ -11,5 +11,3 @@
ansible.builtin.systemd:
name: fail2ban
state: reloaded
# Under --check on a fresh host the package is not installed, so there is no unit to reload.
when: not ansible_check_mode or __fail2ban_install | default({}) is not changed
@@ -1,21 +0,0 @@
---
# Run only under --check (the check step): fail2ban is not installed, so the tasks that need it skip.
- name: Converge the base role on a host without fail2ban
hosts: all
roles:
- role: mortis.kamino.fail2ban
- name: Converge a service jail on a host without fail2ban
hosts: all
tasks:
- name: Service jail with a journalmatch
ansible.builtin.include_role:
name: mortis.kamino.fail2ban
tasks_from: service_jail
vars:
fail2ban_service_name: svc-a
fail2ban_service_jail:
port: "8080"
journalmatch: "_SYSTEMD_UNIT=ssh.service"
fail2ban_service_filter:
failregex: "^.*denied for <HOST>.*$"
@@ -1,55 +0,0 @@
---
# 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. Needs the network:
# prepare purges the fail2ban the image ships and refreshes the APT cache the image deletes.
driver:
name: docker
platforms:
- name: ${KAMINO_RUN_ID:-local}-fail2ban-check-absent-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
capabilities:
- NET_ADMIN
security_opts:
- apparmor=unconfined
- name: ${KAMINO_RUN_ID:-local}-fail2ban-check-absent-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:
name: ansible
scenario:
# Previews the role on a host without fail2ban (--check only, nothing is applied); no destroy:
# scripts/run_molecule_scenarios.sh removes the container as soon as this scenario ends.
test_sequence:
- dependency
- create
- prepare
- check
@@ -1,16 +0,0 @@
---
# The image ships fail2ban and no APT lists; the check step needs fail2ban gone and the lists back,
# or the install task cannot even preview the package.
- name: Prepare a host without fail2ban
hosts: all
gather_facts: false
tasks:
- name: Purge fail2ban
ansible.builtin.apt:
name: fail2ban
state: absent
purge: true
- name: Refresh the APT cache
ansible.builtin.apt:
update_cache: true
-2
View File
@@ -8,5 +8,3 @@
group: root
mode: "0600"
notify: Reload Fail2Ban
# Under --check on a fresh host the package is not installed, so /etc/fail2ban is missing.
when: not ansible_check_mode or __fail2ban_install | default({}) is not changed
-1
View File
@@ -7,4 +7,3 @@
# Required for `backend = systemd` jails (journalmatch), e.g. gitea's.
- python3-systemd
state: present
register: __fail2ban_install
+1 -6
View File
@@ -8,8 +8,6 @@
failed_when: fail2ban_test.rc != 0
changed_when: false
check_mode: false
# Under --check on a fresh host the package is not installed: no fail2ban-client and no unit.
when: not ansible_check_mode or __fail2ban_install | default({}) is not changed
- name: Ensure Fail2Ban service is running
become: true
@@ -17,7 +15,6 @@
name: fail2ban
enabled: "{{ fail2ban_service.enabled | default(true) }}"
state: "{{ fail2ban_service.state | default('started') }}"
when: not ansible_check_mode or __fail2ban_install | default({}) is not changed
# Handlers run at the end of the play; flush so the reload happens after the
# configuration test above and before the jail check below.
@@ -36,6 +33,4 @@
delay: 2
changed_when: false
check_mode: false
when:
- not ansible_check_mode or __fail2ban_install | default({}) is not changed
- fail2ban_service.state | default('started') == 'started'
when: fail2ban_service.state | default('started') == 'started'
+2 -5
View File
@@ -33,8 +33,6 @@
group: root
mode: "0644"
notify: Reload Fail2Ban
# Under --check on a fresh host the package is not installed, so /etc/fail2ban is missing.
when: not ansible_check_mode or __fail2ban_install | default({}) is not changed
tags: [fail2ban, fail2ban_service_jail]
- name: Deploy service jail
@@ -46,15 +44,14 @@
group: root
mode: "0644"
notify: Reload Fail2Ban
when: not ansible_check_mode or __fail2ban_install | default({}) is not changed
tags: [fail2ban, fail2ban_service_jail]
# Read-only, so it also runs in check mode. A failure leaves the broken file on
# disk and fails every run until fixed, instead of only the run that wrote it.
tags: [fail2ban, fail2ban_service_jail]
- name: Test Fail2Ban configuration
become: true
ansible.builtin.command: fail2ban-client -t
changed_when: false
check_mode: false
when: not ansible_check_mode or __fail2ban_install | default({}) is not changed
tags: [fail2ban, fail2ban_service_jail]
+1 -1
View File
@@ -18,7 +18,7 @@ The role targets Ubuntu hosts that run CI jobs, not Proxmox nodes, so it does no
- The registration token is generated on the fly, held in a `no_log` fact and passed to `gitea-runner register` through the `GITEA_RUNNER_REGISTRATION_TOKEN` environment variable, not argv. It is never written to a file by the role.
- The role creates `gitea_runner_group` and `gitea_runner_user` when they are missing; an existing account (for example the SSH login user) is reused.
- Docker is installed by this role (`tasks/docker.yml`) on first install, not by `mortis.kamino.docker`.
- Fact gathering must be on for `gitea_runner_force_register`: the backup name uses `ansible_facts['date_time']`.
- Fact gathering must be on for `gitea_runner_force_register`: the backup name uses `ansible_date_time`.
- Updates: the update path stages the verified binary and hands the swap to `mortis.kamino._binary_update`, an internal role of this Collection.
- `gitea_runner_version` is asserted at role start to be a plain `X.Y.Z` release number, with no leading `v`. Pin it in inventory to move the runner independently of Collection releases; the role default changes only with a release.
- The executor and job image of a job come from its label's suffix (`:host` or `docker://<image>`); a label with no suffix runs its jobs on the host. `config.yaml` has no keys for them.
+1 -1
View File
@@ -19,7 +19,7 @@ argument_specs:
C(gitea_runner_token_host), C(gitea_runner_instance_url) and C(gitea_runner_name) have empty role defaults and
are asserted only when registration runs, so a run that never registers is not blocked.
- >-
Reads gathered facts (C(ansible_facts['date_time']), for the forced re-registration backup name) and
Reads gathered facts (C(ansible_date_time), for the forced re-registration backup name) and
C(ansible_check_mode).
options:
gitea_runner_remove:
+38 -38
View File
@@ -359,26 +359,23 @@
loop_var: gitea_runner_test_path
# 6.0.2 has a wrong checksum file (prepare.yml): the download must fail before anything is
# stopped, so the runner keeps running 6.0.1. The same run sets the disk threshold to 0: prune
# runs before update, so the pressure units are already removed when the download fails.
- name: Verify a failed download leaves the runner running, and turning the pressure prune off
# stopped, so the runner keeps running 6.0.1.
- name: Verify a failed download leaves the runner running
hosts: all
gather_facts: false
tasks:
- name: Update to a release whose checksum does not match
block:
- name: Include the role with gitea_runner_version 6.0.2 and the disk threshold at 0
- name: Include the role with gitea_runner_version 6.0.2
ansible.builtin.include_role:
name: mortis.kamino.gitea_runner
vars:
gitea_runner_version: 6.0.2
gitea_runner_docker_prune_disk_threshold_percent: 0
- name: Fail because the include returned
ansible.builtin.fail:
msg: The role accepted a binary with a wrong checksum
rescue:
# The message comes only from the staging rescue, so a prune error fails this assert.
- name: The staging failed, and nothing else failed first
ansible.builtin.assert:
that:
@@ -410,31 +407,6 @@
- not gitea_runner_test_staged.stat.exists
quiet: true
- name: Stat the pressure units and script
ansible.builtin.stat:
path: "{{ gitea_runner_test_path }}"
loop:
- /etc/systemd/system/gitea-runner-docker-prune-pressure.service
- /etc/systemd/system/gitea-runner-docker-prune-pressure.timer
- /usr/local/sbin/gitea-runner-docker-prune-disk-check
loop_control:
loop_var: gitea_runner_test_path
register: gitea_runner_test_pressure_off
- name: Ask systemd about the pressure timer after turning it off
ansible.builtin.systemd:
name: gitea-runner-docker-prune-pressure.timer
register: gitea_runner_test_pressure_timer_off
# The module errors for a unit that no longer exists, which is also a pass.
failed_when: false
- name: The pressure units are gone and the timer is not active
ansible.builtin.assert:
that:
- gitea_runner_test_pressure_off.results | map(attribute='stat') | map(attribute='exists') | select | list | length == 0
- gitea_runner_test_pressure_timer_off.status.ActiveState | default('inactive') != 'active'
quiet: true
# Each input assert, through the main entry point. Every one runs in validate.yml, before any
# change.
- name: Verify the input asserts
@@ -476,9 +448,8 @@
label: "{{ gitea_runner_test_refused.name }}"
# The CI guard and the mint-before-drop order of a forced re-registration, through a child
# ansible-playbook against one instance (see force_register.yml). Neither case may touch the
# registration or stop the runner. The children run once: what they check is controller state
# and group_vars, the same for every host, and run_once gives every host their results.
# ansible-playbook against this instance (see force_register.yml). Neither case may touch the
# registration or stop the runner.
- name: Verify the forced re-registration guards
hosts: all
gather_facts: false
@@ -494,7 +465,6 @@
- name: Force a re-registration under each CI variable, as a child process with only that one set
delegate_to: localhost
run_once: true
ansible.builtin.command:
argv:
- ansible-playbook
@@ -527,7 +497,6 @@
- name: Force a re-registration outside CI with no token host, as a child process
delegate_to: localhost
run_once: true
ansible.builtin.command:
argv:
- ansible-playbook
@@ -581,12 +550,43 @@
- gitea_runner_test_unit.status.ActiveState == 'active'
quiet: true
# The failed-download run above removed the pressure units; this run, with the scenario's inputs,
# A threshold of 0 removes the pressure units; the run after it, with the scenario's inputs,
# puts them back, so the remove path below still has them to remove.
- name: Verify turning the pressure prune on again
- name: Verify turning the pressure prune off
hosts: all
gather_facts: false
tasks:
- name: Run the role with the disk threshold at 0
ansible.builtin.include_role:
name: mortis.kamino.gitea_runner
vars:
gitea_runner_docker_prune_disk_threshold_percent: 0
- name: Stat the pressure units and script
ansible.builtin.stat:
path: "{{ gitea_runner_test_path }}"
loop:
- /etc/systemd/system/gitea-runner-docker-prune-pressure.service
- /etc/systemd/system/gitea-runner-docker-prune-pressure.timer
- /usr/local/sbin/gitea-runner-docker-prune-disk-check
loop_control:
loop_var: gitea_runner_test_path
register: gitea_runner_test_pressure_off
- name: Ask systemd about the pressure timer after turning it off
ansible.builtin.systemd:
name: gitea-runner-docker-prune-pressure.timer
register: gitea_runner_test_pressure_timer_off
# The module errors for a unit that no longer exists, which is also a pass.
failed_when: false
- name: The pressure units are gone and the timer is not active
ansible.builtin.assert:
that:
- gitea_runner_test_pressure_off.results | map(attribute='stat') | map(attribute='exists') | select | list | length == 0
- gitea_runner_test_pressure_timer_off.status.ActiveState | default('inactive') != 'active'
quiet: true
- name: Run the role again with the scenario's inputs
ansible.builtin.include_role:
name: mortis.kamino.gitea_runner
+1 -1
View File
@@ -71,7 +71,7 @@
become: true
ansible.builtin.copy:
src: "{{ gitea_runner_work_dir }}/.runner"
dest: "{{ gitea_runner_work_dir }}/.runner.bak.{{ ansible_facts['date_time']['iso8601_basic_short'] }}"
dest: "{{ gitea_runner_work_dir }}/.runner.bak.{{ ansible_date_time.iso8601_basic_short }}"
remote_src: true
owner: "{{ gitea_runner_state.stat.pw_name }}"
group: "{{ gitea_runner_state.stat.gr_name }}"
-74
View File
@@ -1,74 +0,0 @@
# nfs_client
Installs the NFS client (`nfs-common`) and manages NFS mount entries in `/etc/fstab`. It writes the fstab line, creates the mount point and reloads systemd; it never mounts or unmounts anything. Variables and their types are defined in [`meta/argument_specs.yml`](meta/argument_specs.yml), which is the source of truth.
## Supported platforms
Ubuntu 24.04 (noble) and 26.04 (resolute), the platforms the molecule scenario runs on. The role asserts a Debian-family host before any change.
Untested platforms: Debian 13 (trixie). The role has no OS-specific branch, but no scenario runs on it until the Debian image (#226) exists.
## Requirements and run order
- Use it by its fully qualified name, `mortis.kamino.nfs_client`, in a play that gathers facts: the Debian-family assert reads them.
- Role dependencies: none. The role calls `ansible.posix.mount`, so the Collection's `ansible.posix` dependency applies.
- `become` is used for every task that changes the host.
- The role does not set up an NFS server, autofs, CIFS/SMB or Kerberos, and it does not wait for a mount.
## Role variables
| Variable | Default | Description |
|---|---|---|
| `nfs_client_mounts` | `[]` | The mounts to manage: a list of entries, each mount point once. With no entries only the client package is installed. |
| `nfs_client_default_opts` | `_netdev,nofail` | Options for an entry that sets none. |
An entry takes these keys:
| Key | Default | Description |
|---|---|---|
| `src` | required | The export as `server:/export`, one word without spaces. |
| `path` | required | The mount point: absolute, without spaces, not `/`, no trailing slash. |
| `opts` | `nfs_client_default_opts` | The fstab options, one comma-separated word. Put the NFS version here, for example `vers=4.2`. |
| `state` | `present` | `present` writes the fstab line. `absent` removes it and nothing else. |
## Tags
- `nfs_client`: everything the role does.
- `install`: the client package.
- `configure`: the mount points and the fstab entries.
Validation runs under `always`, so a bad input fails before any change whatever tags the run selects.
## Example play
```yaml
- name: NFS client
hosts: nfs_clients
roles:
- role: mortis.kamino.nfs_client
vars:
nfs_client_mounts:
- src: nas.example:/export/data
path: /mnt/data
- src: nas.example:/export/media
path: /mnt/media
opts: _netdev,nofail,ro,vers=4.2
```
## Tests
`molecule/default` runs on Ubuntu noble and resolute: a check on a fresh host, the converge, a check on the configured host, an idempotence run, and `verify.yml`. The scenario seeds an fstab line for `/mnt/data` that names another server and a line and a directory for `/mnt/old`, so the run shows that a line is replaced once and that an `absent` entry loses only its line.
`verify.yml` first checks a refusal for each validation on the controller, once, in check mode (a missing or empty `src`, a `src` without an export, a relative path, the root, a trailing slash, options with a space or none, a duplicate path, `mounted` and `remounted`, a host without facts). It then asserts, on each container, the client package, the exact fstab fields, that a new mount point is root's and an existing one keeps its owner and mode, that the removed entry's directory and file are intact, that `/proc/mounts` shows nothing mounted, and that systemd has a mount unit for each new entry and none for the removed one.
What it does not show: that a real share mounts at boot (the server in the scenario does not exist), that `x-systemd.automount` or any option other than the defaults behaves, and Debian trixie.
## Notes
- **Why only the fstab.** `ansible.posix.mount` with `state: mounted` mounts from the play's own process. Where that process runs in a private mount namespace (a hardened sshd unit can), systemd and containers do not see the mount. The role writes the line and reloads systemd, and the share is mounted at the next boot or with `systemctl start <unit>.mount`. New options reach a share that is already mounted only after it is remounted or the host reboots.
- **No owner, group or mode on the mount point.** Once a share is mounted the path is the export root, and a `chown` or `chmod` there changes the permissions on the NFS server. A new directory gets the system defaults, and an existing one is left as it is.
- **A share that is mounted and unreachable.** On a re-run the role looks at each `present` mount point, and a mounted path whose server is gone can block that look. Fix or unmount the share, or leave that entry out of the run, before running the role again.
- **`absent` leaves the share alone.** The entry's line is removed; the share stays mounted until it is unmounted and the mount point is not deleted.
- **Default options.** `_netdev` orders the mount after the network and puts it in `remote-fs.target`; `nofail` keeps an unreachable server from holding up the boot. `x-systemd.automount` changes when a mount appears and can hide an unreachable server until first access, so it is left to the host that wants it. The `docker` role's `docker_stop_at_shutdown` relies on the same `remote-fs.target` ordering.
- `--check` is the supported preview; a play-level `check_mode: true` is not supported. `apt` and the fstab edit both report what would change.
- Idempotent: yes.
-8
View File
@@ -1,8 +0,0 @@
---
# Each entry: src (server:/export) and path (absolute mount point) are required; opts falls back
# to nfs_client_default_opts; state is present (default) or absent.
nfs_client_mounts: []
# _netdev orders the mount after the network and puts it in remote-fs.target; nofail keeps an
# unreachable server from holding up the boot. x-systemd.automount is left to the host that wants it.
nfs_client_default_opts: "_netdev,nofail"
-7
View File
@@ -1,7 +0,0 @@
---
# systemd builds a mount unit from each fstab line only when it reloads, so the reload is what
# makes a changed line known to systemd. It mounts nothing.
- name: Reload systemd for the nfs_client fstab entries
become: true
ansible.builtin.systemd_service:
daemon_reload: true
-57
View File
@@ -1,57 +0,0 @@
---
argument_specs:
main:
short_description: Install the NFS client and manage NFS entries in /etc/fstab
description:
- >-
Asserts a Debian-family host, installs C(nfs-common), creates each mount point of a C(present) entry without
owner, group or mode, writes or removes the entry's line in C(/etc/fstab), and reloads systemd after a change
so that the mount unit is generated now. Nothing is mounted.
- >-
It never mounts or unmounts anything. An C(absent) entry only loses its fstab line: the share stays mounted
until it is unmounted or the host reboots, and the mount point is not removed. Needs gathered facts.
options:
nfs_client_mounts:
type: list
elements: dict
default: []
description:
- >-
The NFS mounts to manage. Each mount point may appear once. With the default (no entries) only the client
package is installed.
options:
src:
type: str
required: true
description:
- The export as C(server:/export), one word without spaces.
path:
type: str
required: true
description:
- >-
The mount point: an absolute path without spaces, not C(/) and without a trailing slash. Created, when
the entry is C(present), with no owner, group or mode.
opts:
type: str
description:
- >-
The fstab options, one comma-separated word without spaces. Falls back to C(nfs_client_default_opts)
when left out or empty. Put the NFS version here, for example C(vers=4.2).
state:
type: str
default: present
choices: [present, absent]
description:
- >-
C(present) writes the fstab line. C(absent) removes it and nothing else. The role has no C(mounted),
C(unmounted) or C(remounted): mounting is left to systemd, so that a mount made from a play running in a
private mount namespace (a hardened sshd unit) cannot go unseen by systemd and by containers.
nfs_client_default_opts:
type: str
default: "_netdev,nofail"
description:
- >-
Options for an entry that sets none. C(_netdev) orders the mount after the network and puts it in
C(remote-fs.target); C(nofail) keeps an unreachable server from holding up the boot.
C(x-systemd.automount) is not in the default.
-18
View File
@@ -1,18 +0,0 @@
---
galaxy_info:
role_name: nfs_client
namespace: mortis
author: Dragonish
license: GPL-3.0-or-later
description: Install the NFS client and manage NFS mount entries in /etc/fstab, without mounting anything.
min_ansible_version: "2.22"
platforms:
- name: Ubuntu
versions:
- noble
- resolute
galaxy_tags:
- nfs
- fstab
- storage
dependencies: []
@@ -1,7 +0,0 @@
---
# The mounts come from molecule.yml.
- name: Converge
hosts: all
gather_facts: true
roles:
- role: mortis.kamino.nfs_client
@@ -1,75 +0,0 @@
---
# 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 the Ubuntu mirrors: the role installs nfs-common. The
# containers run systemd as PID 1 with a writable cgroup, so a daemon-reload builds mount units
# from /etc/fstab; no privileged mode. Nothing is ever mounted: the server below does not exist.
driver:
name: docker
platforms:
- name: ${KAMINO_RUN_ID:-local}-nfs-client-noble
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
- name: ${KAMINO_RUN_ID:-local}-nfs-client-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 plays in verify.yml start from the same
# valid input: a default-options mount, one with its own options, one to remove (prepare.yml
# seeds its line), and /mnt/data, whose seeded line has another server and must be replaced.
inventory:
group_vars:
all:
nfs_client_mounts:
- src: nas.example:/export/data
path: /mnt/data
- src: nas.example:/export/media
path: /mnt/media
opts: _netdev,nofail,ro,vers=4.2
- src: nas.example:/export/old
path: /mnt/old
state: absent
verifier:
name: ansible
scenario:
# molecule's default sequence minus both destroys (scripts/run_molecule_scenarios.sh removes the
# containers as soon as this scenario ends; after a local run, run `molecule destroy` yourself),
# plus a check before the converge (fresh host) and one after it (configured host).
test_sequence:
- dependency
- cleanup
- syntax
- create
- prepare
- check
- converge
- check
- idempotence
- side_effect
- verify
- cleanup
@@ -1,43 +0,0 @@
---
# The state a host has before the role runs: a line for /mnt/data that names another server (the
# role must replace it, once) and a line and a mount point for /mnt/old, the entry the converge
# removes. The file in /mnt/old shows that removing the line leaves the directory alone.
- name: Prepare
hosts: all
gather_facts: false
tasks:
# The image ships without apt lists, and --check does not refresh them, so without this the
# fresh-host check finds no nfs-common to install.
- name: Refresh the apt cache
ansible.builtin.apt:
update_cache: true
- name: Seed the fstab lines
ansible.builtin.lineinfile:
path: /etc/fstab
line: "{{ item }}"
create: true
mode: "0644"
loop:
- old-nas.example:/export/data /mnt/data nfs defaults 0 0
- nas.example:/export/old /mnt/old nfs _netdev,nofail 0 0
- name: Create the mount point that the converge leaves alone
ansible.builtin.file:
path: /mnt/old
state: directory
mode: "0750"
- name: Put a file in it
ansible.builtin.copy:
content: kept
dest: /mnt/old/keep
mode: "0644"
# An existing mount point of a present entry: the role must leave its owner and mode alone.
- name: Create a mount point with an owner and a mode of its own
ansible.builtin.file:
path: /mnt/media
state: directory
owner: daemon
mode: "0710"
@@ -1,21 +0,0 @@
---
# One failing run: includes the role with the inputs the caller sets on the include, and asserts
# that the expected message, not something else, stopped it. Input: nfs_client_test_case (name,
# expect).
- name: "Run the role, case {{ nfs_client_test_case.name }}"
block:
- name: "Include the role, case {{ nfs_client_test_case.name }}"
ansible.builtin.include_role:
name: mortis.kamino.nfs_client
# 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 {{ nfs_client_test_case.name }}"
ansible.builtin.fail:
msg: The role accepted the input
rescue:
- name: "The expected failure stopped the run, case {{ nfs_client_test_case.name }}"
ansible.builtin.assert:
that: nfs_client_test_case.expect in (ansible_failed_result.msg | default(''))
fail_msg: "Expected '{{ nfs_client_test_case.expect }}', got: {{ ansible_failed_result.msg | default('') }}"
quiet: true
@@ -1,247 +0,0 @@
---
# The refusals below stop in validation, before any task that changes a host, so they need no
# container: they run once, on the controller, in check mode so that a regressed guard cannot
# change it.
#
# Runs first, before any play gathers facts: the role refuses a host it cannot identify as
# Debian-family, before any change.
- name: Refuse a host without facts
hosts: localhost
connection: local
check_mode: true
gather_facts: false
tasks:
- name: Run the role without gathered facts
ansible.builtin.include_tasks: tasks/failed_run.yml
vars:
nfs_client_test_case:
name: no-facts
expect: nfs_client supports Debian-family hosts only
# Negative tests: each validation stops the role before any change, with its own message. The
# inputs replace the converge's mounts for one include only.
- name: Refuse invalid input
hosts: localhost
connection: local
check_mode: true
gather_facts: true
tasks:
- name: Refuse a state the role does not have
ansible.builtin.include_tasks: tasks/failed_run.yml
vars:
nfs_client_mounts:
- {src: "nas.example:/export/data", path: /mnt/data, state: mounted}
nfs_client_test_case:
name: state-mounted
expect: "value of state must be one of: present, absent, got: mounted"
- name: Refuse remounted
ansible.builtin.include_tasks: tasks/failed_run.yml
vars:
nfs_client_mounts:
- {src: "nas.example:/export/data", path: /mnt/data, state: remounted}
nfs_client_test_case:
name: state-remounted
expect: "value of state must be one of: present, absent, got: remounted"
- name: Refuse an entry without a src
ansible.builtin.include_tasks: tasks/failed_run.yml
vars:
nfs_client_mounts:
- {path: /mnt/data}
nfs_client_test_case:
name: src-missing
expect: "missing required arguments: src"
- name: Refuse an empty src
ansible.builtin.include_tasks: tasks/failed_run.yml
vars:
nfs_client_mounts:
- {src: "", path: /mnt/data}
nfs_client_test_case:
name: src-empty
expect: nfs_client_mounts src must be one word of the form server:/export
- name: Refuse a src without an export
ansible.builtin.include_tasks: tasks/failed_run.yml
vars:
nfs_client_mounts:
- {src: nas.example, path: /mnt/data}
nfs_client_test_case:
name: src-no-export
expect: nfs_client_mounts src must be one word of the form server:/export
- name: Refuse a src with a space after the export
ansible.builtin.include_tasks: tasks/failed_run.yml
vars:
nfs_client_mounts:
- {src: "nas.example:/export/my data", path: /mnt/data}
nfs_client_test_case:
name: src-space
expect: nfs_client_mounts src must be one word of the form server:/export
- name: Refuse a mount point with a space
ansible.builtin.include_tasks: tasks/failed_run.yml
vars:
nfs_client_mounts:
- {src: "nas.example:/export/data", path: "/mnt/my data"}
nfs_client_test_case:
name: path-space
expect: nfs_client_mounts path must be an absolute path
- name: Refuse a relative mount point
ansible.builtin.include_tasks: tasks/failed_run.yml
vars:
nfs_client_mounts:
- {src: "nas.example:/export/data", path: mnt/data}
nfs_client_test_case:
name: path-relative
expect: nfs_client_mounts path must be an absolute path
- name: Refuse the root as a mount point
ansible.builtin.include_tasks: tasks/failed_run.yml
vars:
nfs_client_mounts:
- {src: "nas.example:/export/data", path: /}
nfs_client_test_case:
name: path-root
expect: nfs_client_mounts path must be an absolute path
- name: Refuse a trailing slash
ansible.builtin.include_tasks: tasks/failed_run.yml
vars:
nfs_client_mounts:
- {src: "nas.example:/export/data", path: /mnt/data/}
nfs_client_test_case:
name: path-trailing-slash
expect: nfs_client_mounts path must be an absolute path
- name: Refuse options with a space
ansible.builtin.include_tasks: tasks/failed_run.yml
vars:
nfs_client_mounts:
- {src: "nas.example:/export/data", path: /mnt/data, opts: "ro, nofail"}
nfs_client_test_case:
name: opts-space
expect: nfs_client_mounts options must be a non-empty comma-separated word
- name: Refuse an entry with no options when the default is empty
ansible.builtin.include_tasks: tasks/failed_run.yml
vars:
nfs_client_default_opts: ""
nfs_client_mounts:
- {src: "nas.example:/export/data", path: /mnt/data}
nfs_client_test_case:
name: opts-empty
expect: nfs_client_mounts options must be a non-empty comma-separated word
- name: Refuse the same mount point twice
ansible.builtin.include_tasks: tasks/failed_run.yml
vars:
nfs_client_mounts:
- {src: "nas.example:/export/data", path: /mnt/data}
- {src: "nas.example:/export/other", path: /mnt/data}
nfs_client_test_case:
name: duplicate-path
expect: nfs_client_mounts lists the same path twice
- name: Verify the host
hosts: all
gather_facts: true
tasks:
- name: Read the installed packages
ansible.builtin.package_facts:
manager: apt
- name: The client package is installed
ansible.builtin.assert:
that:
- "'nfs-common' in ansible_facts.packages"
quiet: true
- name: Read fstab
ansible.builtin.slurp:
src: /etc/fstab
register: nfs_client_test_fstab
# Each line split into its six fields, so the assertions do not depend on the spacing the
# module writes.
- name: Split the fstab lines into fields
ansible.builtin.set_fact:
nfs_client_test_rows: >-
{{ (nfs_client_test_fstab.content | b64decode).splitlines()
| reject('match', '^#')
| map('split')
| reject('equalto', [])
| list }}
# The seeded line for /mnt/data named another server and the default options: the role
# replaces it, so exactly one line is left for the path.
- name: The default-options entry replaced the seeded line
ansible.builtin.assert:
that:
- "['nas.example:/export/data', '/mnt/data', 'nfs', '_netdev,nofail', '0', '0'] in nfs_client_test_rows"
- nfs_client_test_rows | selectattr('1', 'eq', '/mnt/data') | list | length == 1
quiet: true
- name: The entry with its own options keeps them
ansible.builtin.assert:
that:
- "['nas.example:/export/media', '/mnt/media', 'nfs', '_netdev,nofail,ro,vers=4.2', '0', '0'] in nfs_client_test_rows"
quiet: true
- name: The absent entry lost its line
ansible.builtin.assert:
that:
- nfs_client_test_rows | selectattr('1', 'eq', '/mnt/old') | list | length == 0
quiet: true
- name: Stat the mount points
ansible.builtin.stat:
path: "{{ item }}"
loop: [/mnt/data, /mnt/media, /mnt/old, /mnt/old/keep]
register: nfs_client_test_stat
# prepare.yml gave /mnt/media an owner and a mode and /mnt/old a mode of its own. The role
# created /mnt/data (a new directory is root's) and changed neither of the others, and the
# removed entry's directory and the file in it are untouched.
- name: The mount points exist, keep their owner and mode, and the removed entry's directory is intact
ansible.builtin.assert:
that:
- nfs_client_test_stat.results | map(attribute='stat.exists') | min
- nfs_client_test_stat.results[0].stat.isdir
- nfs_client_test_stat.results[0].stat.pw_name == 'root'
- nfs_client_test_stat.results[1].stat.pw_name == 'daemon'
- nfs_client_test_stat.results[1].stat.mode == '0710'
- nfs_client_test_stat.results[2].stat.mode == '0750'
quiet: true
- name: Read what is mounted
ansible.builtin.slurp:
src: /proc/mounts
register: nfs_client_test_mounts
- name: Nothing was mounted
ansible.builtin.assert:
that:
- "'/mnt/data' not in (nfs_client_test_mounts.content | b64decode)"
- "'/mnt/media' not in (nfs_client_test_mounts.content | b64decode)"
quiet: true
# The daemon-reload is what turns an fstab line into a unit; the generator ran again, so the
# new lines have a unit and the removed one has none. systemctl and not the systemd module,
# which fails on a unit that is not loaded, the very state asserted for the removed entry.
- name: Ask systemd about the mount units # noqa: command-instead-of-module
ansible.builtin.command: "systemctl show --property=LoadState --value {{ item }}"
loop: [mnt-data.mount, mnt-media.mount, mnt-old.mount]
register: nfs_client_test_units
changed_when: false
check_mode: false
- name: Systemd knows the new entries and not the removed one
ansible.builtin.assert:
that:
- nfs_client_test_units.results[0].stdout == 'loaded'
- nfs_client_test_units.results[1].stdout == 'loaded'
- nfs_client_test_units.results[2].stdout == 'not-found'
quiet: true
-48
View File
@@ -1,48 +0,0 @@
---
# 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: Install the NFS client package
become: true
ansible.builtin.apt:
name: "{{ __nfs_client_package }}"
state: present
update_cache: true
cache_valid_time: 3600
tags: [nfs_client, install]
# No owner, group or mode: once a share is mounted the path is the export root, and a chown or
# chmod there changes the permissions on the NFS server.
- name: Create the mount points # noqa: risky-file-permissions
become: true
ansible.builtin.file:
path: "{{ item.path }}"
state: directory
loop: "{{ __nfs_client_entries | selectattr('state', 'eq', 'present') | list }}"
loop_control:
label: "{{ item.path }}"
tags: [nfs_client, configure]
# present writes the fstab line and mounts nothing. An absent entry only loses its line:
# ansible.posix.mount's own absent would also unmount the share and delete the mount point.
- name: Manage the fstab entries
become: true
ansible.posix.mount:
src: "{{ item.src }}"
path: "{{ item.path }}"
fstype: nfs
opts: "{{ item.opts }}"
dump: "0"
passno: "0"
state: "{{ 'present' if item.state == 'present' else 'absent_from_fstab' }}"
loop: "{{ __nfs_client_entries }}"
loop_control:
label: "{{ item.path }}"
notify: Reload systemd for the nfs_client fstab entries
tags: [nfs_client, configure]
- name: Flush handlers
ansible.builtin.meta: flush_handlers
-73
View File
@@ -1,73 +0,0 @@
---
# Input checks. Imported first in main.yml with tags: always, so a bad input fails before any
# change. The argument spec (types, choices, required keys) runs before this file; the rules
# below are the ones between values. Each assert covers the whole list, not one item per loop
# pass, so the failure message is the assert's own. fstab fields are split on whitespace, so
# "one word" is tested with split rather than a pattern.
# The package and the fstab format are Debian's, and the role reads gathered facts.
- name: Require a Debian-family host
ansible.builtin.assert:
that:
- ansible_facts['os_family'] | default('') == 'Debian'
fail_msg: >-
nfs_client supports Debian-family hosts only (found: {{ ansible_facts['os_family'] | default('no gathered facts') }}).
The role reads gathered facts, so run it in a play that gathers them.
quiet: true
# Fact-computing tasks that the checks below read. A statement block in one template would leave
# whitespace around the result and make it a string instead of a list, so the list is built by
# appending one entry per pass.
- name: Start the resolved entries
ansible.builtin.set_fact:
__nfs_client_entries: []
# Defaults of the suboptions are applied here: the spec's suboption defaults are documentation.
- name: Resolve the entries
ansible.builtin.set_fact:
__nfs_client_entries: >-
{{ __nfs_client_entries + [{
'src': item.src | trim,
'path': item.path,
'opts': (item.opts | default('', true) | trim) or (nfs_client_default_opts | trim),
'state': item.state | default('present', true)
}] }}
loop: "{{ nfs_client_mounts }}"
loop_control:
label: "{{ item.path }}"
- name: Require a server and an export in every src
ansible.builtin.assert:
that:
- __nfs_client_entries | map(attribute='src') | map('split') | map('length') | reject('eq', 1) | list | length == 0
- __nfs_client_entries | map(attribute='src') | reject('search', '^[^ ]+:/') | list | length == 0
fail_msg: >-
nfs_client_mounts src must be one word of the form server:/export, without spaces
(offending: {{ __nfs_client_entries | map(attribute='src') | reject('search', '^[^ ]+:/') | list }}).
quiet: true
- name: Require an absolute mount point that is not the root
ansible.builtin.assert:
that:
- __nfs_client_entries | map(attribute='path') | map('split') | map('length') | reject('eq', 1) | list | length == 0
- __nfs_client_entries | map(attribute='path') | reject('search', '^/[^ ]*[^/ ]$') | list | length == 0
fail_msg: >-
nfs_client_mounts path must be an absolute path without spaces, not the root and without a trailing slash
(offending: {{ __nfs_client_entries | map(attribute='path') | reject('search', '^/[^ ]*[^/ ]$') | list }}).
quiet: true
- name: Require options that fit one fstab field
ansible.builtin.assert:
that:
- __nfs_client_entries | map(attribute='opts') | map('split') | map('length') | reject('eq', 1) | list | length == 0
fail_msg: >-
nfs_client_mounts options must be a non-empty comma-separated word without spaces, from the entry's opts or, when
that is empty, from nfs_client_default_opts.
quiet: true
- name: Require one entry per mount point
ansible.builtin.assert:
that:
- __nfs_client_entries | map(attribute='path') | unique | list | length == __nfs_client_entries | length
fail_msg: nfs_client_mounts lists the same path twice; each mount point may appear once.
quiet: true
-3
View File
@@ -1,3 +0,0 @@
---
# Constant, not an input: the package that carries mount.nfs on Debian and Ubuntu.
__nfs_client_package: nfs-common
+2 -2
View File
@@ -98,8 +98,8 @@
- name: The user is a system account without a login shell
ansible.builtin.assert:
that:
- ansible_facts['getent_passwd'].pihole[5] == '/usr/sbin/nologin'
- ansible_facts['getent_passwd'].pihole[1] | int < 1000
- getent_passwd.pihole[5] == '/usr/sbin/nologin'
- getent_passwd.pihole[1] | int < 1000
quiet: true
# Neither check run (before and after the converge) ran the installer or the handler.
-133
View File
@@ -1,133 +0,0 @@
# pve_vm
Clones a Proxmox VE QEMU VM from a template through the Proxmox API and keeps its configuration, cloud-init settings, boot disk size and power state in line with the inputs. The configuration is updated only when drift is detected. Variables and their types are defined in [`meta/argument_specs.yml`](meta/argument_specs.yml), which is the source of truth.
## Supported platforms
Ubuntu 24.04 (noble) and 26.04 (resolute) guests, the platforms the molecule scenario runs on. The play runs for the VM's inventory host: the API calls run on the controller (`pve_vm_delegate`, default `localhost`), and only the cloud-init wait runs on the guest itself. The template the VM is cloned from must be a cloud-init image of one of these releases.
The guest-side cloud-init wait (`cloud-init status --wait`) is untested on both releases: the test images do not ship cloud-init.
The role targets the guests, not the Proxmox node, so it does not declare Debian trixie: the node is reached only through its API.
## Requirements and run order
- Use it by its fully qualified name, `mortis.kamino.pve_vm`, in a play over the VM hosts with `gather_facts: false`: the VM may not exist yet when the play starts.
- The controller needs the `community.proxmox` collection and the Python libraries `proxmoxer` 2.3 or later and `requests`.
- Role dependencies: none.
- `pve_vm_node` and `pve_vm_vmid` are required. `pve_vm_api_user` and `pve_vm_api_token_secret` have no usable default and are asserted non-empty before any change; `pve_vm_disk_size` too while `pve_vm_manage_disk` is true, unless `pve_vm_state` is `absent`.
- `pve_vm_api_host` defaults to the `ansible_host` of `pve_vm_node` from hostvars, so the node must then be an inventory host even when only the VM hosts are targeted. Set `pve_vm_api_host` explicitly when the node is not in the inventory.
- The VM's own `ansible_host` is the target of the SSH wait, and `inventory_hostname`, lowercased with underscores replaced by dashes, is its name in Proxmox.
- Run it before any role that configures the inside of the VM. Gate those on `pve_vm_exists` (below).
### API privileges
The API token needs, on the VM (or a pool or path above it), the template and the storage:
- `VM.Allocate`, `VM.Clone` (on the template), `VM.Audit` and `VM.Config.*` (`VM.Config.CDROM`, `VM.Config.CPU`, `VM.Config.Cloudinit`, `VM.Config.Disk`, `VM.Config.HWType`, `VM.Config.Memory`, `VM.Config.Network`, `VM.Config.Options`), and `VM.PowerMgmt` for the power state and restarts;
- `Datastore.AllocateSpace` on the storage that holds the disks;
- `SDN.Use` on the bridge or zone when `pve_vm_network` sets a network.
A token with privilege separation (the Proxmox default) gets the intersection of its own ACL and its user's: grant the role on both the user and the token.
## Role variables
| Variable | Default | Description |
|---|---|---|
| `pve_vm_node` | none (required) | Name of the Proxmox node that owns the VM. |
| `pve_vm_vmid` | none (required) | VM id; for a clone, the new id. |
| `pve_vm_state` | `present` | `present`, `started`, `stopped` or `absent`. `present` leaves the power state alone. |
| `pve_vm_allow_destroy` | `false` | Required before `absent` deletes the VM. |
| `pve_vm_clone_vmid` | none | Template id, read and asserted set only when the VM does not exist and is cloned. |
| `pve_vm_full_clone` | `true` | Full clone instead of a linked clone. |
| `pve_vm_delegate` | `localhost` | Host that runs the API module tasks. |
| `pve_vm_wait_for_guest` | `true` | Wait for SSH and cloud-init when `started`. |
| `pve_vm_agent` | `true` | QEMU guest agent. |
| `pve_vm_onboot` | `true` | Start on node boot. |
| `pve_vm_autostart` | `true` | Sent as `autostart` on update, never compared. |
| `pve_vm_memory`, `pve_vm_cores`, `pve_vm_sockets` | none | Sizing, omitted when undefined. |
| `pve_vm_network`, `pve_vm_ipconfig` | none | Mappings for `net` and `ipconfig`, see the spec. Omitted when undefined. |
| `pve_vm_nameservers` | none | List, or space or comma separated string. Omitted when undefined. |
| `pve_vm_sshkeys` | none | Cloud-init public keys, one per line. Omitted when undefined. |
| `pve_vm_ci_user` | `""` | Cloud-init user (`ciuser`). Left out of the update and of the drift check when empty. |
| `pve_vm_force_update` | `false` | Push the configuration and cloud-init settings without drift. |
| `pve_vm_manage_disk` | `true` | Grow the boot disk to `pve_vm_disk_size`. |
| `pve_vm_disk_size` | none (asserted) | Boot disk size, for example `32G`; only ever grown. |
| `pve_vm_boot_disk` | `scsi0` | Disk key whose size is read and resized. |
| `pve_vm_reboot_if_required` | `true` | Restart the VM after its boot disk was grown. |
| `pve_vm_api_user` | `""` (asserted) | API user without realm; `@<pve_vm_api_realm>` is appended. |
| `pve_vm_api_realm` | `pam` | Realm of the API user. |
| `pve_vm_api_token_id` | `<pve_vm_api_user>-token` | API token id. |
| `pve_vm_api_token_secret` | none (asserted) | API token secret, normally vaulted. No default. `no_log`. |
| `pve_vm_api_host` | `ansible_host` of `pve_vm_node`, empty without it | Proxmox API address (port 8006). |
The `pve_vm_api_*` inputs are applied through `module_defaults` inside the block that holds every API call of the role, and the REST lookup of the VM config sends the header `PVEAPIToken=<user>@<realm>!<token_id>=<secret>`, derived in `vars/main.yml`.
## Variables set by the role
- `pve_vm_exists`: the VM exists on the node.
## 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 VMs
hosts: vms
gather_facts: false
roles:
- role: mortis.kamino.pve_vm
vars:
pve_vm_state: started
pve_vm_node: pve1
pve_vm_vmid: 210
pve_vm_clone_vmid: 9000
pve_vm_memory: 4096
pve_vm_cores: 2
pve_vm_disk_size: 32G
pve_vm_network:
net0:
model: virtio
bridge: vmbr0
tag: 20
pve_vm_ipconfig:
ipconfig0: "ip={{ ansible_host }}/24,gw=192.0.2.1"
pve_vm_ci_user: ubuntu
pve_vm_sshkeys: "{{ lookup('ansible.builtin.file', 'files/admin.pub') }}"
pve_vm_api_user: ansible
pve_vm_api_token_secret: "{{ vault_pve_api_token_secret }}"
- name: Configure the VMs
hosts: vms
tasks:
- name: Configure the guest
ansible.builtin.include_role:
name: mortis.kamino.user_management
when: pve_vm_exists | default(false)
```
## Tests
The `default` molecule scenario runs in CI on Ubuntu 24.04 (noble) and 26.04 (resolute), the `molecule-ubuntu2404` and `molecule-ubuntu2604` images, which stand in for the guest. It runs `check` before the converge (a fresh host) and after it. The converge includes the internal task files `validate` and `detect_drift`, with a seeded VM config in Proxmox's own forms standing in for the REST lookup.
- Positive: `validate` accepts the scenario inputs, an unmanaged disk without a size, and `absent` without a size.
- Negative: through `main`, a state outside the spec, a VM id that is not a number, a missing API user and a missing token secret; through `validate`, a missing token secret with `absent` and a managed disk without a size; through `create`, a clone without `pve_vm_clone_vmid`. Each asserts the expected message.
- Drift: `detect_drift` over seeded configs: a matching config; the cloud-init user (empty input with a different or missing live `ciuser`, a changed user, a missing `ciuser`); the SSH keys (missing, rotated, empty input); a forced update; Proxmox's other value forms; every compared dimension at once; a dropped VLAN tag.
- Static, over every task file under `tasks/` (subdirectories and nested `block`, `rescue` and `always` included): no task calling `proxmox_kvm` (as `community.proxmox.proxmox_kvm`, `community.general.proxmox_kvm`, `ansible.legacy.proxmox_kvm` or `proxmox_kvm`, by its key or through `action` or `local_action`, with its `args` merged) sends `cipassword`; no `module_defaults` entry of any task or block sets `cipassword`; exactly one such task deletes a stored `cipassword`, and it is `no_log`.
Not exercised: the API lifecycle (lookup, clone, update, the `cipassword` delete, resize, start, stop, restart and delete), as there is no Proxmox API in the scenario; and the guest-side cloud-init wait, as the test images do not ship cloud-init.
## Notes
- Idempotent: yes, as far as drift detection goes, which the scenario checks: the update runs only on drift. The API calls themselves rely on `community.proxmox`, which is not tested; the update and the `cipassword` delete report changed whenever they run.
- Check mode: `--check` is the supported preview; a play-level `check_mode: true` is not supported. `proxmox_kvm` and `proxmox_disk` have no check mode support, so under `--check` the two reads (the `proxmox_kvm` `state: current` lookup and the REST GET of the VM config) run for real with `check_mode: false`, and every write is skipped and previewed instead: `Preview VM creation` for a missing VM (nothing else runs for it), `Report configuration drift` names the drifted dimensions and a pending disk resize (changed when the update or resize would run; it also reports on a real run), `Preview deletion of the stored cloud-init password` and `Preview VM power state`. Delete and restart are skipped. Roles gated on `pve_vm_exists` therefore run in check mode against existing VMs.
- Drift is checked for name, CPU type (always `host`), memory, cores, sockets, cloud-init user, `ipconfig0`, nameservers, `onboot`, agent and `net0`. A missing `ciuser` or `sshkeys` key in the live config also counts, and so does the first run after a clone.
- Cloud-init `sshkeys` are stored URL-encoded by Proxmox and cannot be diffed. A rotated `pve_vm_sshkeys` reaches an existing VM only through other detected drift, a fresh clone or `pve_vm_force_update: true`.
- The role never sets a cloud-init password (`cipassword`): the first login is by SSH key. A `cipassword` stored on a VM is deleted on the next real run, by a `no_log` task.
- Disk: the boot disk only grows. Only the digits of `pve_vm_disk_size` are compared with the current size in GB. After a resize the VM is restarted when `pve_vm_reboot_if_required` is true.
- With `pve_vm_state: absent` and `pve_vm_allow_destroy` true the VM is stopped and deleted and the play ends for that host. Without `pve_vm_allow_destroy` the role only looks the VM up and changes nothing.
- A VM that does not exist is detected by the module's "does not exist in cluster" message. Any other lookup failure stops the run, re-raised with only the module message.
- TLS certificates of the API are not verified.
- `no_log` is set on every task that carries the API token.
-31
View File
@@ -1,31 +0,0 @@
---
pve_vm_state: present # present | started | stopped | absent
pve_vm_allow_destroy: false
pve_vm_full_clone: true
pve_vm_wait_for_guest: true
pve_vm_delegate: localhost
pve_vm_agent: true
pve_vm_onboot: true
# Sent on update only; Proxmox does not return it in the VM config, so it is never compared.
pve_vm_autostart: true
pve_vm_manage_disk: true
pve_vm_boot_disk: scsi0
# Restart the VM after its boot disk was grown.
pve_vm_reboot_if_required: true
# Cloud-init (ciuser, sshkeys) is pushed to an existing VM only on other drift, on the first run
# after a clone, or when this is true: Proxmox stores sshkeys URL-encoded, so a rotated key is not
# detected as drift.
pve_vm_force_update: false
# Cloud-init user (ciuser). Empty means not sent to Proxmox and not compared for drift.
pve_vm_ci_user: ""
# Proxmox API credentials, asserted in tasks/validate.yml before any change. The user is the bare
# name: the role appends @<pve_vm_api_realm>. The token secret, pve_vm_api_token_secret, is a secret
# input with no default, normally vaulted.
pve_vm_api_user: ""
pve_vm_api_realm: pam
pve_vm_api_token_id: "{{ pve_vm_api_user }}-token"
# The Proxmox node's address. Guarded so the default templates to '' (and the argument validation
# passes) on a host without pve_vm_node.
pve_vm_api_host: "{{ hostvars[pve_vm_node].ansible_host if pve_vm_node is defined else '' }}"
-197
View File
@@ -1,197 +0,0 @@
---
argument_specs:
main:
short_description: Manage a Proxmox VE QEMU VM cloned from a template
description:
- >-
Looks the VM up through the Proxmox API, deletes it when C(pve_vm_state) is absent and C(pve_vm_allow_destroy) is
true, otherwise clones it from the template C(pve_vm_clone_vmid) when it does not exist, compares the live
configuration with the desired one, updates it only on drift, grows the boot disk, applies the power state
and waits for SSH and cloud-init when the VM is started.
- >-
Every API call is delegated to C(pve_vm_delegate) (the REST lookup of the config to localhost) and authenticates
with C(pve_vm_api_user) (bare user name, C(@<pve_vm_api_realm>) is appended), C(pve_vm_api_token_id),
C(pve_vm_api_token_secret) and C(pve_vm_api_host), applied through C(module_defaults), and with the header
C(PVEAPIToken=<user>@<realm>!<token_id>=<secret>) for the REST lookup, 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, before any change. C(community.proxmox) and, on the controller,
the Python libraries C(proxmoxer) 2.3 or later and C(requests) must be installed. TLS certificates are not
verified.
- >-
Also reads C(ansible_host) (SSH wait), C(inventory_hostname) (the VM name, lowercased with underscores replaced by
dashes) and C(ansible_check_mode). The role sets the fact C(pve_vm_exists) for later roles and plays.
- >-
Cloud-init sets C(ciuser) from C(pve_vm_ci_user); an empty user is left out of the update and not compared for
drift. The role never sets a cloud-init password (C(cipassword)) and deletes one stored on the VM on a real run.
options:
pve_vm_node:
type: str
required: true
description:
- >-
Name of the Proxmox node that owns the VM. When it is also an inventory host, its C(ansible_host) is the
default of C(pve_vm_api_host).
pve_vm_vmid:
type: int
required: true
description:
- VM id on the Proxmox node. For a clone it is the new id.
pve_vm_state:
type: str
default: present
choices: [present, started, stopped, absent]
description:
- >-
C(present) keeps the VM configured without touching its power state. C(started) and C(stopped) also apply the
power state, and C(started) additionally waits for SSH and cloud-init when C(pve_vm_wait_for_guest) is true.
C(absent) deletes the VM, but only when C(pve_vm_allow_destroy) is true. Without it the role only looks the
VM up and changes nothing, because creation, disk detection, update and power state are gated on a state
other than C(absent).
pve_vm_allow_destroy:
type: bool
default: false
description:
- Safety switch required before C(pve_vm_state=absent) deletes the VM.
pve_vm_clone_vmid:
type: raw
description:
- >-
Template VM id to clone. Only read when the VM does not exist and the play is not in check mode. The type is
not fixed, so it can be given as a Jinja expression that resolves to the id.
pve_vm_full_clone:
type: bool
default: true
description:
- Full clone instead of a linked clone.
pve_vm_delegate:
type: str
default: localhost
description:
- Host that executes the Proxmox API module tasks. The REST lookup of the VM config always runs on localhost.
pve_vm_wait_for_guest:
type: bool
default: true
description:
- >-
When true and C(pve_vm_state) is started, wait for SSH on port 22 of C(ansible_host) and then for
C(cloud-init status --wait) on the guest.
pve_vm_agent:
type: bool
default: true
description:
- Enable the QEMU guest agent. Compared with the live config for drift.
pve_vm_onboot:
type: bool
default: true
description:
- Start the VM when the node boots. Compared with the live config for drift.
pve_vm_autostart:
type: bool
default: true
description:
- >-
Passed to the module as C(autostart) on update. Not compared for drift, because Proxmox does not return it in
the VM config.
pve_vm_memory:
type: raw
description:
- Memory in MB. Omitted from the update when undefined. Compared as an integer for drift.
pve_vm_cores:
type: raw
description:
- CPU cores. Omitted from the update when undefined. Compared as an integer for drift.
pve_vm_sockets:
type: raw
description:
- CPU sockets. Omitted from the update when undefined. Compared as an integer for drift.
pve_vm_network:
type: raw
description:
- >-
Mapping passed to the module as C(net), for example C(net0) with C(model), C(bridge), C(tag) and C(firewall).
Omitted when undefined. Only C(net0) is compared for drift.
pve_vm_ipconfig:
type: raw
description:
- >-
Mapping passed to the module as C(ipconfig), for example C(ipconfig0) with a string such as
C(ip=<address>/24,gw=<gateway>). Omitted when undefined. Only C(ipconfig0) is compared for drift, token order
ignored.
pve_vm_nameservers:
type: raw
description:
- Nameservers as a list, or a space or comma separated string. Omitted when undefined.
pve_vm_sshkeys:
type: str
description:
- >-
Public keys written to the cloud-init C(sshkeys) field, one per line. Omitted when undefined. Proxmox stores
them URL-encoded, so a change is not detected as drift and is only applied on a fresh clone, on other drift
or with C(pve_vm_force_update).
pve_vm_ci_user:
type: str
default: ""
description:
- >-
Cloud-init user (C(ciuser)). Left out of the update and not compared for drift when empty. Compared with the
live C(ciuser) otherwise.
pve_vm_force_update:
type: bool
default: false
description:
- Push cloud-init settings (user, sshkeys) and the whole configuration even without detected drift.
pve_vm_manage_disk:
type: bool
default: true
description:
- >-
Grow the boot disk to C(pve_vm_disk_size). While true, C(pve_vm_disk_size) must be set; the input validation
asserts it unless C(pve_vm_state) is absent.
pve_vm_disk_size:
type: raw
description:
- >-
Desired boot disk size, for example C(32G). Only the digits are compared with the current size in GB, and the
disk is only ever grown.
pve_vm_boot_disk:
type: str
default: scsi0
description:
- Disk key whose size is read and resized.
pve_vm_reboot_if_required:
type: bool
default: true
description:
- Restart the VM after its boot disk was grown.
pve_vm_api_user:
type: str
default: ""
description:
- >-
Proxmox API user, the bare name without realm (C(@<pve_vm_api_realm>) is appended). Required: the role
asserts it is non-empty before any change.
pve_vm_api_realm:
type: str
default: pam
description:
- Authentication realm of C(pve_vm_api_user), appended as C(@<realm>) in C(module_defaults) and in the REST header.
pve_vm_api_token_id:
type: str
description:
- >-
API token id, without the user part. Role default C(<pve_vm_api_user>-token), a Jinja expression in
C(defaults/main.yml), so it is not repeated here.
pve_vm_api_token_secret:
type: str
no_log: true
description:
- >-
API token secret, normally vaulted. No default. Required: the role asserts it is set and non-empty before
any change. Every task that carries it is C(no_log).
pve_vm_api_host:
type: str
description:
- >-
Address of the Proxmox API (port 8006). Role default the C(ansible_host) of C(pve_vm_node) from hostvars, or
empty when C(pve_vm_node) is undefined; a Jinja expression in C(defaults/main.yml), so it is not repeated
here. Set it explicitly when the node is not an inventory host.
-19
View File
@@ -1,19 +0,0 @@
---
galaxy_info:
role_name: pve_vm
namespace: mortis
author: Defame1297
license: GPL-3.0-or-later
description: Clone, configure, resize, start, stop and delete Proxmox VE QEMU VMs through the Proxmox API, with cloud-init settings and drift detection.
min_ansible_version: "2.22"
platforms:
- name: Ubuntu
versions:
- noble
- resolute
galaxy_tags:
- proxmox
- vm
- cloudinit
- provisioning
dependencies: []
@@ -1,30 +0,0 @@
---
# The validation and the drift detection only: main.yml would also call the Proxmox API to look
# the VM up and fetch its config, which the scenario does not exercise (README, Tests). The fetched
# config is seeded instead, as the fact detect_disk.yml sets from the REST lookup.
- name: Converge
hosts: all
gather_facts: false
tasks:
- name: Validate the inputs
ansible.builtin.include_role:
name: mortis.kamino.pve_vm
tasks_from: validate
vars:
pve_vm_disk_size: 32G
- name: Seed the live VM config the REST lookup would return
ansible.builtin.set_fact:
__pve_vm_config: "{{ pve_vm_test_config }}"
- name: Detect configuration drift
ansible.builtin.include_role:
name: mortis.kamino.pve_vm
tasks_from: detect_drift
- name: Assert the seeded config matches the inputs
ansible.builtin.assert:
that:
- not (__pve_vm_needs_update | bool)
fail_msg: The seeded config, which matches every input, was reported as drift
quiet: true
-107
View File
@@ -1,107 +0,0 @@
---
# 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. The containers stand in for the guest: the role's input
# validation and its drift detection over a seeded VM config run against them. Nothing calls the
# Proxmox API (README, Tests). The containers run systemd as PID 1 with a writable cgroup; no
# privileged mode.
driver:
name: docker
platforms:
- name: ${KAMINO_RUN_ID:-local}-pve-vm-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
- name: ${KAMINO_RUN_ID:-local}-pve-vm-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 the converge, the drift cases and the negative tests in
# verify.yml start from the same valid input, which matches the seeded VM config of converge.yml.
inventory:
group_vars:
all:
pve_vm_node: pve-node
pve_vm_vmid: 9200
# The node is not an inventory host, from which the role defaults the API address;
# argument validation templates that default, so main would fail on it instead.
pve_vm_api_host: 192.0.2.1
pve_vm_api_user: molecule
pve_vm_api_token_secret: not-a-secret
# pve_vm_disk_size is set where a case needs it, so the refusal case can leave it undefined.
pve_vm_state: started
pve_vm_memory: 2048
pve_vm_cores: 2
pve_vm_sockets: 1
pve_vm_ci_user: ubuntu
pve_vm_sshkeys: ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMoleculeTestKeyNotARealKey molecule
pve_vm_network:
net0:
model: virtio
bridge: vmbr0
tag: 20
firewall: true
pve_vm_ipconfig:
ipconfig0: ip=192.0.2.30/24,gw=192.0.2.1
pve_vm_nameservers:
- 192.0.2.53
- 198.51.100.53
# The live config the REST lookup would return, in Proxmox's own forms: agent with flags,
# ipconfig0 tokens reordered, sshkeys URL-encoded, nameservers space-separated.
pve_vm_test_config:
name: "{{ inventory_hostname | lower | replace('_', '-') }}"
cpu: host
memory: 2048
cores: 2
sockets: 1
ciuser: ubuntu
sshkeys: ssh-ed25519%20AAAAC3NzaC1lZDI1NTE5AAAAIMoleculeTestKeyNotARealKey%20molecule%0A
ipconfig0: gw=192.0.2.1,ip=192.0.2.30/24
nameserver: 192.0.2.53 198.51.100.53
onboot: 1
agent: fstrim_cloned_disks=1,enabled=1
net0: virtio=BC:24:11:00:00:01,bridge=vmbr0,firewall=1,tag=20
scsi0: local-lvm:vm-9200-disk-0,size=32G
verifier:
name: ansible
scenario:
# molecule's default sequence minus both destroys (scripts/run_molecule_scenarios.sh removes the
# containers as soon as this scenario ends; after a local run, run `molecule destroy` yourself),
# plus a check before the converge (fresh host) and one after it (converged host).
test_sequence:
- dependency
- cleanup
- syntax
- create
- prepare
- check
- converge
- check
- idempotence
- side_effect
- verify
- cleanup
@@ -1,24 +0,0 @@
---
# One drift case: seeds the live VM config the REST lookup would return, runs the role's drift
# detection with the inputs the caller sets on the include, and asserts each expected drift fact.
# Input: pve_vm_test_case (name, config, expect: a mapping of drift dimension to true or false,
# needs_update for the combined result).
- name: "Seed the live VM config, case {{ pve_vm_test_case.name }}"
ansible.builtin.set_fact:
__pve_vm_config: "{{ pve_vm_test_case.config }}"
- name: "Detect configuration drift, case {{ pve_vm_test_case.name }}"
ansible.builtin.include_role:
name: mortis.kamino.pve_vm
tasks_from: detect_drift
- name: "Assert the drift facts, case {{ pve_vm_test_case.name }}"
ansible.builtin.assert:
that: (lookup('ansible.builtin.vars', pve_vm_test_fact) | bool) == (item.value | bool)
fail_msg: "{{ pve_vm_test_fact }} is {{ lookup('ansible.builtin.vars', pve_vm_test_fact) }}, expected {{ item.value }}"
quiet: true
vars:
pve_vm_test_fact: "{{ '__pve_vm_needs_update' if item.key == 'needs_update' else '__pve_vm_drift_' ~ item.key }}"
loop: "{{ pve_vm_test_case.expect | dict2items }}"
loop_control:
label: "{{ item.key }}"
@@ -1,22 +0,0 @@
---
# 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_vm_test_case (name, tasks_from, expect).
- name: "Run the role, case {{ pve_vm_test_case.name }}"
block:
- name: "Include the role, case {{ pve_vm_test_case.name }}"
ansible.builtin.include_role:
name: mortis.kamino.pve_vm
tasks_from: "{{ pve_vm_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_vm_test_case.name }}"
ansible.builtin.fail:
msg: The role accepted the input
rescue:
- name: "The expected failure stopped the run, case {{ pve_vm_test_case.name }}"
ansible.builtin.assert:
that: pve_vm_test_case.expect in (ansible_failed_result.msg | default(''))
fail_msg: "Expected '{{ pve_vm_test_case.expect }}', got: {{ ansible_failed_result.msg | default('') }}"
quiet: true
@@ -1,15 +0,0 @@
---
# One level of the static check's flattening: moves the pending tasks into pve_vm_test_tasks and
# makes their block, rescue and always lists the next pending ones, then recurses until none is left.
# Both facts are templated from the values before this task.
- name: Flatten one level of blocks
ansible.builtin.set_fact:
pve_vm_test_tasks: "{{ [pve_vm_test_tasks, pve_vm_test_pending] | flatten(levels=1) }}"
pve_vm_test_pending: >-
{{ [pve_vm_test_pending | map(attribute='block', default=[]) | list,
pve_vm_test_pending | map(attribute='rescue', default=[]) | list,
pve_vm_test_pending | map(attribute='always', default=[]) | list] | flatten(levels=2) }}
- name: Flatten the next level
ansible.builtin.include_tasks: flatten_tasks.yml
when: pve_vm_test_pending | length > 0
-323
View File
@@ -1,323 +0,0 @@
---
# The refusal cases run first: each fails in the input validation, before any API call.
- 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_vm_state: running
pve_vm_test_case:
name: state-choice
tasks_from: main
expect: pve_vm_state must be one of
- name: Refuse a run without an API user
ansible.builtin.include_tasks: tasks/failed_run.yml
vars:
pve_vm_api_user: ""
pve_vm_test_case:
name: no-api-user
tasks_from: main
expect: The Proxmox API calls need pve_vm_api_user
- name: Refuse a run without an API token secret
ansible.builtin.include_tasks: tasks/failed_run.yml
vars:
pve_vm_api_token_secret: ""
pve_vm_test_case:
name: no-token-secret
tasks_from: main
expect: The Proxmox API calls need pve_vm_api_user
- name: Refuse a deletion without an API token secret
ansible.builtin.include_tasks: tasks/failed_run.yml
vars:
pve_vm_state: absent
pve_vm_api_token_secret: ""
pve_vm_test_case:
name: absent-no-token-secret
tasks_from: validate
expect: The Proxmox API calls need pve_vm_api_user
- name: Refuse a managed disk without a size
ansible.builtin.include_tasks: tasks/failed_run.yml
vars:
pve_vm_test_case:
name: no-disk-size
tasks_from: validate
expect: pve_vm_disk_size (for example 32G) must be set
- name: Refuse a VM id that is not a number
ansible.builtin.include_tasks: tasks/failed_run.yml
vars:
pve_vm_vmid: not-a-number
pve_vm_test_case:
name: vmid-type
tasks_from: main
expect: pve_vm_vmid
# create.yml is reached only after the API lookup found no VM; its assert precedes the clone.
- name: Refuse a clone without a template id
ansible.builtin.include_tasks: tasks/failed_run.yml
vars:
pve_vm_test_case:
name: no-clone-vmid
tasks_from: create
expect: which needs pve_vm_clone_vmid
- name: Accept valid input
hosts: all
gather_facts: false
tasks:
- name: Accept an unmanaged disk without a size
ansible.builtin.include_role:
name: mortis.kamino.pve_vm
tasks_from: validate
vars:
pve_vm_manage_disk: false
- name: Accept a deletion without a disk size
ansible.builtin.include_role:
name: mortis.kamino.pve_vm
tasks_from: validate
vars:
pve_vm_state: absent
- name: Detect drift on a seeded VM config
hosts: all
gather_facts: false
vars:
pve_vm_test_no_drift:
forced: false
missing_keys: false
name: false
cpu: false
resources: false
ciuser: false
ipconfig: false
nameservers: false
onboot: false
agent: false
network: false
needs_update: false
tasks:
- name: Report no drift when the live config matches
ansible.builtin.include_tasks: tasks/drift_case.yml
vars:
pve_vm_test_case:
name: match
config: "{{ pve_vm_test_config }}"
expect: "{{ pve_vm_test_no_drift }}"
- name: Ignore the live ciuser while pve_vm_ci_user is empty
ansible.builtin.include_tasks: tasks/drift_case.yml
vars:
pve_vm_ci_user: ""
pve_vm_test_case:
name: ciuser-empty
config: "{{ pve_vm_test_config | combine({'ciuser': 'someone-else'}) }}"
expect: "{{ pve_vm_test_no_drift }}"
- name: Ignore a missing live ciuser while pve_vm_ci_user is empty
ansible.builtin.include_tasks: tasks/drift_case.yml
vars:
pve_vm_ci_user: ""
pve_vm_test_case:
name: ciuser-empty-unset
config: "{{ pve_vm_test_config | dict2items | rejectattr('key', 'eq', 'ciuser') | items2dict }}"
expect: "{{ pve_vm_test_no_drift }}"
- name: Report a live ciuser other than pve_vm_ci_user
ansible.builtin.include_tasks: tasks/drift_case.yml
vars:
pve_vm_ci_user: admin
pve_vm_test_case:
name: ciuser-changed
config: "{{ pve_vm_test_config }}"
expect: "{{ pve_vm_test_no_drift | combine({'ciuser': true, 'needs_update': true}) }}"
- name: Report a live config without ciuser
ansible.builtin.include_tasks: tasks/drift_case.yml
vars:
pve_vm_test_case:
name: ciuser-missing
config: "{{ pve_vm_test_config | dict2items | rejectattr('key', 'eq', 'ciuser') | items2dict }}"
expect: "{{ pve_vm_test_no_drift | combine({'missing_keys': true, 'ciuser': true, 'needs_update': true}) }}"
- name: Report a live config without sshkeys
ansible.builtin.include_tasks: tasks/drift_case.yml
vars:
pve_vm_test_case:
name: sshkeys-missing
config: "{{ pve_vm_test_config | dict2items | rejectattr('key', 'eq', 'sshkeys') | items2dict }}"
expect: "{{ pve_vm_test_no_drift | combine({'missing_keys': true, 'needs_update': true}) }}"
# Proxmox stores sshkeys URL-encoded, so a rotated key is not drift; pve_vm_force_update pushes it.
- name: Report no drift for rotated sshkeys
ansible.builtin.include_tasks: tasks/drift_case.yml
vars:
pve_vm_sshkeys: ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIRotatedTestKeyNotARealKey molecule
pve_vm_test_case:
name: sshkeys-rotated
config: "{{ pve_vm_test_config }}"
expect: "{{ pve_vm_test_no_drift }}"
- name: Expect no sshkeys in the live config while pve_vm_sshkeys is empty
ansible.builtin.include_tasks: tasks/drift_case.yml
vars:
pve_vm_sshkeys: ""
pve_vm_test_case:
name: sshkeys-empty
config: "{{ pve_vm_test_config | dict2items | rejectattr('key', 'eq', 'sshkeys') | items2dict }}"
expect: "{{ pve_vm_test_no_drift }}"
- name: Report forced drift with pve_vm_force_update
ansible.builtin.include_tasks: tasks/drift_case.yml
vars:
pve_vm_force_update: true
pve_vm_test_case:
name: forced
config: "{{ pve_vm_test_config }}"
expect: "{{ pve_vm_test_no_drift | combine({'forced': true, 'needs_update': true}) }}"
- name: Read Proxmox's other forms as no drift
ansible.builtin.include_tasks: tasks/drift_case.yml
vars:
pve_vm_nameservers: 192.0.2.53,198.51.100.53
pve_vm_test_case:
name: other-forms
config: "{{ pve_vm_test_config | combine({'cpu': 'cputype=host,flags=+aes', 'agent': '1'}) }}"
expect: "{{ pve_vm_test_no_drift }}"
- name: Report drift in each compared dimension
ansible.builtin.include_tasks: tasks/drift_case.yml
vars:
pve_vm_test_case:
name: all-dimensions
config: >-
{{ pve_vm_test_config | combine({'name': 'other-name', 'cpu': 'kvm64', 'memory': 1024,
'ipconfig0': 'ip=192.0.2.31/24,gw=192.0.2.1', 'nameserver': '192.0.2.53', 'onboot': 0,
'agent': 'enabled=0', 'net0': 'virtio=BC:24:11:00:00:01,bridge=vmbr1,tag=20'}) }}
expect:
forced: false
missing_keys: false
name: true
cpu: true
resources: true
ciuser: false
ipconfig: true
nameservers: true
onboot: true
agent: true
network: true
needs_update: true
- name: Report a live VLAN tag that the inputs drop
ansible.builtin.include_tasks: tasks/drift_case.yml
vars:
pve_vm_network:
net0:
model: virtio
bridge: vmbr0
firewall: true
pve_vm_test_case:
name: tag-dropped
config: "{{ pve_vm_test_config }}"
expect: "{{ pve_vm_test_no_drift | combine({'network': true, 'needs_update': true}) }}"
# Static: the role must never send a cloud-init password, and its delete of a stored one must not
# log the task, so these read the role's own task files on the controller.
- name: Verify the role's cloud-init password handling
hosts: localhost
gather_facts: false
vars:
pve_vm_test_task_dir: "{{ (playbook_dir ~ '/../../tasks') | realpath }}"
# Every name a task can call the module by.
pve_vm_test_kvm_names:
- community.proxmox.proxmox_kvm
- community.general.proxmox_kvm
- ansible.legacy.proxmox_kvm
- proxmox_kvm
tasks:
- name: Find the role's task files, subdirectories included
ansible.builtin.find:
paths: "{{ pve_vm_test_task_dir }}"
patterns: ["*.yml", "*.yaml"]
recurse: true
register: pve_vm_test_files
- name: Read the role's task files
ansible.builtin.set_fact:
pve_vm_test_pending: >-
{{ [pve_vm_test_pending | default([]),
lookup('ansible.builtin.file', item) | from_yaml] | flatten(levels=1) }}
loop: "{{ pve_vm_test_files.files | map(attribute='path') | sort }}"
- name: Start the flattened task list
ansible.builtin.set_fact:
pve_vm_test_tasks: []
# Recurses through block, rescue and always to any depth.
- name: Flatten the blocks
ansible.builtin.include_tasks: tasks/flatten_tasks.yml
# A task calls the module by its key, or through action or local_action, either a mapping
# with module or a string that starts with the module name. Its args are merged in.
- name: Summarise each proxmox_kvm task
ansible.builtin.set_fact:
pve_vm_test_kvm: >-
{{ pve_vm_test_kvm | default([]) + [{
'name': item.name | default('(unnamed)'),
'sends': ('cipassword' in pve_vm_test_args)
or (pve_vm_test_raw is string and 'cipassword=' in pve_vm_test_raw),
'deletes': ('cipassword' in (pve_vm_test_args.delete | default('') | string).split(','))
or (pve_vm_test_raw is string and pve_vm_test_raw is search('delete=\\S*cipassword')),
'no_log': item.no_log | default(false) | bool,
}] }}
vars:
pve_vm_test_key: "{{ pve_vm_test_kvm_names | select('in', item) | first | default('') }}"
pve_vm_test_action: "{{ item.action | default(item.local_action | default('')) }}"
pve_vm_test_action_kvm: >-
{{ (pve_vm_test_action is mapping and pve_vm_test_action.module | default('') in pve_vm_test_kvm_names)
or (pve_vm_test_action is string and (pve_vm_test_action.split() | first | default('')) in pve_vm_test_kvm_names) }}
pve_vm_test_raw: >-
{{ item[pve_vm_test_key] if pve_vm_test_key
else (pve_vm_test_action | dict2items | rejectattr('key', 'eq', 'module') | items2dict
if pve_vm_test_action is mapping else pve_vm_test_action) }}
pve_vm_test_args: >-
{{ (pve_vm_test_raw if pve_vm_test_raw is mapping else {}) | combine(item.args | default({})) }}
loop: "{{ pve_vm_test_tasks }}"
loop_control:
label: "{{ item.name | default('(unnamed)') }}"
when: pve_vm_test_key | length > 0 or pve_vm_test_action_kvm | bool
- name: Assert no proxmox_kvm task sends cipassword
ansible.builtin.assert:
that:
- pve_vm_test_kvm | default([]) | length > 0
- pve_vm_test_kvm | selectattr('sends') | list | length == 0
fail_msg: "proxmox_kvm tasks sending cipassword: {{ pve_vm_test_kvm | default([]) | selectattr('sends') | map(attribute='name') | list }}"
quiet: true
# Any module, any spelling or group: no default the role sets may carry cipassword.
- name: Assert no module_defaults sets cipassword
ansible.builtin.assert:
that:
- >-
[item.module_defaults] | flatten(levels=1) | map('dict2items') | flatten(levels=1)
| map(attribute='value') | select('contains', 'cipassword') | list | length == 0
fail_msg: "module_defaults with cipassword on '{{ item.name | default('(unnamed)') }}'"
quiet: true
loop: "{{ pve_vm_test_tasks | selectattr('module_defaults', 'defined') | list }}"
loop_control:
label: "{{ item.name | default('(unnamed)') }}"
- name: Assert the stored cipassword is deleted by one no_log task
ansible.builtin.assert:
that:
- pve_vm_test_kvm | selectattr('deletes') | list | length == 1
- pve_vm_test_kvm | selectattr('deletes') | selectattr('no_log') | list | length == 1
fail_msg: "Tasks deleting cipassword: {{ pve_vm_test_kvm | selectattr('deletes') | list }}"
quiet: true
-29
View File
@@ -1,29 +0,0 @@
---
# Here, not in validate.yml: whether a clone happens is known only after the API lookup.
- name: Assert the template to clone is set
ansible.builtin.assert:
that:
- pve_vm_clone_vmid is defined
fail_msg: >-
VM {{ pve_vm_vmid }} does not exist on {{ pve_vm_node }}, so it is cloned, which needs
pve_vm_clone_vmid, the VM id of the template. Set it, or create the VM by other means.
quiet: true
- name: Clone VM from template
no_log: true # carries the API token secret
delegate_to: "{{ pve_vm_delegate }}"
community.proxmox.proxmox_kvm:
node: "{{ pve_vm_node }}"
clone: template
vmid: "{{ pve_vm_clone_vmid }}"
newid: "{{ pve_vm_vmid }}"
name: "{{ inventory_hostname | lower | replace('_', '-') }}"
full: "{{ pve_vm_full_clone }}"
timeout: 600
state: present
register: __pve_vm_clone
- name: Record that the VM was just cloned
ansible.builtin.set_fact:
# Forces one cloud-init update (ciuser, sshkeys) in update.yml.
__pve_vm_created: "{{ __pve_vm_clone is changed }}"
-23
View File
@@ -1,23 +0,0 @@
---
- name: Stop VM before deletion (if running)
no_log: true # defence in depth: the module already masks the API token secret
delegate_to: "{{ pve_vm_delegate }}"
community.proxmox.proxmox_kvm:
node: "{{ pve_vm_node }}"
vmid: "{{ pve_vm_vmid }}"
state: stopped
when:
- pve_vm_exists
- not ansible_check_mode
- name: Delete VM
no_log: true # defence in depth: the module already masks the API token secret
delegate_to: "{{ pve_vm_delegate }}"
community.proxmox.proxmox_kvm:
node: "{{ pve_vm_node }}"
vmid: "{{ pve_vm_vmid }}"
state: absent
when:
- pve_vm_exists
- not ansible_check_mode
register: __pve_vm_delete
-37
View File
@@ -1,37 +0,0 @@
---
# no_log hides the whole failure of the lookup below, so the operator would only see "output hidden
# due to no_log". The rescue re-raises just the module's msg, which is safe to show: the module
# masks the token secret in everything it returns (its invocation echo is not used here).
- name: Look up the VM
block:
- name: Check if VM exists
no_log: true # defence in depth: the module already masks the API token secret
delegate_to: "{{ pve_vm_delegate }}"
community.proxmox.proxmox_kvm:
node: "{{ pve_vm_node }}"
vmid: "{{ pve_vm_vmid }}"
state: current
register: __pve_vm_info
# proxmox_kvm declares no check mode support, so --check would skip this lookup, leave
# pve_vm_exists false and skip everything after it. state=current only reads (GET of the VM
# and its status), so it runs for real under --check as well.
check_mode: false
# An absent VM is an expected answer here: for state=current the module fails with
# "VM with vmid <id> does not exist in cluster". Any other failure (API, auth, network) is
# real and must stop the run instead of being read as "VM absent", which would send
# create.yml after an existing VM.
failed_when:
- __pve_vm_info.failed | default(false)
- "'does not exist in cluster' not in (__pve_vm_info.msg | default(''))"
changed_when: false
rescue:
- name: Fail with the module message
ansible.builtin.fail:
msg: >-
Looking up VM {{ pve_vm_vmid }} on {{ pve_vm_node }} failed:
{{ ansible_failed_result.msg | default('no message') }}
- name: Set VM existence fact
ansible.builtin.set_fact:
pve_vm_exists: >-
{{ __pve_vm_info.vmid is defined or __pve_vm_info.status is defined }}
-47
View File
@@ -1,47 +0,0 @@
---
- name: Get current VM config via REST API
no_log: true # Authorization header carries the API token
delegate_to: localhost
ansible.builtin.uri:
url: "https://{{ pve_vm_api_host }}:8006/api2/json/nodes/{{ pve_vm_node }}/qemu/{{ pve_vm_vmid }}/config"
method: GET
headers:
Authorization: "{{ __pve_vm_api_auth_header }}"
register: __pve_vm_current_config
# uri has no check mode support; this is a GET, so it also runs under --check and drift
# detection sees the live config.
check_mode: false
- name: Set fact to the actual config dict
no_log: true # the config may hold a stored cipassword (update.yml deletes it)
ansible.builtin.set_fact:
__pve_vm_config: "{{ __pve_vm_current_config.json.data }}"
- name: Extract current disk string
ansible.builtin.set_fact:
__pve_vm_disk_string: "{{ __pve_vm_config[pve_vm_boot_disk] | default('') }}"
- name: Extract current disk number and unit properly
ansible.builtin.set_fact:
__pve_vm_disk_parts: "{{ __pve_vm_disk_string | regex_findall('size=(\\d+)([GM])') | first | default(['0', 'G']) | list }}"
- name: Extract current disk number
ansible.builtin.set_fact:
__pve_vm_current_disk_size_number: "{{ __pve_vm_disk_parts[0] | int }}"
__pve_vm_current_disk_size_unit: "{{ __pve_vm_disk_parts[1] }}"
- name: Convert disk size to GB
ansible.builtin.set_fact:
__pve_vm_current_disk: >-
{{
__pve_vm_current_disk_size_number if __pve_vm_current_disk_size_unit == 'G'
else (__pve_vm_current_disk_size_number / 1024)
}}
- name: Determine if disk resize is needed
ansible.builtin.set_fact:
__pve_vm_resize_disk: "{{ pve_vm_disk_size | regex_replace('[^0-9]', '') | int > __pve_vm_current_disk | int }}"
when:
- pve_vm_manage_disk | bool
- pve_vm_disk_size is defined
- pve_vm_exists
-97
View File
@@ -1,97 +0,0 @@
---
# community.proxmox.proxmox_kvm with `update: true` reports changed on every run: it does not diff
# against the live config. Compare the config already fetched in detect_disk.yml with the desired
# values and only call the module on real drift or while cloud-init is still unconfigured (first
# run after a clone, when ciuser and sshkeys have to be applied once). Proxmox stores sshkeys
# URL-encoded, so a change is not diffed: pve_vm_force_update pushes it to an existing VM.
- name: Normalise current QEMU guest agent setting
ansible.builtin.set_fact:
# PVE returns "1", "enabled=1" or e.g. "fstrim_cloned_disks=1,enabled=1"; enabled=1 may sit
# in any position.
__pve_vm_agent_current: >-
{{
'1' if ((__pve_vm_config.agent | default('0') | string).split(',')
| select('in', ['1', 'enabled=1']) | list | length > 0)
else '0'
}}
- name: Normalise desired and current values for drift comparison
ansible.builtin.set_fact:
# ciuser and sshkeys are only expected in the current config when the role sets them.
__pve_vm_required_config_keys: >-
{{
(['ciuser'] if (pve_vm_ci_user | string | length > 0) else [])
+ (['sshkeys'] if (pve_vm_sshkeys | default('') | string | length > 0) else [])
}}
# PVE returns nameserver space-separated; accept a list or a comma-separated string as well.
__pve_vm_nameservers_desired: >-
{{
((pve_vm_nameservers | join(' '))
if (pve_vm_nameservers | default('') is not string and pve_vm_nameservers | default('') is iterable)
else (pve_vm_nameservers | default('') | string))
| replace(',', ' ') | split | join(' ')
}}
# ipconfig0 tokens can come back from PVE in a different order.
__pve_vm_ipconfig0_current: "{{ (__pve_vm_config.ipconfig0 | default('') | string).split(',') | sort }}"
__pve_vm_ipconfig0_desired: "{{ (pve_vm_ipconfig.ipconfig0 | default('') | string).split(',') | sort }}"
__pve_vm_net0_current: "{{ (__pve_vm_config.net0 | default('') | string).split(',') }}"
# autostart is not compared: PVE has no such VM config key (the config API does not return it).
# One fact per drift dimension, combined in __pve_vm_needs_update below.
- name: Determine drift per configuration dimension
ansible.builtin.set_fact:
__pve_vm_drift_forced: >-
{{
(pve_vm_force_update | bool)
or (__pve_vm_created | default(false) | bool)
}}
__pve_vm_drift_missing_keys: "{{ __pve_vm_required_config_keys | reject('in', __pve_vm_config) | list | length > 0 }}"
__pve_vm_drift_name: "{{ (__pve_vm_config.name | default('')) != (inventory_hostname | lower | replace('_', '-')) }}"
# PVE may return "host" or "cputype=host" (optionally followed by flags).
__pve_vm_drift_cpu: >-
{{
(__pve_vm_config.cpu | default('') | string).split(',')[0] | regex_replace('^cputype=', '') != 'host'
}}
__pve_vm_drift_resources: >-
{{
(pve_vm_memory is defined and (__pve_vm_config.memory | default(0) | int) != (pve_vm_memory | int))
or (pve_vm_cores is defined and (__pve_vm_config.cores | default(1) | int) != (pve_vm_cores | int))
or (pve_vm_sockets is defined and (__pve_vm_config.sockets | default(1) | int) != (pve_vm_sockets | int))
}}
__pve_vm_drift_ciuser: "{{ (pve_vm_ci_user | string | length > 0) and __pve_vm_config.ciuser | default('') != pve_vm_ci_user }}"
__pve_vm_drift_ipconfig: "{{ pve_vm_ipconfig.ipconfig0 is defined and __pve_vm_ipconfig0_current != __pve_vm_ipconfig0_desired }}"
__pve_vm_drift_nameservers: >-
{{ pve_vm_nameservers is defined and (__pve_vm_config.nameserver | default('')) != __pve_vm_nameservers_desired }}
__pve_vm_drift_onboot: "{{ (__pve_vm_config.onboot | default(0) | int) != (pve_vm_onboot | bool | int) }}"
__pve_vm_drift_agent: "{{ __pve_vm_agent_current != ((pve_vm_agent | bool | int) | string) }}"
__pve_vm_drift_network: >-
{{
pve_vm_network.net0 is defined and (
not (__pve_vm_config.net0 | default('')).startswith(pve_vm_network.net0.model | default('virtio') ~ '=')
or (pve_vm_network.net0.bridge is defined
and ('bridge=' ~ pve_vm_network.net0.bridge) not in __pve_vm_net0_current)
or (pve_vm_network.net0.tag is defined
and ('tag=' ~ pve_vm_network.net0.tag) not in __pve_vm_net0_current)
or (pve_vm_network.net0.tag is not defined
and (__pve_vm_net0_current | select('match', '^tag=') | list | length > 0))
or (pve_vm_network.net0.firewall is defined
and (('firewall=1' in __pve_vm_net0_current) != (pve_vm_network.net0.firewall | bool)))
)
}}
- name: Determine if VM configuration needs updating
ansible.builtin.set_fact:
__pve_vm_needs_update: >-
{{
__pve_vm_drift_forced | bool
or __pve_vm_drift_missing_keys | bool
or __pve_vm_drift_name | bool
or __pve_vm_drift_cpu | bool
or __pve_vm_drift_resources | bool
or __pve_vm_drift_ciuser | bool
or __pve_vm_drift_ipconfig | bool
or __pve_vm_drift_nameservers | bool
or __pve_vm_drift_onboot | bool
or __pve_vm_drift_agent | bool
or __pve_vm_drift_network | bool
}}
-90
View File
@@ -1,90 +0,0 @@
---
# 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
# Every Proxmox API call of the role is inside this block, so the credentials are set once here
# instead of on each task; module_defaults set on a block reach tasks run through include_tasks.
# They are templated per task and no secret is stored as a fact. The uri call (detect_disk) takes
# host and header explicitly.
- name: Manage Proxmox VM lifecycle
module_defaults:
community.proxmox.proxmox_kvm:
api_user: "{{ pve_vm_api_user }}@{{ pve_vm_api_realm }}"
api_token_id: "{{ pve_vm_api_token_id }}"
api_token_secret: "{{ pve_vm_api_token_secret }}"
api_host: "{{ pve_vm_api_host }}"
validate_certs: false
community.proxmox.proxmox_disk:
api_user: "{{ pve_vm_api_user }}@{{ pve_vm_api_realm }}"
api_token_id: "{{ pve_vm_api_token_id }}"
api_token_secret: "{{ pve_vm_api_token_secret }}"
api_host: "{{ pve_vm_api_host }}"
validate_certs: false
ansible.builtin.uri:
validate_certs: false
block:
- name: Gather current VM information
ansible.builtin.include_tasks: detect.yml
- name: Remove VM if destruction is requested
ansible.builtin.include_tasks: delete.yml
when:
- pve_vm_state == "absent"
- pve_vm_allow_destroy | bool
- pve_vm_exists
- name: Stop processing for deleted VM
ansible.builtin.meta: end_host
when:
- pve_vm_state == "absent"
- pve_vm_allow_destroy | bool
- name: Create VM if it does not exist
ansible.builtin.include_tasks: create.yml
when:
- pve_vm_state != "absent"
- not pve_vm_exists
- not ansible_check_mode
- name: Preview VM creation
ansible.builtin.debug:
msg: >-
VM {{ pve_vm_vmid }} does not exist on {{ pve_vm_node }}: a real run clones it from template
{{ pve_vm_clone_vmid | default('(unset)') }} and then configures it. Nothing after the lookup runs for it
in this check.
changed_when: true
when:
- pve_vm_state != "absent"
- not pve_vm_exists
- ansible_check_mode
- name: Refresh VM information after changes
ansible.builtin.include_tasks: detect.yml
- name: Gather current VM disk information
ansible.builtin.include_tasks: detect_disk.yml
when:
- pve_vm_exists
- pve_vm_state != "absent"
- name: Update existing VM configuration
ansible.builtin.include_tasks: update.yml
when:
- pve_vm_state != "absent"
- pve_vm_exists
- name: Ensure VM power state
ansible.builtin.include_tasks: state.yml
when:
- pve_vm_exists
- pve_vm_state in ["started", "stopped"]
- name: Wait for VM to become ready
ansible.builtin.include_tasks: wait.yml
when:
- pve_vm_exists
- pve_vm_state == "started"
- pve_vm_wait_for_guest | bool
-18
View File
@@ -1,18 +0,0 @@
---
# Under --check the module (no check mode support) does not run; the preview compares the status the
# lookup in detect.yml read with the desired state.
- name: Preview VM power state
ansible.builtin.debug:
msg: "VM {{ pve_vm_vmid }} is {{ __pve_vm_info.status | default('unknown') }}, desired {{ pve_vm_state }}"
changed_when: >-
(__pve_vm_info.status | default('unknown')) != ('running' if pve_vm_state == 'started' else 'stopped')
when: ansible_check_mode
- name: Ensure VM state
no_log: true # defence in depth: the module already masks the API token secret
delegate_to: "{{ pve_vm_delegate }}"
community.proxmox.proxmox_kvm:
node: "{{ pve_vm_node }}"
vmid: "{{ pve_vm_vmid }}"
state: "{{ pve_vm_state }}"
when: not ansible_check_mode
-126
View File
@@ -1,126 +0,0 @@
---
- name: Detect VM configuration drift
ansible.builtin.include_tasks: detect_drift.yml
# Names only, no values: the drift facts are booleans, and sshkeys are never compared.
# Under --check this is the preview of the update and resize below (changed when either would run).
- name: Report configuration drift
ansible.builtin.debug:
msg: >-
{{
'drift: ' ~ (__pve_vm_drift_dimensions | join(', ')) if __pve_vm_drift_dimensions | length > 0
else 'no drift'
}}{{
'; boot disk resize: ' ~ __pve_vm_current_disk ~ 'G -> ' ~ pve_vm_disk_size
if (pve_vm_manage_disk and __pve_vm_resize_disk | default(false) | bool) else ''
}}
vars:
__pve_vm_drift_dimensions: >-
{{
[
'forced' if __pve_vm_drift_forced | bool else '',
'missing_keys' if __pve_vm_drift_missing_keys | bool else '',
'name' if __pve_vm_drift_name | bool else '',
'cpu' if __pve_vm_drift_cpu | bool else '',
'resources' if __pve_vm_drift_resources | bool else '',
'ciuser' if __pve_vm_drift_ciuser | bool else '',
'ipconfig' if __pve_vm_drift_ipconfig | bool else '',
'nameservers' if __pve_vm_drift_nameservers | bool else '',
'onboot' if __pve_vm_drift_onboot | bool else '',
'agent' if __pve_vm_drift_agent | bool else '',
'network' if __pve_vm_drift_network | bool else '',
] | select | list
}}
changed_when: >-
ansible_check_mode and (__pve_vm_needs_update | bool
or (pve_vm_manage_disk and __pve_vm_resize_disk | default(false) | bool))
- name: Update VM configuration
no_log: true # carries the API token secret
delegate_to: "{{ pve_vm_delegate }}"
community.proxmox.proxmox_kvm:
node: "{{ pve_vm_node }}"
vmid: "{{ pve_vm_vmid }}"
name: "{{ inventory_hostname | lower | replace('_', '-') }}"
memory: "{{ pve_vm_memory | default(omit) }}"
cores: "{{ pve_vm_cores | default(omit) }}"
sockets: "{{ pve_vm_sockets | default(omit) }}"
cpu: host
net: "{{ pve_vm_network | default(omit) }}"
ciuser: "{{ pve_vm_ci_user if (pve_vm_ci_user | length > 0) else omit }}"
ipconfig: "{{ pve_vm_ipconfig | default(omit) }}"
sshkeys: "{{ pve_vm_sshkeys | default(omit) }}"
nameservers: "{{ pve_vm_nameservers | default(omit) }}"
agent: "{{ pve_vm_agent }}"
onboot: "{{ pve_vm_onboot }}"
autostart: "{{ pve_vm_autostart }}"
update: true
state: present
# Explicit: the module has no check mode support, so --check skips it anyway; the report above is the preview.
when:
- __pve_vm_needs_update | bool
- not ansible_check_mode
# The role never sets a cloud-init password; a VM configured by other means may still have one
# stored. The module cannot combine delete with update, has no check mode and always reports
# changed, hence a separate task, run only when the key is present, with the debug as its --check
# preview.
- name: Preview deletion of the stored cloud-init password
ansible.builtin.debug:
msg: "cipassword stored on VM {{ pve_vm_vmid }}: a real run deletes it"
changed_when: true
when:
- "'cipassword' in __pve_vm_config"
- ansible_check_mode
- name: Delete the stored cloud-init password
no_log: true # carries the API token secret
delegate_to: "{{ pve_vm_delegate }}"
community.proxmox.proxmox_kvm:
node: "{{ pve_vm_node }}"
vmid: "{{ pve_vm_vmid }}"
delete: cipassword
when:
- "'cipassword' in __pve_vm_config"
- not ansible_check_mode
# The marker has been consumed by drift detection and the update above; reset it so another
# pve_vm run for this host in the same play does not force a second update.
- name: Clear the just-cloned marker
ansible.builtin.set_fact:
__pve_vm_created: false
- name: Resize boot drive
no_log: true # defence in depth: the module already masks the API token secret
delegate_to: "{{ pve_vm_delegate }}"
community.proxmox.proxmox_disk:
vmid: "{{ pve_vm_vmid }}"
disk: "{{ pve_vm_boot_disk }}"
size: "{{ pve_vm_disk_size }}"
state: resized
when:
- pve_vm_manage_disk | bool
- __pve_vm_resize_disk
- not ansible_check_mode
register: __pve_vm_disk_resize
- name: Track disk resize result
ansible.builtin.set_fact:
__pve_vm_disk_resized: "{{ __pve_vm_disk_resize.changed | default(false) }}"
- name: Restart VM if disk was resized
no_log: true # defence in depth: the module already masks the API token secret
delegate_to: "{{ pve_vm_delegate }}"
community.proxmox.proxmox_kvm:
node: "{{ pve_vm_node }}"
vmid: "{{ pve_vm_vmid }}"
state: restarted
when:
- __pve_vm_disk_resized
- pve_vm_reboot_if_required | bool
- not ansible_check_mode
-28
View File
@@ -1,28 +0,0 @@
---
# 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.
# Every run calls the API: even pve_vm_state absent without pve_vm_allow_destroy looks the VM up.
- name: Assert the Proxmox API credentials are set
ansible.builtin.assert:
that:
- pve_vm_api_user | length > 0
- pve_vm_api_token_secret is defined and pve_vm_api_token_secret | length > 0
fail_msg: >-
The Proxmox API calls need pve_vm_api_user (bare user name, the role appends
@<pve_vm_api_realm>) and pve_vm_api_token_secret (normally vaulted). Neither has a usable
default: set them in the inventory.
quiet: true
# The update reads the resize flag, which is only computed while pve_vm_disk_size is defined.
- name: Assert the boot disk size is set while the disk is managed
ansible.builtin.assert:
that:
- pve_vm_disk_size is defined
fail_msg: >-
pve_vm_disk_size (for example 32G) must be set while pve_vm_manage_disk is true, the default.
Set pve_vm_manage_disk to false to leave the boot disk alone.
quiet: true
when:
- pve_vm_manage_disk | bool
- pve_vm_state != "absent"
-16
View File
@@ -1,16 +0,0 @@
---
- name: Wait for SSH to become available
delegate_to: localhost
ansible.builtin.wait_for:
host: "{{ ansible_host }}"
port: 22
timeout: 3600
# Runs on the guest itself, over the connection the play uses for it.
- name: Wait for cloud-init to finish
ansible.builtin.command: cloud-init status --wait
register: __pve_vm_cloudinit_status
retries: 10
delay: 15
until: __pve_vm_cloudinit_status.rc == 0
changed_when: false
-4
View File
@@ -1,4 +0,0 @@
---
# Authorization header of the ansible.builtin.uri call in detect_disk.yml, derived from the
# pve_vm_api_* inputs.
__pve_vm_api_auth_header: "PVEAPIToken={{ pve_vm_api_user }}@{{ pve_vm_api_realm }}!{{ pve_vm_api_token_id }}={{ pve_vm_api_token_secret }}"
+2 -2
View File
@@ -61,8 +61,8 @@ The role defines none.
The scenario `molecule/default/` runs in CI only, on two platforms: `${MOLECULE_IMAGE}` (Ubuntu 24.04) and `${MOLECULE_IMAGE_2604}` (Ubuntu 26.04). Both images ship openssh-server. It runs `check` before the converge (a fresh host) and after it (a configured host).
- Converge applies the `ubuntu_lxc` profile. Verify first loads the defaults on the controller through `tasks_from: validate.yml`: 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 then 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.
- Converge applies the `ubuntu_lxc` profile. It then loads the defaults through `tasks_from: validate.yml` without changing the host: every profile (`pve`, `ubuntu_lxc`, `ubuntu_vm`) passes validation and keeps its root login policy and key algorithms, a consumer `sshd_settings` override wins over the profile, and the `pve` guard accepts each value that allows root key login.
- Verify first checks the refusals: a run without `sshd_profile`, `PubkeyAuthentication no` (lock-out), a `pve` profile with `PermitRootLogin no` or `forced-commands-only`, a `pve` profile without `rsa-sha2-512`, SHA-1 `ssh-rsa`, and an unknown profile. Each but the missing profile is matched on its message.
- Verify then checks the converged host: the drop-in exists, `sshd -t` passes, the `ssh` unit is active, and `sshd -T` shows key login on and password and root login off.
- The `pve` profile is checked by rendering its drop-in to a scratch file and parsing it with `sshd -T -f`: root logs in with keys only and passwords stay off.
+70
View File
@@ -7,3 +7,73 @@
ansible_user: root
roles:
- role: mortis.kamino.sshd
# The plays below only load the role's defaults and run validate.yml, which changes nothing
# on the container. They cover the profiles the converge above cannot run and the values
# the guards accept.
- name: Every profile passes validation and keeps its root login policy
hosts: all
gather_facts: false
tasks:
- name: Validate each profile
ansible.builtin.include_role:
name: mortis.kamino.sshd
tasks_from: validate.yml
public: true
vars:
sshd_profile: "{{ item }}"
loop: [pve, ubuntu_lxc, ubuntu_vm]
- name: Assert the profile data
ansible.builtin.assert:
that:
- sshd_profiles.pve.PermitRootLogin == "prohibit-password"
- sshd_profiles.ubuntu_lxc.PermitRootLogin == "no"
- sshd_profiles.ubuntu_vm.PermitRootLogin == "no"
quiet: true
# Proxmox cluster SSH needs RSA with SHA-2, never SHA-1 ssh-rsa; the others stay ed25519 only.
- name: Assert the key algorithms per profile
ansible.builtin.assert:
that:
- sshd_profiles.pve.HostKeyAlgorithms == "ssh-ed25519,rsa-sha2-512,rsa-sha2-256"
- sshd_profiles.pve.PubkeyAcceptedAlgorithms == "ssh-ed25519,rsa-sha2-512,rsa-sha2-256"
- sshd_settings_defaults.HostKeyAlgorithms == "ssh-ed25519"
- sshd_settings_defaults.PubkeyAcceptedAlgorithms == "ssh-ed25519"
- "'HostKeyAlgorithms' not in sshd_profiles.ubuntu_lxc"
- "'HostKeyAlgorithms' not in sshd_profiles.ubuntu_vm"
quiet: true
# Play vars outrank the role defaults, so the override reaches the merged settings.
- name: A consumer override wins and keeps the rest
hosts: all
gather_facts: false
vars:
sshd_profile: ubuntu_vm
sshd_settings:
MaxAuthTries: "5"
tasks:
- name: Load the role defaults
ansible.builtin.include_role:
name: mortis.kamino.sshd
tasks_from: validate.yml
public: true
- name: Assert the override
ansible.builtin.assert:
that:
- sshd_settings_effective.MaxAuthTries == "5"
- sshd_settings_effective.PermitRootLogin == "no"
- sshd_settings_effective.PubkeyAuthentication == "yes"
quiet: true
- name: The Proxmox guard accepts every value that allows root key login
hosts: all
gather_facts: false
tasks:
- name: Validate the pve profile with each accepted value
ansible.builtin.include_role:
name: mortis.kamino.sshd
tasks_from: validate.yml
vars:
sshd_profile: pve
sshd_settings:
PermitRootLogin: "{{ item }}"
loop: [prohibit-password, without-password, "yes", Prohibit-Password]
+1 -78
View File
@@ -1,83 +1,6 @@
---
# The plays below only load the role's defaults and run validate.yml, which needs no container,
# so they run once, on the controller, in check mode so that a regressed guard cannot change it.
# They cover the profiles converge.yml cannot run and the values the guards accept.
- name: Every profile passes validation and keeps its root login policy
hosts: localhost
connection: local
check_mode: true
gather_facts: false
tasks:
- name: Validate each profile
ansible.builtin.include_role:
name: mortis.kamino.sshd
tasks_from: validate.yml
public: true
vars:
sshd_profile: "{{ item }}"
loop: [pve, ubuntu_lxc, ubuntu_vm]
- name: Assert the profile data
ansible.builtin.assert:
that:
- sshd_profiles.pve.PermitRootLogin == "prohibit-password"
- sshd_profiles.ubuntu_lxc.PermitRootLogin == "no"
- sshd_profiles.ubuntu_vm.PermitRootLogin == "no"
quiet: true
# Proxmox cluster SSH needs RSA with SHA-2, never SHA-1 ssh-rsa; the others stay ed25519 only.
- name: Assert the key algorithms per profile
ansible.builtin.assert:
that:
- sshd_profiles.pve.HostKeyAlgorithms == "ssh-ed25519,rsa-sha2-512,rsa-sha2-256"
- sshd_profiles.pve.PubkeyAcceptedAlgorithms == "ssh-ed25519,rsa-sha2-512,rsa-sha2-256"
- sshd_settings_defaults.HostKeyAlgorithms == "ssh-ed25519"
- sshd_settings_defaults.PubkeyAcceptedAlgorithms == "ssh-ed25519"
- "'HostKeyAlgorithms' not in sshd_profiles.ubuntu_lxc"
- "'HostKeyAlgorithms' not in sshd_profiles.ubuntu_vm"
quiet: true
# Play vars outrank the role defaults, so the override reaches the merged settings.
- name: A consumer override wins and keeps the rest
hosts: localhost
connection: local
check_mode: true
gather_facts: false
vars:
sshd_profile: ubuntu_vm
sshd_settings:
MaxAuthTries: "5"
tasks:
- name: Load the role defaults
ansible.builtin.include_role:
name: mortis.kamino.sshd
tasks_from: validate.yml
public: true
- name: Assert the override
ansible.builtin.assert:
that:
- sshd_settings_effective.MaxAuthTries == "5"
- sshd_settings_effective.PermitRootLogin == "no"
- sshd_settings_effective.PubkeyAuthentication == "yes"
quiet: true
- name: The Proxmox guard accepts every value that allows root key login
hosts: localhost
connection: local
check_mode: true
gather_facts: false
tasks:
- name: Validate the pve profile with each accepted value
ansible.builtin.include_role:
name: mortis.kamino.sshd
tasks_from: validate.yml
vars:
sshd_profile: pve
sshd_settings:
PermitRootLogin: "{{ item }}"
loop: [prohibit-password, without-password, "yes", Prohibit-Password]
# The refusal cases: here, not in converge.yml, because idempotence reruns converge. Each
# fails in validate.yml; they run before the host checks, so the assertions below also show the
# host unchanged.
# fails in validate.yml; they run first, so the assertions below also show the host unchanged.
# A play without sshd_profile: the role must refuse it. The block proves the refusal
# (not its wording).
+7 -19
View File
@@ -12,7 +12,7 @@ The role targets Ubuntu guests (the `ubuntu_lxc` and `ubuntu_vm` profiles) and P
## Requirements and run order
- Facts must be gathered (`gather_facts: true`); `reboot.yml` reads `ansible_facts['os_family']`.
- Facts must be gathered (`gather_facts: true`); `reboot.yml` reads `ansible_os_family`.
- `system_baseline_system_type` is required and has no default (the role does not read a global such as `system_type`; map it in the inventory). Valid values: `ubuntu_lxc`, `ubuntu_vm` or `pve`.
- Use it by its fully qualified name, `mortis.kamino.system_baseline`.
- Collections: `community.general` (locale, timezone) and `ansible.posix` (sysctl, mount).
@@ -39,13 +39,12 @@ templating error instead of the role's own message.
| `system_baseline_extra_remove_packages` | `[]` | no | Packages to purge in addition to the resolved list; appends |
| `system_baseline_apt_periodic_settings` | from profile | no | Keys for `20auto-upgrades` |
| `system_baseline_apt_upgrade` | from profile | no | `safe` or `dist`: how the role upgrades packages (`pve`: `dist`, the Ubuntu profiles: `safe`); see "Apt upgrade mode" |
| `system_baseline_skip_upgrade_during_vzdump` | `false` | no | `pve` only: skip the apt upgrade while a vzdump backup is running on the node (see "Skipping the upgrade during a backup") |
| `system_baseline_unattended_upgrade_settings` | from profile | no | Keys for `50unattended-upgrades` |
| `system_baseline_unattended_upgrade_origins` | from profile | no | Pinned `Origins-Pattern` entries; `[]` keeps the distribution default (see below) |
| `system_baseline_unattended_upgrade_package_blacklist` | `[]` | no | Packages unattended-upgrades must not touch, as regular expressions (see below) |
| `system_baseline_sysctl_hardening` | from profile | no | List of `name` and `value` sysctl pairs |
| `system_baseline_secure_tmp_mounts` | from profile | no | Paths remounted as tmpfs with `noexec,nosuid,nodev` |
| `system_baseline_journal_max_use` | `200M` | no | Upper bound of the persistent journal (journald `SystemMaxUse`): a number with an optional upper-case `B`, `K`, `M`, `G`, `T`, `P` or `E`, such as `1.5G`; a bare number is bytes. journald does not take `infinity`. Empty leaves the host alone and removes nothing a former run wrote (see "Leaving journald alone") |
| `system_baseline_journal_max_use` | `200M` | no | Upper bound of the persistent journal (journald `SystemMaxUse`): a number and `K`, `M`, `G` or `T`, or `infinity`. Empty leaves the host alone and removes nothing a former run wrote (see "Leaving journald alone") |
| `system_baseline_tmux_autostart` | `false` | no | Attach interactive SSH logins to a tmux session (`ubuntu_lxc` and `ubuntu_vm` only) |
| `system_baseline_tmux_session` | `main` | no | Session name, `A-Za-z0-9_-`, up to 32 characters |
| `system_baseline_tmux_windows` | `[]` | no | `{name, command}` windows made when the session is created |
@@ -129,13 +128,12 @@ The two task files besides `main` are a supported interface, for a caller that d
The scenario `molecule/default/` runs in CI only, on two platforms: `${MOLECULE_IMAGE}` (Ubuntu 24.04) and `${MOLECULE_IMAGE_2604}` (Ubuntu 26.04). It installs packages from the Ubuntu mirrors, so the runner needs outbound network. It runs `check` before the converge (a fresh host) and after it (a configured host).
- Verify first checks, on the controller, that the role refuses a bad input with its own message before any change: an unknown `system_baseline_system_type`, an unknown `system_baseline_apt_upgrade` (main flow and `update` entry point), a negative reboot throttle or a negative or boolean post-reboot delay (main flow and `reboot` entry point), a line break in `system_baseline_apt_daily_timeout`, a bad `system_baseline_journal_max_use` (`infinity`, a lower-case unit, a unit with a trailing `B`, a line break, a number), and a bad package blacklist (a quote, a null item, a bare string).
- Converge applies the `ubuntu_lxc` profile, with tmux autostart and `system_baseline_apt_daily_timeout: 1h`. Verify only resolves the `pve` and `ubuntu_vm` profiles and a consumer override, on the controller, asserting the resolved inputs.
- Converge first checks that the role refuses a bad input with its own message before any change: an unknown `system_baseline_system_type`, an unknown `system_baseline_apt_upgrade` (main flow and `update` entry point), a negative reboot throttle or a negative or boolean post-reboot delay (main flow and `reboot` entry point), a line break in `system_baseline_apt_daily_timeout`, a bad `system_baseline_journal_max_use` (a bare number, a space, a line break, a number), and a bad package blacklist (a quote, a null item, a bare string).
- Converge then applies the `ubuntu_lxc` profile, with tmux autostart and `system_baseline_apt_daily_timeout: 1h`, and only resolves the `pve` and `ubuntu_vm` profiles and a consumer override, asserting the resolved inputs.
- Verify checks the installed and removed packages, the journal size cap, the apt settings in `20auto-upgrades` and `50unattended-upgrades`, the locale, and that systemd loaded the `apt-daily.service` timeout.
- Verify checks the tmux snippet: root-owned, valid shell, the session and quoted window command, no effect without a terminal, a session name or window command ending in a newline refused, and the file removed when autostart is off.
- Verify refuses bad items in `system_baseline_extra_packages` and `system_baseline_extra_remove_packages` (whitespace, a null, an empty string, a trailing minus, upper case, a bare string) and a package that one input installs and another purges; converge applies the `ubuntu_lxc` profile with `jq` as an extra package and `ed` as an extra removal; verify checks that `jq` is installed, `ed` is gone and the profile's packages are still there, and that an extra `tmux` installs the snippet where a flat list without it installs none.
- Verify also checks that a bad `system_baseline_apt_tmpdir` (under `/tmp` or `/var/tmp`, relative, with `..`, empty) is refused in the main flow and in the `update` entry point. It reads `tasks/update.yml` and checks that the scratch directory is created with mode `0700`, that both apt tasks set `TMPDIR` to it, that the connection is reset afterwards, and that the vzdump guard is imported before the upgrade, whose `when` reads the guard's fact: the scenario skips the `update` tag, so the upgrade itself never runs there.
- Verify runs the vzdump guard in check mode on the Ubuntu container with `system_baseline_system_type: pve` and a `pvesh` stub, in seven cases (a running, a finished or no vzdump task, the input off, `ubuntu_lxc`); six run the guard's task file alone and the `ubuntu_lxc` case runs the whole `update` entry point. Each case asserts the fact that decides the upgrade and that `pvesh` was run, with `--source active`, only when it should be. It does not assert that the apt task itself was skipped. The stub stands for the real answer, which no CI image has.
- Converge refuses bad items in `system_baseline_extra_packages` and `system_baseline_extra_remove_packages` (whitespace, a null, an empty string, a trailing minus, upper case, a bare string) and a package that one input installs and another purges, then applies the `ubuntu_lxc` profile with `jq` as an extra package and `ed` as an extra removal; verify checks that `jq` is installed, `ed` is gone and the profile's packages are still there, and that an extra `tmux` installs the snippet where a flat list without it installs none.
- Converge also checks that a bad `system_baseline_apt_tmpdir` (under `/tmp` or `/var/tmp`, relative, with `..`, empty) is refused in the main flow and in the `update` entry point. Verify reads `tasks/update.yml` and checks that the scratch directory is created with mode `0700`, that both apt tasks set `TMPDIR` to it, and that the connection is reset afterwards: the scenario skips the `update` tag, so the upgrade itself never runs there.
- Verify ends by running the role once with `system_baseline_journal_max_use: ""` after removing the drop-in, and asserts that no drop-in is written and that `systemd-journald` was not restarted.
- Verify runs the `reboot` entry point with `system_baseline_reboot_if_required: false`, without and with `/var/run/reboot-required`, and checks the fact and that the host did not reboot.
- The `pve` origins pin is applied to the Ubuntu container and read back with `apt-config dump`, then removed again. The package blacklist is written, read back as a list, left alone by a second run and removed by an empty list.
@@ -161,7 +159,6 @@ system_baseline_extra_remove_packages: [telnet]
```
- Each item is a Debian package name: lower-case letters, digits, `+`, `-` and `.`, two or more characters, starting with a letter or digit and not ending in `-` (apt reads a trailing minus as a removal). Anything else stops the run. Duplicates of the profile list are harmless.
- The role does not refresh an APT cache younger than an hour, so a package from a source you add just before the role (`ansible.builtin.deb822_repository` does not refresh) needs your own cache refresh first.
- An extra counts wherever the role looks for a package in the list: an extra `tmux` enables the tmux snippet and an extra `unattended-upgrades` the unattended-upgrades tasks, as a profile package does.
- A package that one input installs and another purges stops the run before any change: `system_baseline_extra_packages` against `system_baseline_remove_packages` or `system_baseline_extra_remove_packages`, and `system_baseline_extra_remove_packages` against `system_baseline_essential_packages`. The resolved lists are not checked against each other, so a consumer's own overlap there behaves as before.
@@ -215,18 +212,9 @@ The profile key `apt_upgrade` (`safe` or `dist`, resolved to `system_baseline_ap
- The `update` entry point follows the same input: it upgrades with `dist` when `system_baseline_system_type` is `pve`. Without a `system_baseline_system_type` (the entry point does not require one) it stays on `safe`.
- Only the apt upgrade changes. Autoremove and autoclean, the check-mode skip and unattended-upgrades are as before; the example blacklist below keeps unattended-upgrades away from the Proxmox packages.
### Skipping the upgrade during a backup
An upgrade of a Proxmox node can restart Proxmox services while a backup holds a snapshot of a guest. With `system_baseline_skip_upgrade_during_vzdump: true` and `system_baseline_system_type: pve`, the role runs `pvesh get /nodes/localhost/tasks --source active --limit 0` before the upgrade (`--source active` lists the running tasks; the default, `archive`, holds only finished ones). When one of the listed tasks has the type `vzdump` and no `endtime`, the upgrade is skipped and a message says why; autoremove, autoclean and the reboot check still run, and the role does not wait for the backup, so run it again afterwards.
- Off by default. With `false`, or on any other system type, no `pvesh` command runs.
- The `update` entry point reads the input as well. In check mode the main flow skips the upgrade itself, so it does not ask for the tasks; the entry point previews the upgrade and so asks.
- `localhost` is the node's own alias in the Proxmox API, so the role needs neither a node name nor gathered facts.
- A `pvesh` answer that is not a JSON list stops the run, instead of upgrading on a guess.
### Leaving journald alone
`system_baseline_journal_max_use: ""` skips the journald task: no drop-in directory, no `50-system-baseline.conf` and no restart of `systemd-journald`. Use it where another drop-in, role or policy owns the journal size. A file an earlier run wrote stays, as for an empty `system_baseline_apt_daily_timeout`; remove it by hand if the cap should go. A value that is not empty and not a size journald reads (`infinity`, `10m`, one with a line break) stops the run before any change, in the same way as the apt-daily value.
`system_baseline_journal_max_use: ""` skips the journald task: no drop-in directory, no `50-system-baseline.conf` and no restart of `systemd-journald`. Use it where another drop-in, role or policy owns the journal size. A file an earlier run wrote stays, as for an empty `system_baseline_apt_daily_timeout`; remove it by hand if the cap should go. A value that is not empty and not a size (`300`, `0`, `10 M`, one with a line break) stops the run before any change, in the same way as the apt-daily value.
### Apt scratch directory
-3
View File
@@ -18,9 +18,6 @@ system_baseline_apt_tmpdir: /var/cache/system-baseline-apt-tmp
# Run the package update (tasks/update.yml) in the main flow. false skips it, for hosts that are patched by a separate,
# operator-run flow; the tasks_from: update entry point does not read it.
system_baseline_update: true
# Skip the apt upgrade while a vzdump backup is running on the Proxmox node (tasks/update.yml). Only for system_baseline_system_type pve;
# both the main flow and the tasks_from: update entry point read it. Off by default.
system_baseline_skip_upgrade_during_vzdump: false
# Upper bound of the persistent journal (journald SystemMaxUse); older archived files are removed above it. Empty leaves the host alone
# (tasks/journald.yml is not run; a drop-in an earlier run wrote stays).
system_baseline_journal_max_use: 200M
+4 -20
View File
@@ -7,7 +7,7 @@ argument_specs:
Validates C(system_baseline_system_type) and, when C(system_baseline_tmux_autostart) is true, the tmux session name and
windows, then runs the update (unless C(system_baseline_update) is false), packages, unattended-upgrades, locale, timezone,
journald, apt-daily timeout (when set), sysctl, tmpfs, tmux and reboot task files, in that order.
- Needs gathered facts, because the reboot check reads C(ansible_facts['os_family']).
- Needs gathered facts, because the reboot check reads C(ansible_os_family).
- >-
The resolved inputs C(system_baseline_profile), C(system_baseline_essential_packages),
C(system_baseline_remove_packages), C(system_baseline_apt_periodic_settings), C(system_baseline_apt_upgrade),
@@ -56,9 +56,8 @@ argument_specs:
- Upper bound of the persistent systemd journal (journald C(SystemMaxUse), for example C(200M)).
- Written to a drop-in under C(/etc/systemd/journald.conf.d).
- >-
A size journald reads, a number with an optional upper-case unit C(B), C(K), C(M), C(G), C(T), C(P) or C(E) (a bare number
is bytes); anything else (C(infinity), a lower-case unit, a line break) is refused before any change. Empty leaves the host
alone: no drop-in is written and journald is not restarted.
A number and one of C(K), C(M), C(G), C(T), or C(infinity); anything else (a bare number, a space, a line break) is refused
before any change. Empty leaves the host alone: no drop-in is written and journald is not restarted.
Clearing the value later does not remove a file already written.
system_baseline_tmux_autostart:
type: bool
@@ -189,18 +188,6 @@ argument_specs:
the reboot.
- The C(update) entry point does not read it.
- In check mode the main flow skips the upgrade itself (a pending update is not drift); autoremove and autoclean are still checked.
system_baseline_skip_upgrade_during_vzdump:
type: bool
default: false
description:
- >-
Skip the apt upgrade while a vzdump backup is running on the Proxmox node. Acts only when C(system_baseline_system_type) is
C(pve): the role runs C(pvesh get /nodes/localhost/tasks --source active), and a C(vzdump) task in that list is a running backup.
The upgrade is then skipped with a message, and the rest of the flow (autoremove, the reboot check) goes on. It does not wait for
the backup. With false, or on any other system type, no C(pvesh) command runs.
- >-
The C(update) entry point reads it too, and a C(pvesh) answer that is not a JSON list fails the run instead of upgrading. In check mode the
main flow skips the upgrade itself, so it does not ask for the tasks.
update:
short_description: Update and upgrade apt packages
description:
@@ -215,9 +202,6 @@ argument_specs:
It creates C(system_baseline_apt_tmpdir), runs the upgrade and the autoremove with C(TMPDIR) set to it, and then opens a new
connection, so that a restart of C(ssh.service) during the upgrade does not remove the files apt needs. It reads that input
although the entry point has no argument specification of its own.
- >-
It also reads C(system_baseline_skip_upgrade_during_vzdump): with true on C(system_baseline_system_type) C(pve) it skips the upgrade while
a vzdump backup is running.
reboot:
short_description: Compute system_baseline_reboot_required and reboot when allowed
description:
@@ -229,7 +213,7 @@ argument_specs:
never reboots, so a caller can read C(system_baseline_reboot_required) (bool) and reboot on its own terms, for example after
draining a node. The fact name and this behaviour are part of the role's interface.
- On a non-Debian host the fact is not set; read it with C(default(false)).
- Reads C(ansible_facts['os_family']), so facts must be gathered.
- Reads C(ansible_os_family), so facts must be gathered.
options:
system_baseline_reboot_if_required:
type: bool
@@ -1,8 +1,184 @@
---
- name: Refuse an unknown system_baseline_system_type
hosts: all
gather_facts: false
tasks:
- name: Run the role with a bad system_baseline_system_type
block:
- name: Include system_baseline
ansible.builtin.include_role:
name: mortis.kamino.system_baseline
vars:
system_baseline_system_type: not_a_type
- name: Unreachable when validation works
ansible.builtin.fail:
msg: system_baseline ran with an invalid system_baseline_system_type
rescue:
- name: The validation stopped the play
ansible.builtin.assert:
that: "'is invalid' in ansible_failed_result.msg | default('')"
quiet: true
# The apt upgrade mode is safe or dist: anything else (here `full`, an apt module value the role does not offer) stops the run before
# any change, with a message that names the input.
- name: An unknown apt upgrade mode is refused
hosts: all
gather_facts: false
tasks:
- name: Run the role with a bad system_baseline_apt_upgrade
block:
- name: Include system_baseline
ansible.builtin.include_role:
name: mortis.kamino.system_baseline
vars:
system_baseline_system_type: ubuntu_lxc
system_baseline_apt_upgrade: full
- name: Unreachable when validation works
ansible.builtin.fail:
msg: system_baseline ran with an invalid system_baseline_apt_upgrade
rescue:
- name: The validation stopped the play
ansible.builtin.assert:
that: "'system_baseline_apt_upgrade is' in ansible_failed_result.msg | default('')"
quiet: true
# The update entry point does not run validate.yml, so it checks the mode itself and stops before it calls the package module.
- name: The update entry point refuses an unknown apt upgrade mode
hosts: all
gather_facts: false
tasks:
- name: Run the update entry point with a bad system_baseline_apt_upgrade
block:
- name: Include system_baseline, tasks_from update
ansible.builtin.include_role:
name: mortis.kamino.system_baseline
tasks_from: update
vars:
system_baseline_apt_upgrade: full
- name: Unreachable when validation works
ansible.builtin.fail:
msg: the update entry point ran with an invalid system_baseline_apt_upgrade
rescue:
- name: The validation stopped the play
ansible.builtin.assert:
that: "'system_baseline_apt_upgrade is' in ansible_failed_result.msg | default('')"
quiet: true
# The apt scratch directory becomes TMPDIR of the upgrade: a path under /tmp or /var/tmp (which a restart of ssh.service can delete), a relative
# path and a `..` each stop the run before any change, in the main flow and in the update entry point (which does not run validate.yml).
- name: A bad apt scratch directory is refused
hosts: all
gather_facts: false
tasks:
- name: Refuse each bad value
ansible.builtin.include_tasks: tasks/refuse_apt_tmpdir_entries.yml
vars:
system_baseline_refused_tmpdir: "{{ item }}"
loop:
- /tmp
- /var/tmp/apt
- /var/cache/../../tmp/x
- var/cache/apt-tmp
- ""
# The reboot inputs are whole numbers, 0 or more: a negative number and a boolean each stop the run before a host reboots,
# in the main flow and in the reboot entry point (which does not run validate.yml).
- name: A bad reboot throttle or post-reboot delay is refused
hosts: all
gather_facts: false
tasks:
- name: Refuse each bad value
ansible.builtin.include_tasks: tasks/refuse_reboot.yml
vars:
system_baseline_refused_reboot: "{{ item }}"
loop:
- {system_baseline_reboot_throttle: -1}
- {system_baseline_reboot_post_delay: -5}
- {system_baseline_reboot_post_delay: true}
# The value is written into a unit file, so a line break (a second directive) is refused.
- name: A bad apt-daily timeout is refused
hosts: all
gather_facts: false
tasks:
- name: Run the role with a line break in system_baseline_apt_daily_timeout
block:
- name: Include system_baseline
ansible.builtin.include_role:
name: mortis.kamino.system_baseline
vars:
system_baseline_system_type: ubuntu_lxc
system_baseline_apt_daily_timeout: "1h\nExecStart=/bin/true"
- name: Unreachable when validation works
ansible.builtin.fail:
msg: system_baseline ran with an invalid system_baseline_apt_daily_timeout
rescue:
- name: The validation stopped the play
ansible.builtin.assert:
that: "'system_baseline_apt_daily_timeout must be' in ansible_failed_result.msg | default('')"
quiet: true
# The journal cap is a number and a unit letter, or empty: a bare number (journald would read bytes), a zero, a space, a line break, a
# lower-case unit and a number that is not a string each stop the run before any change.
- name: A bad journal size cap is refused
hosts: all
gather_facts: false
tasks:
- name: Refuse each bad value
ansible.builtin.include_tasks: tasks/refuse_journal_max_use.yml
vars:
system_baseline_refused_journal: "{{ item }}"
loop:
- "300"
- "0"
- 10 M
- "10m"
- "200M\nStorage=none"
- 300
# A quote, a null item and a bare string (not a list) each stop the run: the bare string would otherwise be split into one-character
# patterns, and the null item would become an empty pattern that matches every package.
- name: A bad package blacklist is refused
hosts: all
gather_facts: false
tasks:
- name: Refuse each bad value
ansible.builtin.include_tasks: tasks/refuse_blacklist.yml
vars:
system_baseline_refused_blacklist: "{{ item }}"
loop:
- ['bad"name']
- [null]
- linux-image-.*
# Items that are not Debian package names (whitespace, null, empty, a trailing minus that apt reads as a removal, an option, upper case, a
# version pin), and a package that one input installs and another purges, each stop the run before any change.
# The overlaps are: an extra install against the profile's remove list (telnet), an extra install against an extra remove, and an extra
# remove against the profile's install list (tmux).
- name: A bad extra package list is refused
hosts: all
gather_facts: false
tasks:
- name: Refuse each bad value
ansible.builtin.include_tasks: tasks/refuse_extra_packages.yml
vars:
system_baseline_refused_case: "{{ item }}"
loop:
- { install: ['bad name'], expect: 'must be lists of package names' }
- { install: [null], expect: 'must be lists of package names' }
- { install: jq, expect: 'must be lists of package names' }
- { remove: [''], expect: 'must be lists of package names' }
- { install: ['jq-'], expect: 'must be lists of package names' }
- { install: ['-y'], expect: 'must be lists of package names' }
- { remove: ['Telnet'], expect: 'must be lists of package names' }
- { remove: ['ed=1.0'], expect: 'must be lists of package names' }
- { install: [telnet], expect: 'is both installed and purged' }
- { install: [jq], remove: [jq], expect: 'is both installed and purged' }
- { remove: [tmux], expect: 'is both installed and purged' }
- name: Converge the LXC profile
hosts: all
gather_facts: true
gather_subset: [min]
vars:
system_baseline_system_type: ubuntu_lxc
system_baseline_extra_packages: [jq]
@@ -14,3 +190,130 @@
- { name: logs, command: "echo 'a b'; true" }
roles:
- role: mortis.kamino.system_baseline
# The remaining plays only load the role's defaults (validate.yml changes nothing) and assert
# the resolved inputs. They cover the profiles the converge above cannot run.
- name: The pve profile resolves
hosts: all
gather_facts: false
vars:
system_baseline_system_type: pve
tasks:
- name: Load the role defaults
ansible.builtin.include_role:
name: mortis.kamino.system_baseline
tasks_from: validate.yml
public: true
- name: Assert the pve profile
ansible.builtin.assert:
that:
- "'ufw' not in system_baseline_essential_packages"
- "'tmux' not in system_baseline_essential_packages"
- "'unattended-upgrades' in system_baseline_essential_packages"
- system_baseline_unattended_upgrade_settings['Unattended-Upgrade::Automatic-Reboot'] == false
- system_baseline_unattended_upgrade_settings['Unattended-Upgrade::Automatic-Reboot-Time'] == '03:00'
- system_baseline_secure_tmp_mounts == ['/dev/shm', '/tmp', '/var/tmp']
- system_baseline_update
- system_baseline_apt_upgrade == 'dist'
- system_baseline_unattended_upgrade_origins | length == 3
- system_baseline_unattended_upgrade_origins | select('search', 'Proxmox') | list == []
- __system_baseline_install_packages == system_baseline_essential_packages
- __system_baseline_purge_packages == system_baseline_remove_packages
quiet: true
- name: The ubuntu_vm profile resolves
hosts: all
gather_facts: false
vars:
system_baseline_system_type: ubuntu_vm
tasks:
- name: Load the role defaults
ansible.builtin.include_role:
name: mortis.kamino.system_baseline
tasks_from: validate.yml
public: true
- name: Assert the ubuntu_vm profile
ansible.builtin.assert:
that:
- "'qemu-guest-agent' in system_baseline_essential_packages"
- "'tmux' in system_baseline_essential_packages"
- system_baseline_unattended_upgrade_settings['Unattended-Upgrade::Automatic-Reboot'] == false
- system_baseline_unattended_upgrade_settings['Unattended-Upgrade::Automatic-Reboot-Time'] == '04:00'
- system_baseline_sysctl_hardening | selectattr('name', 'equalto', 'net.ipv4.conf.all.log_martians') | list | length == 1
- system_baseline_apt_upgrade == 'safe'
- system_baseline_unattended_upgrade_origins == []
- __system_baseline_install_packages == system_baseline_essential_packages
- __system_baseline_purge_packages == system_baseline_remove_packages
quiet: true
# Consumer play vars override the profile.
- name: Consumer overrides win over the profile
hosts: all
gather_facts: false
vars:
system_baseline_system_type: ubuntu_vm
system_baseline_remove_packages: [telnet]
system_baseline_apt_upgrade: dist
system_baseline_profile_overrides:
ubuntu_vm:
unattended_upgrade_settings:
"Unattended-Upgrade::Automatic-Reboot": true
tasks:
- name: Load the role defaults
ansible.builtin.include_role:
name: mortis.kamino.system_baseline
tasks_from: validate.yml
public: true
- name: Assert the overrides
ansible.builtin.assert:
that:
- system_baseline_remove_packages == ['telnet']
- system_baseline_apt_upgrade == 'dist'
- system_baseline_unattended_upgrade_settings['Unattended-Upgrade::Automatic-Reboot'] == true
- system_baseline_unattended_upgrade_settings['Unattended-Upgrade::Automatic-Reboot-Time'] == '04:00'
- "'qemu-guest-agent' in system_baseline_essential_packages"
quiet: true
# The extras append to the resolved lists, whether the profile's list or a flat input supplies them, and a name that is in both is listed once.
- name: Extra packages append to the resolved lists
hosts: all
gather_facts: false
vars:
system_baseline_system_type: ubuntu_lxc
system_baseline_essential_packages: [vim, curl]
system_baseline_extra_packages: [jq, vim, unattended-upgrades]
system_baseline_extra_remove_packages: [ed, telnet]
tasks:
- name: Load the role defaults
ansible.builtin.include_role:
name: mortis.kamino.system_baseline
tasks_from: validate.yml
public: true
- name: Assert the lists the role acts on
ansible.builtin.assert:
that:
- __system_baseline_install_packages == ['vim', 'curl', 'jq', 'unattended-upgrades']
- "'ed' in __system_baseline_purge_packages"
- __system_baseline_purge_packages | select('equalto', 'telnet') | list | length == 1
- system_baseline_remove_packages | difference(__system_baseline_purge_packages) | length == 0
quiet: true
# A flat input that is a plain string (the package module accepts one) still counts as a one-item list, with and without extras.
- name: A flat string package list still resolves
hosts: all
gather_facts: false
vars:
system_baseline_system_type: ubuntu_lxc
system_baseline_essential_packages: vim
system_baseline_extra_packages: [jq]
tasks:
- name: Load the role defaults
ansible.builtin.include_role:
name: mortis.kamino.system_baseline
tasks_from: validate.yml
public: true
- name: Assert the lists the role acts on
ansible.builtin.assert:
that:
- __system_baseline_install_packages == ['vim', 'jq']
quiet: true
@@ -1,62 +0,0 @@
---
# One case of the vzdump guard: a pvesh stub answers with system_baseline_case.answer, the role's tasks_from file (the guard alone unless the
# case names update) runs in check mode, and the fact that decides the upgrade, and whether pvesh was asked at all, are compared with what the
# case expects. Kept outside the role's own tasks: no CI image is a Proxmox node, so the stub stands for the real `pvesh get` answer.
- name: Write the pvesh stub
check_mode: false
ansible.builtin.copy:
dest: /usr/local/bin/pvesh
mode: "0755"
content: |
#!/bin/sh
echo "$*" >> /var/tmp/pvesh-calls
cat <<'JSON'
{{ system_baseline_case.answer | to_json }}
JSON
- name: Create the apt scratch directory, which a check mode run of the update entry point does not
check_mode: false
when: system_baseline_case.tasks_from | default('vzdump_guard') == 'update'
ansible.builtin.file:
path: /var/cache/system-baseline-apt-tmp
state: directory
mode: "0700"
- name: Forget earlier calls
ansible.builtin.file:
path: /var/tmp/pvesh-calls
state: absent
- name: Run the case's tasks in check mode
check_mode: true
block:
- name: Include system_baseline, tasks_from {{ system_baseline_case.tasks_from | default('vzdump_guard') }}
ansible.builtin.include_role:
name: mortis.kamino.system_baseline
tasks_from: "{{ system_baseline_case.tasks_from | default('vzdump_guard') }}"
vars:
system_baseline_system_type: "{{ system_baseline_case.type }}"
system_baseline_skip_upgrade_during_vzdump: "{{ system_baseline_case.input }}"
- name: Read the recorded pvesh calls
ansible.builtin.slurp:
src: /var/tmp/pvesh-calls
register: system_baseline_case_calls
failed_when: false
- name: The guard decided as the case expects, and pvesh was asked only when it should be
ansible.builtin.assert:
that:
- __system_baseline_vzdump_running == system_baseline_case.running
- (system_baseline_case_calls.content is defined) == system_baseline_case.asked
- not system_baseline_case.asked or
"get /nodes/localhost/tasks --source active --limit 0 --output-format json" in (system_baseline_case_calls.content | b64decode)
quiet: true
- name: Remove the pvesh stub and its record
ansible.builtin.file:
path: "{{ item }}"
state: absent
loop:
- /usr/local/bin/pvesh
- /var/tmp/pvesh-calls
Loaded 100 of 142 files, more files were not shown because too many files have changed in this diff. Show more