3 Commits
Author SHA1 Message Date
Defame1297 464cc5848b Merge branch 'main' into fix/364-ansible-facts
Build / build (pull_request) Successful in 29s
Lint / lint (pull_request) Successful in 2m56s
Molecule / molecule (pull_request) Failing after 45m4s
2026-11-26 21:50:58 +00:00
Defame1297 d1b4501c2b Merge branch 'main' into fix/364-ansible-facts
Build / build (pull_request) Successful in 29s
Lint / lint (pull_request) Successful in 2m10s
Molecule / molecule (pull_request) Canceled after 5m20s
2026-11-26 21:44:16 +00:00
Dragonish 26b6e37a09 fix: read facts through ansible_facts and run Molecule with fact injection off
Build / build (pull_request) Successful in 34s
Lint / lint (pull_request) Successful in 2m32s
Molecule / molecule (pull_request) Canceled after 6m34s
ansible-core deprecates injecting facts as top-level variables (removal is
scheduled for 2.24, see #364). Three roles still read a bare fact: system_baseline (reboot check,
ansible_os_family), docker (APT source line, ansible_distribution_release)
and gitea_runner (re-registration backup name, ansible_date_time). With
inject_facts_as_vars set to false the system_baseline reboot check failed
with "'ansible_os_family' is undefined".

They now read ansible_facts[...]; the argument specs and READMEs that name
the facts follow. run_molecule_in_ci_image.sh exports
ANSIBLE_INJECT_FACT_VARS=False, so a role that reads an injected fact fails
its scenario, and a script test keeps the export in place.

Refs #364

Assisted-by: Claude Code:claude-sonnet-5-5
2026-11-26 21:33:03 +00:00
19 changed files with 71 additions and 67 deletions

No files matched your search

