fix(roles): apply review findings to the check-mode change
Guard gitea_runner's docker group membership like its Docker start, run user_management's getent probe unconditionally, and state the play-level check_mode limit in every touched README. The check-mode rule now allows the pihole guard form and names roles whose --check needs their package installed. Assisted-by: Claude Code
This commit is contained in:
1 parent
cf2286b7a7
commit
3afff00b9b
8 files changed
+17
-7
No files matched your search
@@ -110,7 +110,8 @@ issue.
|
||||
*Why:* a pull request that raises the ansible-core floor must run its scenarios on the new core
|
||||
before it automerges. *Held:* control: the pin comparison in `molecule.yml`.
|
||||
- **Every scenario sets `scenario.test_sequence` to molecule's default minus both `destroy`
|
||||
steps, with a role scenario's `check` right before and right after `converge`, names each platform `${KAMINO_RUN_ID:-local}-<name>` and labels it
|
||||
steps, with a role scenario's `check` right before and right after `converge`, names each
|
||||
platform `${KAMINO_RUN_ID:-local}-<name>` and labels it
|
||||
`net.rkdr.mortis.molecule-run: "${KAMINO_RUN_ID:-local}"` in its `molecule.yml`;** copy it into
|
||||
a new scenario. *Why:* the run script removes each scenario's containers by those names as soon
|
||||
as it ends, which skips the driver's destroy wait, the workflow finds a run's containers by the
|
||||
|
||||
+6
-3
@@ -96,9 +96,12 @@ names a check that does not exist yet and its backlog issue.
|
||||
block/rescue/assert matching the expected error message, run last or failing before any
|
||||
change. *Why:* a bare "it failed" passes for the wrong error. *Held:* review.
|
||||
- **Check mode.** Every scenario runs `check` before and after converge. The only guards are
|
||||
`check_mode: false` on read-only probes and `when: not ansible_check_mode`; `--check` is the
|
||||
supported preview, and the README says a play-level `check_mode: true` is not supported. A role
|
||||
that cannot support check mode says why in README Notes and drops the step. *Why:* check-mode
|
||||
`check_mode: false` on read-only probes and `when: not ansible_check_mode`, alone or as
|
||||
`not ansible_check_mode or <condition>` where the condition shows the task can run, such as a
|
||||
registered result that is not changed; `--check` is the supported preview, and the README says
|
||||
a play-level `check_mode: true` is not supported. A role whose `--check` needs its package
|
||||
installed says so in README Notes and keeps the step; a role that cannot support check mode at
|
||||
all says why there and drops the step, with an exception in the test below. *Why:* check-mode
|
||||
breakage is a frequent fix, and one guard pattern is reviewable. *Held:* Molecule for the run
|
||||
passing, `tests/scripts/test_run_molecule_scenarios.py` for the steps being there; review for
|
||||
the guards.
|
||||
|
||||
@@ -36,6 +36,8 @@
|
||||
name: "{{ gitea_runner_user }}"
|
||||
groups: docker
|
||||
append: true
|
||||
# Under --check a new docker.io creates no docker group, and user fails on a missing group.
|
||||
when: not ansible_check_mode or __gitea_runner_docker_package is not changed
|
||||
tags: [gitea_runner, docker, install]
|
||||
|
||||
# Pulls ubuntu:24.04 from Docker Hub. Also proves Docker runs inside a container host
|
||||
|
||||
@@ -76,5 +76,5 @@ It does not test `ifreload`, so no Debian release or `ifupdown2` version is veri
|
||||
- On change the order is: copy the current file to `network_interfaces_backup`, write the new file (notifies `Reload Interfaces`), run the validate command, flush handlers. Any failure in that block restores the backup and fails with "Invalid network configuration detected. Previous config restored." The restore does not reload the interfaces.
|
||||
- The validate command runs after the file is written, and the reload runs right after it. A configuration that passes validation but breaks connectivity is not detected.
|
||||
- With `method: static`, `address` and `netmask` are required by the template.
|
||||
- Check mode: under `--check` the new file is not written, so the validate command and the reload are skipped; the preview shows whether the file would change, not whether it is valid.
|
||||
- Check mode: `--check` is the supported preview; a play-level `check_mode: true` is not supported. Under `--check` the new file is not written, so the validate command and the reload are skipped; the preview shows whether the file would change, not whether it is valid.
|
||||
- `no_log` is not used: the role handles no secrets.
|
||||
@@ -57,6 +57,7 @@ Only `always` (the `systemd_hardening_system_type` assert) works as intended. `d
|
||||
## Notes
|
||||
|
||||
- Idempotent: yes.
|
||||
- Check mode: `--check` is the supported preview; a play-level `check_mode: true` is not supported.
|
||||
- Every name in `systemd_hardening_disable_services` and `systemd_hardening_mask_services` is looked up as a socket and as a service, with or without the `.service` or `.socket` suffix. Only units that systemd has a unit file for (`LoadState` is not `not-found`) are disabled or masked, the socket first: a stopped service whose socket still listens is started again by the next connection. A name with only a service, only a socket, or neither is fine. The role asks about the listed units only, with one `systemctl show`, and does not list every unit file. A template name such as `[email protected]` is not supported: that call fails.
|
||||
- `systemctl disable` does nothing for a static unit (one with no `[Install]` section), so the systemd module can report `changed` on every run for it; list only names whose units can be enabled, and note that this now applies to a listed name's socket as well.
|
||||
- The manager drop-in (`DefaultLimitNOFILE`, `DefaultLimitNPROC`, `DefaultLimitCORE`, and task, memory and CPU accounting) is written verbatim by `tasks/harden_manager.yml` and has no variable.
|
||||
|
||||
+1
-1
@@ -156,5 +156,5 @@ Not covered: `ufw_before_rules` entries and `ufw_sysctl_overrides` are never set
|
||||
- Rule schema is asserted before anything changes: `rule` must be allow, deny, reject or limit, `port` a positive integer, `proto` tcp or udp, and each rule needs `port`, `from`, `to` or `interface`.
|
||||
- UFW is only re-enabled when `ufw status verbose` shows it inactive or the logging line differs, because the module rewrites rules and re-applies sysctl on every call.
|
||||
- The `Reload UFW` handler runs `ufw reload`.
|
||||
- Check mode: `--check` previews a host where ufw is already installed. On a host without ufw it fails at the default policy tasks: the package is not installed under `--check`, and the module needs the `ufw` binary.
|
||||
- Check mode: `--check` previews a host where ufw is already installed; a play-level `check_mode: true` is not supported. On a host without ufw it fails at the default policy tasks: the package is not installed under `--check`, and the module needs the `ufw` binary.
|
||||
- `no_log` is not used: the role handles no secrets.
|
||||
@@ -18,7 +18,6 @@
|
||||
- name: Read the existing users for the check-mode preview
|
||||
ansible.builtin.getent:
|
||||
database: passwd
|
||||
when: ansible_check_mode
|
||||
|
||||
- name: Enforce authorized_keys authoritatively
|
||||
become: true
|
||||
|
||||
@@ -395,6 +395,10 @@ class ScenarioPlatformsTest(unittest.TestCase):
|
||||
seen[name] = where
|
||||
self.assertNotIn("destroy", data["scenario"]["test_sequence"], path)
|
||||
|
||||
|
||||
class ScenarioSequenceTest(unittest.TestCase):
|
||||
"""A role scenario previews the fresh host and the configured host with molecule's check step."""
|
||||
|
||||
def test_role_scenarios_run_check_before_and_after_converge(self):
|
||||
# A check-only scenario has no converge to surround, so it is not held to this.
|
||||
files = sorted(REPO.glob("roles/*/molecule/*/molecule.yml"))
|
||||
|
||||
Reference in new issue
Block a user