Compare commits
7
Commits
c7ab023dca
..
v2.0.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2dea86a492 | ||
|
|
2ecf7f8765 | ||
|
|
86b6abf5d9 | ||
|
|
03b21a9aef | ||
|
|
fcd331be06 | ||
|
|
11ed3df80e | ||
|
|
2e5f3ad8ca |
No files matched your search
@@ -75,9 +75,20 @@ issue.
|
||||
- **A role named in an include, import, play `roles:` entry or meta dependency is written out in
|
||||
full**, never bare or templated. *Why:* the selector finds dependent roles by their FQCN.
|
||||
*Held:* control: a selector test fails a bare or templated name.
|
||||
- **Scenarios load `mortis.kamino` from the checkout, never from molecule's installed copy, so
|
||||
`galaxy.yml` is on IGNORED.** *Why:* molecule installs the collection from `galaxy.yml` into
|
||||
each scenario's `ANSIBLE_HOME`, which is not on `ANSIBLE_COLLECTIONS_PATH`, so its changes
|
||||
(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.
|
||||
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
|
||||
belongs there only if no scenario reads it.** *Why:* a file a scenario reads but the selector
|
||||
ignores would let a breaking change through untested. *Held:* review.
|
||||
belongs there only if no scenario reads it** (`galaxy.yml` only by the rule above).
|
||||
*Why:* a file a scenario reads but the selector ignores would let a breaking change through
|
||||
untested. *Held:* review.
|
||||
- **Every scenario runs on a manual dispatch and in the nightly run (04:43 UTC, after
|
||||
Renovate's).** A push to `main` runs no Molecule. *Why:* a pull request runs only its
|
||||
selection, so drift in the other roles shows up here. *Held:* review.
|
||||
|
||||
@@ -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.41@sha256:6a2f152e20833f84ce168ec3a4ba07ba6823d9a3a7abd5f0411538fed5d146ed
|
||||
image: git.rkdr.net/mortis/ci:0.2.42@sha256:6dc6906aaf407ccff74adcaade5dc7a810cb3ffcc1a6caa9df26b94dfe1632f7
|
||||
env:
|
||||
PIP_DISABLE_PIP_VERSION_CHECK: "1"
|
||||
steps:
|
||||
|
||||
@@ -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.41@sha256:6a2f152e20833f84ce168ec3a4ba07ba6823d9a3a7abd5f0411538fed5d146ed
|
||||
image: git.rkdr.net/mortis/ci:0.2.42@sha256:6dc6906aaf407ccff74adcaade5dc7a810cb3ffcc1a6caa9df26b94dfe1632f7
|
||||
steps:
|
||||
# The container has no Node, so JavaScript actions such as actions/checkout
|
||||
# cannot run; clone with git and the job token.
|
||||
|
||||
@@ -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.41@sha256:6a2f152e20833f84ce168ec3a4ba07ba6823d9a3a7abd5f0411538fed5d146ed
|
||||
image: git.rkdr.net/mortis/ci:0.2.42@sha256:6dc6906aaf407ccff74adcaade5dc7a810cb3ffcc1a6caa9df26b94dfe1632f7
|
||||
env:
|
||||
PIP_DISABLE_PIP_VERSION_CHECK: "1"
|
||||
PRE_COMMIT_HOME: /opt/pre-commit
|
||||
|
||||
@@ -53,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.41@sha256:6a2f152e20833f84ce168ec3a4ba07ba6823d9a3a7abd5f0411538fed5d146ed
|
||||
git.rkdr.net/mortis/ci:0.2.42@sha256:6dc6906aaf407ccff74adcaade5dc7a810cb3ffcc1a6caa9df26b94dfe1632f7
|
||||
# Used by the scenarios as `image: ${MOLECULE_IMAGE}`; set it the same way to run
|
||||
# one locally.
|
||||
MOLECULE_IMAGE: >-
|
||||
|
||||
@@ -4,6 +4,31 @@ mortis.kamino Release Notes
|
||||
|
||||
.. contents:: Topics
|
||||
|
||||
v2.0.0
|
||||
======
|
||||
|
||||
Minor Changes
|
||||
-------------
|
||||
|
||||
- docker - ``docker_apt_arch`` now defaults to an empty value that derives the apt architecture from the host (``x86_64`` gives ``amd64``, ``aarch64`` gives ``arm64``) instead of always writing ``amd64``, so an arm64 host no longer needs an override. A value set in the inventory is used as before. A host with any other architecture fails the play with a message that names ``docker_apt_arch`` instead of getting an ``amd64`` source line that its apt cannot use; set ``docker_apt_arch`` for such a host.
|
||||
- fail2ban - the main entry point now reloads Fail2Ban when ``jail.local`` changes instead of restarting it, as ``service_jail`` already did. A restart stops every jail, which flushes its bans out of the firewall until they are restored from Fail2Ban's database, and forgets failures counted toward ``maxretry``; a reload applies the new settings to the running jails. The ``Restart Fail2Ban`` handler is removed: nothing in the role notifies it any more.
|
||||
- gitea_runner - The Docker prune can bound the image cache by count and by disk use. With ``gitea_runner_docker_prune_keep_per_repository`` above 0 the weekly prune keeps the newest N image IDs of each repository and removes every other image no container uses. With ``gitea_runner_docker_prune_disk_threshold_percent`` set, a timer (``gitea_runner_docker_prune_disk_check_schedule``, hourly by default) runs the count prune and a builder prune capped at ``gitea_runner_docker_prune_builder_keep_storage`` when the filesystem holding the Docker root is fuller than that, behind the same job gate as the weekly prune. Both are off by default.
|
||||
- system_baseline - Add ``system_baseline_unattended_upgrade_package_blacklist`` (list of regular expressions, default empty). A non-empty list is written to ``/etc/apt/apt.conf.d/90unattended-upgrades-blacklist`` as ``Unattended-Upgrade::Package-Blacklist``, so unattended-upgrades leaves those packages alone on a host whose kernel or drivers must not change. An empty list removes the file.
|
||||
- system_baseline - Add the input ``system_baseline_apt_daily_timeout``. When set (a systemd time span, for example ``1h``; the default is empty, which leaves the host alone) the role writes a ``TimeoutStartSec`` drop-in for ``apt-daily.service`` and reloads systemd, so a hung apt run is stopped. Tag ``apt-daily-timeout``.
|
||||
- system_baseline - Add the inputs ``system_baseline_reboot_throttle`` and ``system_baseline_reboot_post_delay`` (whole numbers, default ``0``, which keeps today's behaviour). They are passed to the ``throttle`` and ``post_reboot_delay`` of the reboot task, so a caller can reboot one host at a time and wait before the next. The main flow and the ``reboot`` entry point read them and refuse a negative or non-integer value before anything runs.
|
||||
- system_baseline - Add the profile key ``apt_upgrade`` (``safe`` or ``dist``) and the input ``system_baseline_apt_upgrade`` that it resolves to. The ``pve`` profile now upgrades packages with ``apt-get dist-upgrade`` (``apt full-upgrade``, which Proxmox VE documents), so packages that a plain upgrade holds back (a new kernel, ``pve-manager``) are installed too; the Ubuntu profiles keep the plain upgrade. A ``pve`` host therefore receives those packages on the next run: set ``system_baseline_reboot_if_required`` to ``false`` first if the role must not reboot it. The ``update`` entry point follows the input when ``system_baseline_system_type`` is set, and so can also remove packages on a ``pve`` host; it stays on the plain upgrade when the type is not set, and now refuses an unknown mode.
|
||||
|
||||
Breaking Changes / Porting Guide
|
||||
--------------------------------
|
||||
|
||||
- Raise the minimum ansible-core to 2.22 (controller Python 3.14); 2.19, 2.20 and 2.21 are no longer supported. ``requires_ansible`` and every role's ``min_ansible_version`` now equal the ansible-core minor that CI tests.
|
||||
- gitea_runner - With ``gitea_runner_molecule_enabled`` the role no longer installs molecule tooling or collections: a job on the ``<gitea_runner_molecule_label>:host`` label brings its own toolchain in an image and runs it on the host's Docker daemon. The role still registers that label and now installs only ``git`` and ``python3`` on the host, which the job uses there, and no longer needs PyPI or Ansible Galaxy access. The inputs ``gitea_runner_molecule_venv``, ``gitea_runner_molecule_collections_path``, ``gitea_runner_collections_requirements_file``, ``gitea_runner_molecule_version``, ``gitea_runner_molecule_plugins_version``, ``gitea_runner_molecule_ansible_core_version`` and ``gitea_runner_molecule_docker_sdk_version`` are removed; a value set in the inventory is ignored. The role does not delete a venv or collections directory an earlier version installed: remove ``/opt/molecule-venv``, ``/opt/molecule-collections`` (the old defaults) and ``<gitea_runner_home>/molecule-requirements.yml`` by hand if nothing else uses them.
|
||||
|
||||
Bugfixes
|
||||
--------
|
||||
|
||||
- system_baseline - Do not run the apt upgrade in check mode in the main flow. A package that is only waiting for the next patch run, or a package cache older than an hour, is not drift, but the package module reports both as changed, so a scheduled dry run flagged every host. Autoremove and autoclean are now a task of their own and stay checked; as part of the upgrade call the module did not reach autoclean, so ``apt-get autoclean`` now runs (and may report changed once on a host with stale archives), in the main flow and in the ``update`` entry point. The ``update`` entry point still previews the upgrade in check mode.
|
||||
|
||||
v1.11.0
|
||||
=======
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ An Ansible Collection of reusable, hardened roles for a self-hosted home lab:
|
||||
`sshd`, `system_baseline`, `systemd_hardening`, `traefik`, `ufw` and `user_management`,
|
||||
plus the internal `_binary_update`. Roles still to come are listed under [Roadmap](#roadmap).
|
||||
|
||||
Status: roles arrive in waves. Release 1.11.0 holds the `cloudflared`, `docker`, `fail2ban`, `gitea`, `gitea_runner`, `network_interfaces`, `sshd`, `system_baseline`, `systemd_hardening`, `traefik`, `ufw` and `user_management` roles (and the internal `_binary_update`, which `cloudflared`, `gitea`, `gitea_runner` and `traefik` call).
|
||||
Status: roles arrive in waves. Release 2.0.0 holds the `cloudflared`, `docker`, `fail2ban`, `gitea`, `gitea_runner`, `network_interfaces`, `sshd`, `system_baseline`, `systemd_hardening`, `traefik`, `ufw` and `user_management` roles (and the internal `_binary_update`, which `cloudflared`, `gitea`, `gitea_runner` and `traefik` call).
|
||||
|
||||
## Consuming
|
||||
|
||||
@@ -17,7 +17,7 @@ name (FQCN) only, `mortis.kamino.<role>`:
|
||||
collections:
|
||||
- name: https://git.rkdr.net/mortis/kamino.git
|
||||
type: git
|
||||
version: v1.11.0
|
||||
version: v2.0.0
|
||||
```
|
||||
|
||||
Its dependencies (`community.general`, `ansible.posix`) are declared in `galaxy.yml`, so
|
||||
|
||||
@@ -71,4 +71,4 @@ plugins:
|
||||
strategy: {}
|
||||
test: {}
|
||||
vars: {}
|
||||
version: 1.11.0
|
||||
version: 2.0.0
|
||||
@@ -266,3 +266,92 @@ releases:
|
||||
- gitea-role.yml
|
||||
- release-1.9.0.yml
|
||||
release_date: '2026-11-21'
|
||||
2.0.0:
|
||||
changes:
|
||||
breaking_changes:
|
||||
- Raise the minimum ansible-core to 2.22 (controller Python 3.14); 2.19, 2.20
|
||||
and 2.21 are no longer supported. ``requires_ansible`` and every role's ``min_ansible_version``
|
||||
now equal the ansible-core minor that CI tests.
|
||||
- 'gitea_runner - With ``gitea_runner_molecule_enabled`` the role no longer
|
||||
installs molecule tooling or collections: a job on the ``<gitea_runner_molecule_label>:host``
|
||||
label brings its own toolchain in an image and runs it on the host''s Docker
|
||||
daemon. The role still registers that label and now installs only ``git``
|
||||
and ``python3`` on the host, which the job uses there, and no longer needs
|
||||
PyPI or Ansible Galaxy access. The inputs ``gitea_runner_molecule_venv``,
|
||||
``gitea_runner_molecule_collections_path``, ``gitea_runner_collections_requirements_file``,
|
||||
``gitea_runner_molecule_version``, ``gitea_runner_molecule_plugins_version``,
|
||||
``gitea_runner_molecule_ansible_core_version`` and ``gitea_runner_molecule_docker_sdk_version``
|
||||
are removed; a value set in the inventory is ignored. The role does not delete
|
||||
a venv or collections directory an earlier version installed: remove ``/opt/molecule-venv``,
|
||||
``/opt/molecule-collections`` (the old defaults) and ``<gitea_runner_home>/molecule-requirements.yml``
|
||||
by hand if nothing else uses them.'
|
||||
bugfixes:
|
||||
- system_baseline - Do not run the apt upgrade in check mode in the main flow.
|
||||
A package that is only waiting for the next patch run, or a package cache
|
||||
older than an hour, is not drift, but the package module reports both as changed,
|
||||
so a scheduled dry run flagged every host. Autoremove and autoclean are now
|
||||
a task of their own and stay checked; as part of the upgrade call the module
|
||||
did not reach autoclean, so ``apt-get autoclean`` now runs (and may report
|
||||
changed once on a host with stale archives), in the main flow and in the ``update``
|
||||
entry point. The ``update`` entry point still previews the upgrade in check
|
||||
mode.
|
||||
minor_changes:
|
||||
- docker - ``docker_apt_arch`` now defaults to an empty value that derives the
|
||||
apt architecture from the host (``x86_64`` gives ``amd64``, ``aarch64`` gives
|
||||
``arm64``) instead of always writing ``amd64``, so an arm64 host no longer
|
||||
needs an override. A value set in the inventory is used as before. A host
|
||||
with any other architecture fails the play with a message that names ``docker_apt_arch``
|
||||
instead of getting an ``amd64`` source line that its apt cannot use; set ``docker_apt_arch``
|
||||
for such a host.
|
||||
- 'fail2ban - the main entry point now reloads Fail2Ban when ``jail.local``
|
||||
changes instead of restarting it, as ``service_jail`` already did. A restart
|
||||
stops every jail, which flushes its bans out of the firewall until they are
|
||||
restored from Fail2Ban''s database, and forgets failures counted toward ``maxretry``;
|
||||
a reload applies the new settings to the running jails. The ``Restart Fail2Ban``
|
||||
handler is removed: nothing in the role notifies it any more.'
|
||||
- gitea_runner - The Docker prune can bound the image cache by count and by
|
||||
disk use. With ``gitea_runner_docker_prune_keep_per_repository`` above 0 the
|
||||
weekly prune keeps the newest N image IDs of each repository and removes every
|
||||
other image no container uses. With ``gitea_runner_docker_prune_disk_threshold_percent``
|
||||
set, a timer (``gitea_runner_docker_prune_disk_check_schedule``, hourly by
|
||||
default) runs the count prune and a builder prune capped at ``gitea_runner_docker_prune_builder_keep_storage``
|
||||
when the filesystem holding the Docker root is fuller than that, behind the
|
||||
same job gate as the weekly prune. Both are off by default.
|
||||
- system_baseline - Add ``system_baseline_unattended_upgrade_package_blacklist``
|
||||
(list of regular expressions, default empty). A non-empty list is written
|
||||
to ``/etc/apt/apt.conf.d/90unattended-upgrades-blacklist`` as ``Unattended-Upgrade::Package-Blacklist``,
|
||||
so unattended-upgrades leaves those packages alone on a host whose kernel
|
||||
or drivers must not change. An empty list removes the file.
|
||||
- system_baseline - Add the input ``system_baseline_apt_daily_timeout``. When
|
||||
set (a systemd time span, for example ``1h``; the default is empty, which
|
||||
leaves the host alone) the role writes a ``TimeoutStartSec`` drop-in for ``apt-daily.service``
|
||||
and reloads systemd, so a hung apt run is stopped. Tag ``apt-daily-timeout``.
|
||||
- system_baseline - Add the inputs ``system_baseline_reboot_throttle`` and ``system_baseline_reboot_post_delay``
|
||||
(whole numbers, default ``0``, which keeps today's behaviour). They are passed
|
||||
to the ``throttle`` and ``post_reboot_delay`` of the reboot task, so a caller
|
||||
can reboot one host at a time and wait before the next. The main flow and
|
||||
the ``reboot`` entry point read them and refuse a negative or non-integer
|
||||
value before anything runs.
|
||||
- 'system_baseline - Add the profile key ``apt_upgrade`` (``safe`` or ``dist``)
|
||||
and the input ``system_baseline_apt_upgrade`` that it resolves to. The ``pve``
|
||||
profile now upgrades packages with ``apt-get dist-upgrade`` (``apt full-upgrade``,
|
||||
which Proxmox VE documents), so packages that a plain upgrade holds back (a
|
||||
new kernel, ``pve-manager``) are installed too; the Ubuntu profiles keep the
|
||||
plain upgrade. A ``pve`` host therefore receives those packages on the next
|
||||
run: set ``system_baseline_reboot_if_required`` to ``false`` first if the
|
||||
role must not reboot it. The ``update`` entry point follows the input when
|
||||
``system_baseline_system_type`` is set, and so can also remove packages on
|
||||
a ``pve`` host; it stays on the plain upgrade when the type is not set, and
|
||||
now refuses an unknown mode.'
|
||||
fragments:
|
||||
- ansible-core-2.22-floor.yml
|
||||
- docker-apt-arch-from-host.yml
|
||||
- fail2ban-reload.yml
|
||||
- gitea-runner-docker-prune-count-threshold.yml
|
||||
- gitea-runner-molecule-tooling-removed.yml
|
||||
- stale-claims.yml
|
||||
- system-baseline-check-mode-upgrade.yml
|
||||
- system-baseline-pve-dist-upgrade.yml
|
||||
- system-baseline-reboot-throttle-apt-daily.yml
|
||||
- system-baseline-unattended-blacklist.yml
|
||||
release_date: '2026-11-24'
|
||||
@@ -1,6 +0,0 @@
|
||||
---
|
||||
breaking_changes:
|
||||
- >-
|
||||
Raise the minimum ansible-core to 2.22 (controller Python 3.14); 2.19, 2.20 and 2.21
|
||||
are no longer supported. ``requires_ansible`` and every role's ``min_ansible_version``
|
||||
now equal the ansible-core minor that CI tests.
|
||||
@@ -1,7 +0,0 @@
|
||||
---
|
||||
minor_changes:
|
||||
- >-
|
||||
docker - ``docker_apt_arch`` now defaults to an empty value that derives the apt architecture from the host (``x86_64`` gives ``amd64``,
|
||||
``aarch64`` gives ``arm64``) instead of always writing ``amd64``, so an arm64 host no longer needs an override. A value set in the inventory
|
||||
is used as before. A host with any other architecture fails the play with a message that names ``docker_apt_arch`` instead of getting an
|
||||
``amd64`` source line that its apt cannot use; set ``docker_apt_arch`` for such a host.
|
||||
@@ -1,7 +0,0 @@
|
||||
---
|
||||
minor_changes:
|
||||
- >-
|
||||
fail2ban - the main entry point now reloads Fail2Ban when ``jail.local`` changes instead of restarting it, as ``service_jail``
|
||||
already did. A restart stops every jail, which flushes its bans out of the firewall until they are restored from Fail2Ban's
|
||||
database, and forgets failures counted toward ``maxretry``; a reload applies the new settings to the running jails. The
|
||||
``Restart Fail2Ban`` handler is removed: nothing in the role notifies it any more.
|
||||
@@ -1,9 +0,0 @@
|
||||
---
|
||||
minor_changes:
|
||||
- >-
|
||||
gitea_runner - The Docker prune can bound the image cache by count and by disk use. With
|
||||
``gitea_runner_docker_prune_keep_per_repository`` above 0 the weekly prune keeps the newest N image IDs of each
|
||||
repository and removes every other image no container uses. With ``gitea_runner_docker_prune_disk_threshold_percent``
|
||||
set, a timer (``gitea_runner_docker_prune_disk_check_schedule``, hourly by default) runs the count prune and a builder
|
||||
prune capped at ``gitea_runner_docker_prune_builder_keep_storage`` when the filesystem holding the Docker root is
|
||||
fuller than that, behind the same job gate as the weekly prune. Both are off by default.
|
||||
@@ -1,13 +0,0 @@
|
||||
---
|
||||
breaking_changes:
|
||||
- >-
|
||||
gitea_runner - With ``gitea_runner_molecule_enabled`` the role no longer installs molecule tooling or collections: a job on
|
||||
the ``<gitea_runner_molecule_label>:host`` label brings its own toolchain in an image and runs it on the host's Docker
|
||||
daemon. The role still registers that label and now installs only ``git`` and ``python3`` on the host, which the job uses
|
||||
there, and no longer needs PyPI or Ansible Galaxy access. The inputs ``gitea_runner_molecule_venv``,
|
||||
``gitea_runner_molecule_collections_path``, ``gitea_runner_collections_requirements_file``,
|
||||
``gitea_runner_molecule_version``, ``gitea_runner_molecule_plugins_version``,
|
||||
``gitea_runner_molecule_ansible_core_version`` and ``gitea_runner_molecule_docker_sdk_version`` are removed; a value set
|
||||
in the inventory is ignored. The role does not delete a venv or collections directory an earlier version installed:
|
||||
remove ``/opt/molecule-venv``, ``/opt/molecule-collections`` (the old defaults) and
|
||||
``<gitea_runner_home>/molecule-requirements.yml`` by hand if nothing else uses them.
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
trivial:
|
||||
- >-
|
||||
Name only the roles that ship in the README and the Galaxy description, and drop the
|
||||
licence texts, NOTICE and REUSE entries of roles that are not in the Collection.
|
||||
@@ -1,8 +0,0 @@
|
||||
---
|
||||
bugfixes:
|
||||
- >-
|
||||
system_baseline - Do not run the apt upgrade in check mode in the main flow. A package that is only waiting for the next patch run, or a
|
||||
package cache older than an hour, is not drift, but the package module reports both as changed, so a scheduled dry run flagged every
|
||||
host. Autoremove and autoclean are now a task of their own and stay checked; as part of the upgrade call the module did not reach
|
||||
autoclean, so ``apt-get autoclean`` now runs (and may report changed once on a host with stale archives), in the main flow and in the
|
||||
``update`` entry point. The ``update`` entry point still previews the upgrade in check mode.
|
||||
@@ -1,10 +0,0 @@
|
||||
---
|
||||
minor_changes:
|
||||
- >-
|
||||
system_baseline - Add the profile key ``apt_upgrade`` (``safe`` or ``dist``) and the input ``system_baseline_apt_upgrade`` that it resolves
|
||||
to. The ``pve`` profile now upgrades packages with ``apt-get dist-upgrade``
|
||||
(``apt full-upgrade``, which Proxmox VE documents), so packages that a plain upgrade
|
||||
holds back (a new kernel, ``pve-manager``) are installed too; the Ubuntu profiles keep the plain upgrade. A ``pve`` host therefore receives
|
||||
those packages on the next run: set ``system_baseline_reboot_if_required`` to ``false`` first if the role must not reboot it. The ``update``
|
||||
entry point follows the input when ``system_baseline_system_type`` is set, and so can also remove packages on a ``pve`` host; it stays on
|
||||
the plain upgrade when the type is not set, and now refuses an unknown mode.
|
||||
@@ -1,11 +0,0 @@
|
||||
---
|
||||
minor_changes:
|
||||
- >-
|
||||
system_baseline - Add the inputs ``system_baseline_reboot_throttle`` and ``system_baseline_reboot_post_delay`` (whole numbers, default
|
||||
``0``, which keeps today's behaviour). They are passed to the ``throttle`` and ``post_reboot_delay`` of the reboot task, so a caller can
|
||||
reboot one host at a time and wait before the next. The main flow and the ``reboot`` entry point read them and refuse a negative or
|
||||
non-integer value before anything runs.
|
||||
- >-
|
||||
system_baseline - Add the input ``system_baseline_apt_daily_timeout``. When set (a systemd time span, for example ``1h``; the default is
|
||||
empty, which leaves the host alone) the role writes a ``TimeoutStartSec`` drop-in for ``apt-daily.service`` and reloads systemd, so a hung
|
||||
apt run is stopped. Tag ``apt-daily-timeout``.
|
||||
@@ -1,6 +0,0 @@
|
||||
---
|
||||
minor_changes:
|
||||
- >-
|
||||
system_baseline - Add ``system_baseline_unattended_upgrade_package_blacklist`` (list of regular expressions, default empty). A non-empty
|
||||
list is written to ``/etc/apt/apt.conf.d/90unattended-upgrades-blacklist`` as ``Unattended-Upgrade::Package-Blacklist``, so unattended-upgrades
|
||||
leaves those packages alone on a host whose kernel or drivers must not change. An empty list removes the file.
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
---
|
||||
namespace: mortis
|
||||
name: kamino
|
||||
version: 1.11.0
|
||||
version: 2.0.0
|
||||
readme: README.md
|
||||
authors:
|
||||
- Defame1297
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
# SPDX-FileCopyrightText: Defame1297 and contributors
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
"""Fail when a molecule scenario would load mortis.kamino from anywhere but this checkout.
|
||||
|
||||
python3 -I scripts/check_scenarios_load_checkout.py < scenario-dirs
|
||||
|
||||
Checks the environment molecule hands ansible-playbook, not only the inherited one: a scenario's
|
||||
own env can change it. The rule it holds is in .gitea/workflows/AGENTS.md (Molecule). Exit 1 when
|
||||
a scenario would load another copy, or none.
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
from molecule.config import Config
|
||||
|
||||
CHECKOUT = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
|
||||
RULE = (
|
||||
"scenarios must load mortis.kamino from the checkout ({checkout}), not molecule's installed"
|
||||
" copy: the scenario selector ignores galaxy.yml on that rule"
|
||||
" (.gitea/workflows/AGENTS.md, Molecule)"
|
||||
)
|
||||
|
||||
|
||||
def playbook_env(scenario):
|
||||
"""The environment molecule gives ansible-playbook in `scenario`, as a role scenario runs it."""
|
||||
parts = scenario.split("/")
|
||||
cwd = os.path.join(CHECKOUT, *parts[:2]) if parts[0] == "roles" else CHECKOUT
|
||||
# molecule takes the project from the working directory; each call sets it afresh
|
||||
os.chdir(cwd)
|
||||
config = Config(
|
||||
os.path.relpath(os.path.join(CHECKOUT, scenario, "molecule.yml")),
|
||||
args={},
|
||||
command_args={"subcommand": "converge"},
|
||||
)
|
||||
return dict(config.provisioner.env)
|
||||
|
||||
|
||||
def collection_paths(env, cwd):
|
||||
"""COLLECTIONS_PATHS as ansible-config resolves it in `env`, in search order."""
|
||||
env = dict(env)
|
||||
# molecule writes its ansible.cfg only when a step runs; the environment outranks it anyway
|
||||
if not os.path.isfile(env.get("ANSIBLE_CONFIG", "")):
|
||||
env.pop("ANSIBLE_CONFIG", None)
|
||||
out = subprocess.run(
|
||||
["ansible-config", "dump", "-t", "base", "--format", "json"],
|
||||
cwd=cwd,
|
||||
env=env,
|
||||
check=True,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
).stdout
|
||||
(entry,) = [e for e in json.loads(out) if e.get("name") == "COLLECTIONS_PATHS"]
|
||||
return entry["value"]
|
||||
|
||||
|
||||
def loaded_copy(paths):
|
||||
"""The mortis.kamino directory the first of `paths` holding one gives, or None."""
|
||||
for path in paths:
|
||||
# a path may name the ansible_collections directory itself
|
||||
base = (
|
||||
path
|
||||
if os.path.basename(path) == "ansible_collections"
|
||||
else os.path.join(path, "ansible_collections")
|
||||
)
|
||||
found = os.path.join(base, "mortis", "kamino")
|
||||
if os.path.isdir(found):
|
||||
return found
|
||||
return None
|
||||
|
||||
|
||||
def main():
|
||||
failed = False
|
||||
with tempfile.TemporaryDirectory(prefix="kamino-loads-") as home:
|
||||
# molecule's config writes its scratch directories under ANSIBLE_HOME
|
||||
os.environ.setdefault("ANSIBLE_HOME", home)
|
||||
for scenario in filter(None, sys.stdin.read().splitlines()):
|
||||
scenario_dir = os.path.join(CHECKOUT, scenario)
|
||||
paths = [os.path.join(scenario_dir, "collections")]
|
||||
paths += collection_paths(playbook_env(scenario), scenario_dir)
|
||||
found = loaded_copy(paths)
|
||||
if found and os.path.realpath(found) == CHECKOUT:
|
||||
continue
|
||||
failed = True
|
||||
print(
|
||||
f"::error::{scenario}: "
|
||||
+ RULE.format(checkout=CHECKOUT)
|
||||
+ f"; it would load {found or 'no mortis.kamino on ' + ':'.join(paths)}"
|
||||
)
|
||||
return 1 if failed else 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -4,7 +4,8 @@
|
||||
#
|
||||
# The Molecule workflow's run inside the ci image, from the checkout root: when a pin file differs
|
||||
# from the image's, install the pull request's pins into $AC_ROOT/pins (/opt is not writable for the
|
||||
# runner user) and put them first, then run the scenarios on stdin. CI_BASE_PYTHON is a test seam.
|
||||
# runner user) and put them first, then check that the scenarios on stdin load this checkout and run
|
||||
# them. CI_BASE_PYTHON is a test seam.
|
||||
#
|
||||
# AC_ROOT=<dir holding ansible_collections> scripts/run_molecule_in_ci_image.sh < scenario-dirs
|
||||
set -euo pipefail
|
||||
@@ -31,4 +32,5 @@ molecule --version
|
||||
# The collection under test first; molecule also installs it into each scenario's ANSIBLE_HOME,
|
||||
# which the run script keeps in the job tree.
|
||||
export ANSIBLE_COLLECTIONS_PATH="$AC_ROOT:${extra_collections}/opt/collections"
|
||||
python3 -I scripts/check_scenarios_load_checkout.py <<< "$selected"
|
||||
exec scripts/run_molecule_scenarios.sh "$AC_ROOT/molecule-runs" <<< "$selected"
|
||||
@@ -17,7 +17,7 @@ Only a pull request is narrowed, and only when <base-ref> is given and EVENT_NAM
|
||||
only (the image-smoke scenarios test the images, not the roles); a shared file such as
|
||||
extensions/molecule/requirements.yml is "any other file";
|
||||
* a file on the IGNORED list (documentation, changelog, repository tooling that no
|
||||
scenario reads) selects nothing;
|
||||
scenario reads; galaxy.yml by a rule in .gitea/workflows/AGENTS.md) selects nothing;
|
||||
* any other file selects every scenario.
|
||||
|
||||
A role uses another when any file under its directory names it as `mortis.kamino.<other>`
|
||||
@@ -62,6 +62,7 @@ IGNORED = (
|
||||
"changelogs/*",
|
||||
"LICENSES/*",
|
||||
"README.md",
|
||||
"galaxy.yml",
|
||||
"CONTRIBUTING.md",
|
||||
"SECURITY.md",
|
||||
"GLOSSARY.md",
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
# SPDX-FileCopyrightText: Defame1297 and contributors
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
"""Tests for scripts/check_scenarios_load_checkout.py with real molecule and ansible-config.
|
||||
|
||||
Run with: python3 -m unittest discover -s tests/scripts
|
||||
"""
|
||||
|
||||
import importlib.util
|
||||
import os
|
||||
import pathlib
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
import yaml
|
||||
|
||||
REPO = pathlib.Path(__file__).resolve().parents[2]
|
||||
SCRIPT = REPO / "scripts" / "check_scenarios_load_checkout.py"
|
||||
HAS_TOOLS = (
|
||||
importlib.util.find_spec("molecule") is not None
|
||||
and shutil.which("ansible-config", path=os.path.dirname(sys.executable)) is not None
|
||||
)
|
||||
NEEDS_TOOLS = "the check runs molecule's config and ansible-config"
|
||||
|
||||
|
||||
def collection(root):
|
||||
"""A mortis.kamino collection at <root>/ansible_collections/mortis/kamino."""
|
||||
path = root / "ansible_collections" / "mortis" / "kamino"
|
||||
path.mkdir(parents=True, exist_ok=True)
|
||||
(path / "galaxy.yml").write_text(
|
||||
"namespace: mortis\nname: kamino\nversion: 1.0.0\n"
|
||||
)
|
||||
return path
|
||||
|
||||
|
||||
@unittest.skipUnless(HAS_TOOLS, NEEDS_TOOLS)
|
||||
class CheckScenariosLoadCheckoutTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.tmp = pathlib.Path(tempfile.mkdtemp(prefix="kamino-loads-")).resolve()
|
||||
self.addCleanup(shutil.rmtree, self.tmp, True)
|
||||
self.ac_root = self.tmp / "ac"
|
||||
self.checkout = collection(self.ac_root)
|
||||
(self.checkout / "scripts").mkdir()
|
||||
shutil.copy(SCRIPT, self.checkout / "scripts")
|
||||
self.other = self.tmp / "other"
|
||||
collection(self.other)
|
||||
self.scenario("roles/alpha/molecule/default")
|
||||
self.scenario("extensions/molecule/image-smoke")
|
||||
self.env = {
|
||||
"PATH": f"{os.path.dirname(sys.executable)}:{os.environ['PATH']}",
|
||||
"HOME": str(self.tmp),
|
||||
"ANSIBLE_HOME": str(self.tmp / "ansible-home"),
|
||||
"ANSIBLE_COLLECTIONS_PATH": f"{self.ac_root}:{self.other}",
|
||||
}
|
||||
|
||||
def scenario(self, path, env=None):
|
||||
d = self.checkout / path
|
||||
d.mkdir(parents=True, exist_ok=True)
|
||||
config = {"driver": {"name": "default"}, "platforms": [{"name": "instance"}]}
|
||||
if env:
|
||||
config["provisioner"] = {"name": "ansible", "env": env}
|
||||
(d / "molecule.yml").write_text(yaml.safe_dump(config))
|
||||
return d
|
||||
|
||||
def run_check(self, selection="roles/alpha/molecule/default\n", **env):
|
||||
return subprocess.run(
|
||||
[sys.executable, "-I", str(self.checkout / "scripts" / SCRIPT.name)],
|
||||
cwd=self.checkout,
|
||||
env={**self.env, **env},
|
||||
input=selection,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=False,
|
||||
)
|
||||
|
||||
def assert_refused(self, result, found):
|
||||
self.assertEqual(result.returncode, 1, result.stdout + result.stderr)
|
||||
self.assertIn("::error::", result.stdout)
|
||||
self.assertIn("must load mortis.kamino from the checkout", result.stdout)
|
||||
self.assertIn(found, result.stdout)
|
||||
|
||||
def test_the_checkout_first_passes(self):
|
||||
result = self.run_check(
|
||||
"roles/alpha/molecule/default\nextensions/molecule/image-smoke\n"
|
||||
)
|
||||
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
|
||||
|
||||
def test_another_copy_first_fails(self):
|
||||
result = self.run_check(ANSIBLE_COLLECTIONS_PATH=f"{self.other}:{self.ac_root}")
|
||||
self.assert_refused(result, str(self.other))
|
||||
|
||||
def test_a_scenario_env_that_puts_another_copy_first_fails(self):
|
||||
# The inherited path is right; molecule's provisioner env is what ansible-playbook gets.
|
||||
self.scenario(
|
||||
"roles/alpha/molecule/default",
|
||||
env={"ANSIBLE_COLLECTIONS_PATH": str(self.other)},
|
||||
)
|
||||
self.assert_refused(self.run_check(), str(self.other))
|
||||
|
||||
def test_a_copy_next_to_the_playbooks_fails(self):
|
||||
# ansible-playbook searches the playbook's own collections/ directory first.
|
||||
d = self.checkout / "roles/alpha/molecule/default"
|
||||
collection(d / "collections")
|
||||
self.assert_refused(self.run_check(), str(d / "collections"))
|
||||
|
||||
def test_no_copy_on_the_paths_fails(self):
|
||||
result = self.run_check(ANSIBLE_COLLECTIONS_PATH=str(self.tmp / "empty"))
|
||||
self.assert_refused(result, "no mortis.kamino")
|
||||
|
||||
def test_the_failing_scenario_is_named(self):
|
||||
self.scenario(
|
||||
"extensions/molecule/image-smoke",
|
||||
env={"ANSIBLE_COLLECTIONS_PATH": str(self.other)},
|
||||
)
|
||||
result = self.run_check(
|
||||
"roles/alpha/molecule/default\nextensions/molecule/image-smoke\n"
|
||||
)
|
||||
self.assert_refused(result, "extensions/molecule/image-smoke")
|
||||
self.assertNotIn("roles/alpha/molecule/default", result.stdout)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -33,6 +33,13 @@ mkdir -p "$3/bin"
|
||||
cp "$STUB_SOURCE" "$3/bin/pip"
|
||||
"""
|
||||
|
||||
# The python that runs the load check: records its arguments, paths and stdin.
|
||||
CHECK_STUB = """#!/usr/bin/env bash
|
||||
echo "python3 args=$* acp=$ANSIBLE_COLLECTIONS_PATH stdin=[$(cat | tr '\\n' ' ')]" >> "$STUB_LOG"
|
||||
[ -n "${STUB_FAIL_check:-}" ] && exit 1
|
||||
exit 0
|
||||
"""
|
||||
|
||||
# The scenario runner: records its arguments, paths and stdin.
|
||||
RUNNER_STUB = """#!/usr/bin/env bash
|
||||
echo "runner args=$* path=$PATH acp=$ANSIBLE_COLLECTIONS_PATH stdin=[$(cat | tr '\\n' ' ')]" >> "$STUB_LOG"
|
||||
@@ -57,6 +64,8 @@ class RunMoleculeInCiImageTest(unittest.TestCase):
|
||||
stub.chmod(0o755)
|
||||
for name in ("sha256sum", "ansible-galaxy", "ansible", "molecule"):
|
||||
shutil.copy(stub, bin_dir / name)
|
||||
(bin_dir / "python3").write_text(CHECK_STUB)
|
||||
(bin_dir / "python3").chmod(0o755)
|
||||
python = self.tmp / "python"
|
||||
python.write_text(PYTHON_STUB)
|
||||
python.chmod(0o755)
|
||||
@@ -142,6 +151,25 @@ class RunMoleculeInCiImageTest(unittest.TestCase):
|
||||
runner,
|
||||
)
|
||||
|
||||
def test_the_load_check_sees_the_selection_and_the_final_path(self):
|
||||
selection = "roles/alpha/molecule/default\nextensions/molecule/image-smoke\n"
|
||||
result = self.run_script(selection, STUB_FAIL_sha256sum="1")
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
(check,) = self.calls("python3")
|
||||
self.assertIn("args=-I scripts/check_scenarios_load_checkout.py ", check)
|
||||
self.assertIn(
|
||||
f"acp={self.ac_root}:{self.pins}/collections:/opt/collections ", check
|
||||
)
|
||||
self.assertIn(
|
||||
"stdin=[roles/alpha/molecule/default extensions/molecule/image-smoke ]",
|
||||
check,
|
||||
)
|
||||
|
||||
def test_a_failing_load_check_runs_no_scenario(self):
|
||||
result = self.run_script(STUB_FAIL_check="1")
|
||||
self.assertNotEqual(result.returncode, 0)
|
||||
self.assertEqual(self.calls("runner"), [])
|
||||
|
||||
def test_a_failing_install_fails_the_run(self):
|
||||
for stub in ("python", "pip", "ansible-galaxy"):
|
||||
with self.subTest(stub=stub):
|
||||
|
||||
@@ -210,9 +210,14 @@ class SelectTest(unittest.TestCase):
|
||||
chosen, _reason = self.select(["docs/x.md", "roles/docker/tasks/main.yml"])
|
||||
self.assertEqual(chosen, ["roles/docker/molecule/default"])
|
||||
|
||||
def test_galaxy_yml_selects_nothing_and_does_not_mask_a_role(self):
|
||||
chosen, _reason = self.select(["galaxy.yml"])
|
||||
self.assertEqual(chosen, [])
|
||||
chosen, _reason = self.select(["galaxy.yml", "roles/docker/tasks/main.yml"])
|
||||
self.assertEqual(chosen, ["roles/docker/molecule/default"])
|
||||
|
||||
def test_anything_else_selects_everything(self):
|
||||
for path in (
|
||||
"galaxy.yml",
|
||||
"meta/runtime.yml",
|
||||
"plugins/modules/x.py",
|
||||
"extensions/molecule/requirements.yml",
|
||||
|
||||
Reference in new issue
Block a user