In check mode the package install reports changed, but nothing is installed, so later tasks that need the binary or its config failed on a fresh host.
fail2ban
The install is registered as __fail2ban_install.
These are skipped with not ansible_check_mode or __fail2ban_install | default({}) is not changed:
the jail.local, filter and jail templates;
both fail2ban-client -t tests;
the systemd task;
the jail-status loop;
the Reload handler.
flush_handlers stays unguarded, because nothing is notified once those tasks skip.
ufw
The install is registered as __ufw_install. A command: "true" check-mode probe follows it, the same pattern as sysctl.yml, because ansible_check_mode is not set for a play-level check_mode inside include_role.
A set_fact right after the probe gives __ufw_can_configure. It guards before.rules, the default policies, the rules and enable. Guards read it with default(true), so a run that skips the install by tags behaves as before.
The service_rules entry point already passes, because its ufw status has failed_when: false and its assert skips in check mode. The new scenario exercises it.
Docs, changelog and tests
Both READMEs drop the "--check fails without the package" limit. They keep "play-level check_mode: true is not supported" and say a preview on a fresh host skips configuration.
A bugfix changelog fragment is added.
There are two new scenarios, roles/ufw/molecule/check-absent and roles/fail2ban/molecule/check-absent, each running dependency, create, prepare and check. Prepare purges the package and refreshes APT. There is one per role, because a shared scenario would make the selector count ufw as a consumer of fail2ban.
This unblocks #435, which stops baking ufw and fail2ban into the Molecule images.
Verified
pre-commit run --all-files passes, ansible-lint included.
ansible-playbook --syntax-check passes on the new converge and prepare playbooks.
The ufw check-absent converge run locally with --check on a host without ufw gave failed=0.
Two clean-context review rounds traced every task of both roles. The first found no blocking issues; I applied three of its notes:
the computed fact moved out of vars/;
service_rules was checked;
a misplaced comment was moved.
CI: this pull request's Molecule run covers the new scenarios and the existing ones, idempotence included.
Not verified
The new scenarios, and the default scenarios' idempotence, have run only in CI.
The probe depends on the command module reporting skipped in check mode. ansible-core plans to change that in 2.25. sysctl.yml already relies on it.
I confirm third-party material is recorded in NOTICE and REUSE.toml, or there is none.
Assisted-by: Claude Code
## What and why
Closes #478
In check mode the package install reports changed, but nothing is installed, so later tasks that need the binary or its config failed on a fresh host.
**fail2ban**
- The install is registered as `__fail2ban_install`.
- These are skipped with `not ansible_check_mode or __fail2ban_install | default({}) is not changed`:
- the `jail.local`, filter and jail templates;
- both `fail2ban-client -t` tests;
- the systemd task;
- the jail-status loop;
- the Reload handler.
- `flush_handlers` stays unguarded, because nothing is notified once those tasks skip.
**ufw**
- The install is registered as `__ufw_install`. A `command: "true"` check-mode probe follows it, the same pattern as `sysctl.yml`, because `ansible_check_mode` is not set for a play-level `check_mode` inside `include_role`.
- A `set_fact` right after the probe gives `__ufw_can_configure`. It guards `before.rules`, the default policies, the rules and enable. Guards read it with `default(true)`, so a run that skips the install by tags behaves as before.
- The `service_rules` entry point already passes, because its `ufw status` has `failed_when: false` and its assert skips in check mode. The new scenario exercises it.
**Docs, changelog and tests**
- Both READMEs drop the "--check fails without the package" limit. They keep "play-level `check_mode: true` is not supported" and say a preview on a fresh host skips configuration.
- A bugfix changelog fragment is added.
- There are two new scenarios, `roles/ufw/molecule/check-absent` and `roles/fail2ban/molecule/check-absent`, each running dependency, create, prepare and check. Prepare purges the package and refreshes APT. There is one per role, because a shared scenario would make the selector count ufw as a consumer of fail2ban.
This unblocks #435, which stops baking ufw and fail2ban into the Molecule images.
## Verified
- `pre-commit run --all-files` passes, ansible-lint included.
- `python -m unittest discover -s tests/scripts` passes.
- `ansible-playbook --syntax-check` passes on the new converge and prepare playbooks.
- The ufw check-absent converge run locally with `--check` on a host without ufw gave `failed=0`.
- Two clean-context review rounds traced every task of both roles. The first found no blocking issues; I applied three of its notes:
- the computed fact moved out of `vars/`;
- `service_rules` was checked;
- a misplaced comment was moved.
- CI: this pull request's Molecule run covers the new scenarios and the existing ones, idempotence included.
## Not verified
- The new scenarios, and the default scenarios' idempotence, have run only in CI.
- The probe depends on the command module reporting `skipped` in check mode. ansible-core plans to change that in 2.25. `sysctl.yml` already relies on it.
---
- [x] I confirm third-party material is recorded in `NOTICE` and `REUSE.toml`, or there is none.
Assisted-by: Claude Code
Claude
added this to the CI velocity (emergency) milestone 2026-11-29 17:44:06 +00:00
Under --check the package task only reports a change, so on a fresh host
the tasks after it ran against a missing binary, /etc directory or unit
and failed. They now skip when the install would change in check mode.
fail2ban registers __fail2ban_install and guards its template, service,
config test, jail tasks and handler with the standard
`not ansible_check_mode or ... is not changed` guard. ufw registers
__ufw_install plus a command probe (ansible_check_mode is not set for a
play-level check_mode inside include_role), combined once in vars/main.yml
as __ufw_can_configure. flush_handlers is left unguarded: the handler it
runs is guarded itself.
A check-absent scenario per role purges the package, refreshes the APT
cache and runs only `check`, so each fix is tested; one scenario covering
both would make the ufw role a user of fail2ban and select the ufw and
traefik scenarios on every fail2ban change.
Fixes#478
Assisted-by: Claude Code
vars/ holds constants only, so ufw's __ufw_can_configure is now a
set_fact after the install probe; the guards default it to true when the
install tasks were skipped by tags.
service_rules already skips its reconcile when `ufw status` fails under
check mode; the ufw check-absent scenario now calls it so CI holds that.
The fail2ban service jail task's tags sit with the task again, above the
comment of the configuration test.
Refs #478
Assisted-by: Claude Code
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
What and why
Closes #478
In check mode the package install reports changed, but nothing is installed, so later tasks that need the binary or its config failed on a fresh host.
fail2ban
__fail2ban_install.not ansible_check_mode or __fail2ban_install | default({}) is not changed:jail.local, filter and jail templates;fail2ban-client -ttests;flush_handlersstays unguarded, because nothing is notified once those tasks skip.ufw
__ufw_install. Acommand: "true"check-mode probe follows it, the same pattern assysctl.yml, becauseansible_check_modeis not set for a play-levelcheck_modeinsideinclude_role.set_factright after the probe gives__ufw_can_configure. It guardsbefore.rules, the default policies, the rules and enable. Guards read it withdefault(true), so a run that skips the install by tags behaves as before.service_rulesentry point already passes, because itsufw statushasfailed_when: falseand its assert skips in check mode. The new scenario exercises it.Docs, changelog and tests
check_mode: trueis not supported" and say a preview on a fresh host skips configuration.roles/ufw/molecule/check-absentandroles/fail2ban/molecule/check-absent, each running dependency, create, prepare and check. Prepare purges the package and refreshes APT. There is one per role, because a shared scenario would make the selector count ufw as a consumer of fail2ban.This unblocks #435, which stops baking ufw and fail2ban into the Molecule images.
Verified
pre-commit run --all-filespasses, ansible-lint included.python -m unittest discover -s tests/scriptspasses.ansible-playbook --syntax-checkpasses on the new converge and prepare playbooks.--checkon a host without ufw gavefailed=0.vars/;service_ruleswas checked;Not verified
skippedin check mode. ansible-core plans to change that in 2.25.sysctl.ymlalready relies on it.NOTICEandREUSE.toml, or there is none.Assisted-by: Claude Code