-18
View File
@@ -4,24 +4,6 @@ mortis.kamino Release Notes
.. contents:: Topics .. contents:: Topics
v3.1.0
======
Minor Changes
-------------
- tailscale - New role. Installs Tailscale from the upstream APT repository with the keyring pinned by sha256, sets ``--tun=userspace-networking`` in the ``tailscaled`` flags when ``tailscale_userspace_networking`` is true, enables ``tailscaled`` and, with ``tailscale_up`` (default ``true``), runs ``tailscale up`` with ``tailscale_auth_key`` while the node is not Running; it can also update to the APT candidate version and remove or purge. Declares Ubuntu noble and resolute; the molecule scenario installs the real package but does not join a tailnet.
Bugfixes
--------
- cloudflared - Do not fail under ``--check`` on a host where the cloudflared account or systemd unit does not exist yet.
- docker - Do not fail under ``--check`` on a host where the Docker repository and packages are not installed yet.
- gitea - Do not fail under ``--check`` on a host where Gitea is not installed yet.
- gitea_runner - Do not fail under ``--check`` on a host where the runner account, Docker or the systemd unit does not exist yet.
- traefik - Do not fail under ``--check`` on a host where Traefik is not installed yet.
- user_management - Do not fail under ``--check`` when a managed user does not exist yet.
v3.0.0 v3.0.0
====== ======
+2 -2
View File
@@ -5,7 +5,7 @@ An Ansible Collection of reusable, hardened roles for a self-hosted home lab:
`pihole`, `pve_lxc`, `sshd`, `system_baseline`, `systemd_hardening`, `tailscale`, `traefik`, `ufw` and `pihole`, `pve_lxc`, `sshd`, `system_baseline`, `systemd_hardening`, `tailscale`, `traefik`, `ufw` and
`user_management`, plus the internal `_binary_update`. Roles still to come are listed under [Roadmap](#roadmap). `user_management`, plus the internal `_binary_update`. Roles still to come are listed under [Roadmap](#roadmap).
Status: roles arrive in waves. Release 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). Status: roles arrive in waves. Release 3.0.0 holds the `cloudflared`, `docker`, `fail2ban`, `gitea`, `gitea_runner`, `network_interfaces`, `pihole`, `pve_lxc`, `sshd`, `system_baseline`, `systemd_hardening`, `traefik`, `ufw` and `user_management` roles (and the internal `_binary_update`, which `cloudflared`, `gitea`, `gitea_runner` and `traefik` call).
## Consuming ## Consuming
@@ -17,7 +17,7 @@ name (FQCN) only, `mortis.kamino.<role>`:
collections: collections:
- name: https://git.rkdr.net/mortis/kamino.git - name: https://git.rkdr.net/mortis/kamino.git
type: git type: git
version: v3.1.0 version: v3.0.0
``` ```
Its dependencies (`community.general`, `ansible.posix`, `community.proxmox`) are declared in `galaxy.yml`, so Its dependencies (`community.general`, `ansible.posix`, `community.proxmox`) are declared in `galaxy.yml`, so
+1 -5
View File
@@ -51,10 +51,6 @@ objects:
description: Harden systemd for a system type description: Harden systemd for a system type
name: systemd_hardening name: systemd_hardening
version_added: null version_added: null
tailscale:
description: Install Tailscale and bring the node up
name: tailscale
version_added: null
traefik: traefik:
description: Install, configure, update or remove Traefik as a systemd binary description: Install, configure, update or remove Traefik as a systemd binary
name: traefik name: traefik
@@ -85,4 +81,4 @@ plugins:
strategy: {} strategy: {}
test: {} test: {}
vars: {} vars: {}
version: 3.1.0 version: 3.0.0
-28
View File
@@ -446,31 +446,3 @@ releases:
- 133-drop-jammy-and-ubuntu-all.yml - 133-drop-jammy-and-ubuntu-all.yml
- 133-ubuntu-2604.yml - 133-ubuntu-2604.yml
release_date: '2026-11-26' release_date: '2026-11-26'
3.1.0:
changes:
bugfixes:
- cloudflared - Do not fail under ``--check`` on a host where the cloudflared
account or systemd unit does not exist yet.
- docker - Do not fail under ``--check`` on a host where the Docker repository
and packages are not installed yet.
- gitea - Do not fail under ``--check`` on a host where Gitea is not installed
yet.
- gitea_runner - Do not fail under ``--check`` on a host where the runner account,
Docker or the systemd unit does not exist yet.
- traefik - Do not fail under ``--check`` on a host where Traefik is not installed
yet.
- user_management - Do not fail under ``--check`` when a managed user does not
exist yet.
minor_changes:
- tailscale - New role. Installs Tailscale from the upstream APT repository
with the keyring pinned by sha256, sets ``--tun=userspace-networking`` in
the ``tailscaled`` flags when ``tailscale_userspace_networking`` is true,
enables ``tailscaled`` and, with ``tailscale_up`` (default ``true``), runs
``tailscale up`` with ``tailscale_auth_key`` while the node is not Running;
it can also update to the APT candidate version and remove or purge. Declares
Ubuntu noble and resolute; the molecule scenario installs the real package
but does not join a tailnet.
fragments:
- 134-check-mode.yml
- tailscale-role.yml
release_date: '2026-11-26'
+17
View File
@@ -0,0 +1,17 @@
---
bugfixes:
- >-
cloudflared - Do not fail under ``--check`` on a host where the cloudflared account or systemd
unit does not exist yet.
- >-
docker - Do not fail under ``--check`` on a host where the Docker repository and packages are
not installed yet.
- >-
gitea - Do not fail under ``--check`` on a host where Gitea is not installed yet.
- >-
gitea_runner - Do not fail under ``--check`` on a host where the runner account, Docker or the
systemd unit does not exist yet.
- >-
traefik - Do not fail under ``--check`` on a host where Traefik is not installed yet.
- >-
user_management - Do not fail under ``--check`` when a managed user does not exist yet.
@@ -0,0 +1,15 @@
---
bugfixes:
- >-
docker - Read the distribution release through ``ansible_facts['distribution_release']`` for the APT
source line, so the role works with ``inject_facts_as_vars`` set to false and in the ansible-core
release that stops injecting facts as variables. The source line is unchanged.
- >-
gitea_runner - Read the timestamp of the forced re-registration backup through
``ansible_facts['date_time']``, so the role works with ``inject_facts_as_vars`` set to false and in
the ansible-core release that stops injecting facts as variables. The backup name is unchanged.
- >-
system_baseline - Read the OS family through ``ansible_facts['os_family']`` in the reboot check, so
the role (and its ``reboot`` entry point) works with ``inject_facts_as_vars`` set to false and in
the ansible-core release that stops injecting facts as variables. Before, the task failed with
``'ansible_os_family' is undefined`` there.
+9
View File
@@ -0,0 +1,9 @@
---
minor_changes:
- >-
tailscale - New role. Installs Tailscale from the upstream APT repository with the keyring pinned by sha256,
sets ``--tun=userspace-networking`` in the ``tailscaled`` flags when ``tailscale_userspace_networking`` is true,
enables ``tailscaled`` and, with ``tailscale_up`` (default ``true``), runs ``tailscale up`` with
``tailscale_auth_key`` while the node is not Running; it can also update to the APT candidate version and remove
or purge. Declares Ubuntu noble and resolute; the molecule scenario installs the real package but does not join a
tailnet.
+1 -1
View File
@@ -1,7 +1,7 @@
--- ---
namespace: mortis namespace: mortis
name: kamino name: kamino
version: 3.1.0 version: 3.0.0
readme: README.md readme: README.md
authors: authors:
- Defame1297 - Defame1297
+2 -2
View File
@@ -4,7 +4,7 @@ Installs Docker Engine from the upstream Docker APT repository, optionally updat
## Supported platforms ## Supported platforms
Ubuntu 24.04 (noble) and 26.04 (resolute), the platforms the molecule scenario runs on. The key and repository URLs point at `download.docker.com/linux/ubuntu`, and the source line uses `ansible_distribution_release`. The apt architecture is derived from the host (`x86_64` gives `amd64`, `aarch64` gives `arm64`); any other architecture fails the play until `docker_apt_arch` is set. A limited molecule scenario covers the role's own logic (see [Tests](#tests)); the real Docker Engine is not tested. Ubuntu 24.04 (noble) and 26.04 (resolute), the platforms the molecule scenario runs on. The key and repository URLs point at `download.docker.com/linux/ubuntu`, and the source line uses `ansible_facts['distribution_release']`. The apt architecture is derived from the host (`x86_64` gives `amd64`, `aarch64` gives `arm64`); any other architecture fails the play until `docker_apt_arch` is set. A limited molecule scenario covers the role's own logic (see [Tests](#tests)); the real Docker Engine is not tested.
The role targets Ubuntu hosts only: it installs from Docker's Ubuntu repository, so it does not cover Debian trixie (Proxmox hosts). The role targets Ubuntu hosts only: it installs from Docker's Ubuntu repository, so it does not cover Debian trixie (Proxmox hosts).
@@ -91,7 +91,7 @@ With any of `docker_daemon_options`, `docker_live_restore`, `docker_log_driver`,
What it shows, with the role's tasks running unchanged: What it shows, with the role's tasks running unchanged:
- The key is fetched, stored at `docker_keyring_path` with mode `0644`, and apt really verifies the repository against it (an unsigned or wrongly signed repository would leave no install candidate). - The key is fetched, stored at `docker_keyring_path` with mode `0644`, and apt really verifies the repository against it (an unsigned or wrongly signed repository would leave no install candidate).
- The source line has the architecture, the `signed-by` keyring and `ansible_distribution_release`. - The source line has the architecture, the `signed-by` keyring and `ansible_facts['distribution_release']`.
- The packages are installed from that repository, the unit is enabled and active, and `docker_users` join `docker_group`. - The packages are installed from that repository, the unit is enabled and active, and `docker_users` join `docker_group`.
- `docker_remove` with `docker_remove_data` removes the source line, the keyring, the packages, the unit and `/var/lib/docker`. - `docker_remove` with `docker_remove_data` removes the source line, the keyring, the packages, the unit and `/var/lib/docker`.
- Both units are installed, enabled, ordered against `docker.service` as stated, the shutdown unit is active, a unit is removed when its input is `false`, and `docker_remove` removes both. - Both units are installed, enabled, ordered against `docker.service` as stated, the shutdown unit is active, a unit is removed when its input is `false`, and `docker_remove` removes both.
+2 -2
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 Installs Docker Engine from the upstream APT repository, or removes it when C(docker_remove) is true. Optionally updates the packages to
the current candidate versions, then adds C(docker_users) to C(docker_group). the current candidate versions, then adds C(docker_users) to C(docker_group).
- Needs gathered facts, because the APT source uses C(ansible_distribution_release). - Needs gathered facts, because the APT source uses C(ansible_facts['distribution_release']).
options: options:
docker_remove: docker_remove:
type: bool type: bool
@@ -53,7 +53,7 @@ argument_specs:
type: str type: str
default: https://download.docker.com/linux/ubuntu default: https://download.docker.com/linux/ubuntu
description: description:
- Base URL of the repository. The source line uses C(ansible_distribution_release) and the C(stable) component. - Base URL of the repository. The source line uses C(ansible_facts['distribution_release']) and the C(stable) component.
docker_apt_arch: docker_apt_arch:
type: str type: str
default: "" default: ""
+1 -1
View File
@@ -30,7 +30,7 @@
ansible.builtin.copy: ansible.builtin.copy:
dest: "{{ docker_apt_list_path }}" dest: "{{ docker_apt_list_path }}"
content: | content: |
deb [arch={{ __docker_apt_arch }} signed-by={{ docker_keyring_path }}] {{ docker_repo_base_url }} {{ ansible_distribution_release }} stable deb [arch={{ __docker_apt_arch }} signed-by={{ docker_keyring_path }}] {{ docker_repo_base_url }} {{ ansible_facts['distribution_release'] }} stable
mode: "0644" mode: "0644"
register: __docker_apt_source register: __docker_apt_source
tags: [docker, install] tags: [docker, install]
+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 registration token is generated on the fly, held in a `no_log` fact and passed to `gitea-runner register` through the `GITEA_RUNNER_REGISTRATION_TOKEN` environment variable, not argv. It is never written to a file by the role.
- The role creates `gitea_runner_group` and `gitea_runner_user` when they are missing; an existing account (for example the SSH login user) is reused. - The role creates `gitea_runner_group` and `gitea_runner_user` when they are missing; an existing account (for example the SSH login user) is reused.
- Docker is installed by this role (`tasks/docker.yml`) on first install, not by `mortis.kamino.docker`. - Docker is installed by this role (`tasks/docker.yml`) on first install, not by `mortis.kamino.docker`.
- Fact gathering must be on for `gitea_runner_force_register`: the backup name uses `ansible_date_time`. - Fact gathering must be on for `gitea_runner_force_register`: the backup name uses `ansible_facts['date_time']`.
- Updates: the update path stages the verified binary and hands the swap to `mortis.kamino._binary_update`, an internal role of this Collection. - Updates: the update path stages the verified binary and hands the swap to `mortis.kamino._binary_update`, an internal role of this Collection.
- `gitea_runner_version` is asserted at role start to be a plain `X.Y.Z` release number, with no leading `v`. Pin it in inventory to move the runner independently of Collection releases; the role default changes only with a release. - `gitea_runner_version` is asserted at role start to be a plain `X.Y.Z` release number, with no leading `v`. Pin it in inventory to move the runner independently of Collection releases; the role default changes only with a release.
- The executor and job image of a job come from its label's suffix (`:host` or `docker://<image>`); a label with no suffix runs its jobs on the host. `config.yaml` has no keys for them. - The executor and job image of a job come from its label's suffix (`:host` or `docker://<image>`); a label with no suffix runs its jobs on the host. `config.yaml` has no keys for them.
+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 C(gitea_runner_token_host), C(gitea_runner_instance_url) and C(gitea_runner_name) have empty role defaults and
are asserted only when registration runs, so a run that never registers is not blocked. are asserted only when registration runs, so a run that never registers is not blocked.
- >- - >-
Reads gathered facts (C(ansible_date_time), for the forced re-registration backup name) and Reads gathered facts (C(ansible_facts['date_time']), for the forced re-registration backup name) and
C(ansible_check_mode). C(ansible_check_mode).
options: options:
gitea_runner_remove: gitea_runner_remove:
+1 -1
View File
@@ -71,7 +71,7 @@
become: true become: true
ansible.builtin.copy: ansible.builtin.copy:
src: "{{ gitea_runner_work_dir }}/.runner" src: "{{ gitea_runner_work_dir }}/.runner"
dest: "{{ gitea_runner_work_dir }}/.runner.bak.{{ ansible_date_time.iso8601_basic_short }}" dest: "{{ gitea_runner_work_dir }}/.runner.bak.{{ ansible_facts['date_time']['iso8601_basic_short'] }}"
remote_src: true remote_src: true
owner: "{{ gitea_runner_state.stat.pw_name }}" owner: "{{ gitea_runner_state.stat.pw_name }}"
group: "{{ gitea_runner_state.stat.gr_name }}" group: "{{ gitea_runner_state.stat.gr_name }}"
+1 -1
View File
@@ -12,7 +12,7 @@ The role targets Ubuntu guests (the `ubuntu_lxc` and `ubuntu_vm` profiles) and P
## Requirements and run order ## Requirements and run order
- Facts must be gathered (`gather_facts: true`); `reboot.yml` reads `ansible_os_family`. - Facts must be gathered (`gather_facts: true`); `reboot.yml` reads `ansible_facts['os_family']`.
- `system_baseline_system_type` is required and has no default (the role does not read a global such as `system_type`; map it in the inventory). Valid values: `ubuntu_lxc`, `ubuntu_vm` or `pve`. - `system_baseline_system_type` is required and has no default (the role does not read a global such as `system_type`; map it in the inventory). Valid values: `ubuntu_lxc`, `ubuntu_vm` or `pve`.
- Use it by its fully qualified name, `mortis.kamino.system_baseline`. - Use it by its fully qualified name, `mortis.kamino.system_baseline`.
- Collections: `community.general` (locale, timezone) and `ansible.posix` (sysctl, mount). - Collections: `community.general` (locale, timezone) and `ansible.posix` (sysctl, mount).
@@ -7,7 +7,7 @@ argument_specs:
Validates C(system_baseline_system_type) and, when C(system_baseline_tmux_autostart) is true, the tmux session name and Validates C(system_baseline_system_type) and, when C(system_baseline_tmux_autostart) is true, the tmux session name and
windows, then runs the update (unless C(system_baseline_update) is false), packages, unattended-upgrades, locale, timezone, windows, then runs the update (unless C(system_baseline_update) is false), packages, unattended-upgrades, locale, timezone,
journald, apt-daily timeout (when set), sysctl, tmpfs, tmux and reboot task files, in that order. journald, apt-daily timeout (when set), sysctl, tmpfs, tmux and reboot task files, in that order.
- Needs gathered facts, because the reboot check reads C(ansible_os_family). - Needs gathered facts, because the reboot check reads C(ansible_facts['os_family']).
- >- - >-
The resolved inputs C(system_baseline_profile), C(system_baseline_essential_packages), The resolved inputs C(system_baseline_profile), C(system_baseline_essential_packages),
C(system_baseline_remove_packages), C(system_baseline_apt_periodic_settings), C(system_baseline_apt_upgrade), C(system_baseline_remove_packages), C(system_baseline_apt_periodic_settings), C(system_baseline_apt_upgrade),
@@ -187,7 +187,7 @@ argument_specs:
never reboots, so a caller can read C(system_baseline_reboot_required) (bool) and reboot on its own terms, for example after never reboots, so a caller can read C(system_baseline_reboot_required) (bool) and reboot on its own terms, for example after
draining a node. The fact name and this behaviour are part of the role's interface. draining a node. The fact name and this behaviour are part of the role's interface.
- On a non-Debian host the fact is not set; read it with C(default(false)). - On a non-Debian host the fact is not set; read it with C(default(false)).
- Reads C(ansible_os_family), so facts must be gathered. - Reads C(ansible_facts['os_family']), so facts must be gathered.
options: options:
system_baseline_reboot_if_required: system_baseline_reboot_if_required:
type: bool type: bool
+1 -1
View File
@@ -4,7 +4,7 @@
ansible.builtin.import_tasks: validate_reboot.yml ansible.builtin.import_tasks: validate_reboot.yml
- name: Check if reboot required (Debian) - name: Check if reboot required (Debian)
when: ansible_os_family == "Debian" when: ansible_facts['os_family'] == "Debian"
block: block:
- name: Check if reboot is required (Debian) - name: Check if reboot is required (Debian)
ansible.builtin.stat: ansible.builtin.stat:
+3
View File
@@ -32,5 +32,8 @@ molecule --version
# The collection under test first; molecule also installs it into each scenario's ANSIBLE_HOME, # The collection under test first; molecule also installs it into each scenario's ANSIBLE_HOME,
# which the run script keeps in the job tree. # which the run script keeps in the job tree.
export ANSIBLE_COLLECTIONS_PATH="$AC_ROOT:${extra_collections}/opt/collections" export ANSIBLE_COLLECTIONS_PATH="$AC_ROOT:${extra_collections}/opt/collections"
# Facts are not injected as variables (deprecated in ansible-core 2.22, removal scheduled for 2.24, see #364), so a
# role that reads a bare `ansible_<fact>` fails its scenario here instead of in a consumer's inventory.
export ANSIBLE_INJECT_FACT_VARS=False
python3 -I scripts/check_scenarios_load_checkout.py <<< "$selected" python3 -I scripts/check_scenarios_load_checkout.py <<< "$selected"
exec scripts/run_molecule_scenarios.sh "$AC_ROOT/molecule-runs" <<< "$selected" exec scripts/run_molecule_scenarios.sh "$AC_ROOT/molecule-runs" <<< "$selected"
+11 -1
View File
@@ -42,7 +42,7 @@ exit 0
# The scenario runner: records its arguments, paths and stdin. # The scenario runner: records its arguments, paths and stdin.
RUNNER_STUB = """#!/usr/bin/env bash RUNNER_STUB = """#!/usr/bin/env bash
echo "runner args=$* path=$PATH acp=$ANSIBLE_COLLECTIONS_PATH stdin=[$(cat | tr '\\n' ' ')]" >> "$STUB_LOG" echo "runner args=$* path=$PATH acp=$ANSIBLE_COLLECTIONS_PATH inject=${ANSIBLE_INJECT_FACT_VARS-unset} stdin=[$(cat | tr '\\n' ' ')]" >> "$STUB_LOG"
""" """
@@ -112,6 +112,16 @@ class RunMoleculeInCiImageTest(unittest.TestCase):
self.assertIn(f"acp={self.ac_root}:/opt/collections ", runner) self.assertIn(f"acp={self.ac_root}:/opt/collections ", runner)
self.assertIn(f"args={self.ac_root}/molecule-runs ", runner) self.assertIn(f"args={self.ac_root}/molecule-runs ", runner)
def test_scenarios_run_with_fact_injection_off(self):
# A role that reads a bare ansible_<fact> must fail its scenario here (#364), whichever way the pins went.
for fail in ("", "1"):
with self.subTest(pins_differ=bool(fail)):
self.log.write_text("")
result = self.run_script(STUB_FAIL_sha256sum=fail)
self.assertEqual(result.returncode, 0, result.stderr)
(runner,) = self.calls("runner")
self.assertIn(" inject=False ", runner)
def test_changed_pins_are_installed_and_put_first(self): def test_changed_pins_are_installed_and_put_first(self):
result = self.run_script(STUB_FAIL_sha256sum="1") result = self.run_script(STUB_FAIL_sha256sum="1")
self.assertEqual(result.returncode, 0, result.stderr) self.assertEqual(result.returncode, 0, result.stderr)