fail2ban, A Ban That Exists In The Kernel
fail2ban from EPEL on EL 10, banning into nftables, with the jails and the server settings as .local files beside the package's own. The live test drives a jail past its limit and reads the ban out of nft rather than out of a status page, unbans it and reads the rule's absence, and checks that the same burst from an address in ignoreip is never banned. Original role, live-tested on Rocky Linux 10.
Verification
Live-testedReally deployed to a container sandbox, proven idempotent (a second run changes nothing), verified against the role’s assertions, then torn down.
Conformance
- Static validation (yamllint · ansible-lint)
Provenance
- SHA-256 checksum
- Signature (pending)
Functional
- Live-tested - applied, verified, destroyed
Last verified 2026-09-26 · podman 4.9.3 · ansible 2.21.4 · how we verify
Cite it in your README
badge · attributionPaste this beside the module in the repository that uses it. The badge is rendered from this artifact's verification record, so it reads live-tested because the record says so, and the link lands on this page.
[](https://www.iac-bazaar.com/catalog/ansible-fail2ban?utm_source=syndication&utm_medium=readme&utm_campaign=artifact)
Ansible role 1.0.0, live-tested on IaC Bazaar: [fail2ban, A Ban That Exists In The Kernel](https://www.iac-bazaar.com/catalog/ansible-fail2ban?utm_source=syndication&utm_medium=readme&utm_campaign=artifact)
```yaml
# fail2ban, A Ban That Exists In The Kernel: https://www.iac-bazaar.com/catalog/ansible-fail2ban (download from your IaC Bazaar account)
```Preview:
Documentation
fail2ban
Bans that exist in the kernel, not just in a status page. The role installs
fail2ban with the nftables action, writes the server settings and the jails as
.local files beside the package's own, and enables the unit the distribution
ships. The live test drives a jail past its limit and then reads the ban out of
nft, unbans it, and reads the rule's absence.
No download, and no version to pin. fail2ban is packaged in EPEL, so the role enables the repository and installs it by name, taking the filters and the unit the distribution ships. What the role owns is the policy: which jails, how many tries, how long a ban lasts, who is never banned, and the proof that a ban reaches the kernel.
.local, never the package's .conf. fail2ban is designed to be configured
in jail.local and fail2ban.local, which the package's files include: an
upgrade replaces jail.conf and leaves this role's policy untouched. The filters
are the package's own, so a fail2ban update improves them without a new release
of this role.
The live test needs CAP_NET_ADMIN. The container the lane boots carries
it, and without it the kernel refuses the very call this role exists to make,
so the test would pass having changed nothing. The lane is therefore run as
live-ansible.sh ... --cap-add=NET_ADMIN, and the receipt records it: a pass
under an added capability is not the same claim as a pass without one.
The sshd jail reads the journal, and that is correct. The package's
jail.conf sets the sshd jail's backend to systemd, which is where sshd on EL 10
logs; /var/log/secure exists only on a host that also runs rsyslog, so a jail
pointed at it would silently watch an empty file. This role leaves that alone,
and proves the filter with the tool fail2ban ships for it: fail2ban-regex
against a real failure line reports "1 matched, 0 missed".
The ban path is driven through the recidive jail, which reads fail2ban's own
log and is therefore file-backed. It is a jail worth having in its own right - it
catches the addresses that come back after a ban expires - and it exercises the
same filter, jail, action and unban path as every other jail.
A log line without a date is invisible to fail2ban. The jail reads the file, matches nothing, and reports a healthy zero, which looks identical to "no attacks yet". The live test dates every line it injects for exactly this reason.
The ban is asserted in the kernel and after the unban. A jail's own counter
moving proves fail2ban decided to ban; it does not prove anything reached
netfilter. The verify reads nft -j list ruleset for the address in
f2b-table, and then checks the unban removed it - a released address that
stays blocked is the failure nobody notices.
The ignore configuration is tested through the filter, not through banip. A
manual fail2ban-client set <jail> banip bans an address in ignoreip anyway,
so it proves nothing. The live test writes the same burst for 127.0.0.1 into
the watched log and asserts no ban appears - that is what decides whether a fleet
rollout locks out the operator who performed it.
There are TWO settings doing that work, and a mutation check found it.
Removing 127.0.0.1/8 from ignoreip changes nothing on its own, because
ignoreself still covers every address the host holds. Both are variables here,
and the test's control turns off both: a claim that only one of them protects the
operator would have been untrue.
License
Commercial - IaC Bazaar EULA. (c) IaC Bazaar.
Usage code & full reference need an account
The complete copy-paste usage, the full input/output reference, and operational notes are free with an account - shown here and bundled in the download. Sign in and this section fills in.
- Variables
- Test
Related modules
ansible-lynis
Lynis from EPEL on a systemd timer, with the units the package keeps only in its docs, your skipped tests in custom.prf, and a minimum hardening index below which the audit unit fails, so a falling score shows as a failed unit. The live test runs the audit, reads the index and the tests that ran, and finds the timer enabled. Original role, live-tested on Rocky Linux 10.
ansible-suricata
Suricata from EPEL watching the default-route interface as the suricata user, ET Open fetched at install and refreshed daily, plus a canary rule that proves the sensor is alive. A root-run check left root-owned logs and a daemon recording nothing; the role prevents it. The live test raises the canary alert while a second lookup is logged, not alerted. Original role, live-tested on Rocky Linux 10.
ansible-aide
AIDE from AppStream on EL 10: a watched tree, a baseline database built once, and the oneshot unit and timer the package does not ship. The live test passes on an unchanged host, FAILS when a file appears inside a watched path and names it, ignores one inside an excluded path, and passes again once the change is gone. Original role, live-tested on Rocky Linux 10.
ansible-389-ds
389 Directory Server from AppStream. A fresh instance listens on every interface and lets anonymous clients read the tree; this role binds both listeners to loopback and limits anonymous clients to the rootDSE. The live test adds a user who binds, sees a wrong password and an anonymous search refused, and reads the LDAPS certificate. Original role, live-tested on Rocky Linux 10.
ansible-krb5-kdc
An MIT Kerberos KDC: the realm created once with a stash, kadmind behind an ACL, a default policy that locks an account after five wrong passwords, every listener on loopback. The KDC starts on a broken config without a word, so the live test proves each setting by behaviour: the ticket lifetime, the refusals, the lockout. Original role, live-tested on Rocky Linux 10.
ansible-authelia
Authelia from the upstream release (sha256-verified) as a hardened system service on loopback with file users and sqlite; its secrets are generated once on the host and reach the service as AUTHELIA_*_FILE variables. The live test hashes a password with Authelia's hasher, logs in, sees a wrong password refused and an anonymous visitor sent to the portal. Original role, live-tested on Rocky 10.