Make the main entry point reload Fail2Ban when jail.local changes, instead of restarting it. tasks/configure.yml notifies Restart Fail2Ban; the service_jail entry point already notifies Reload Fail2Ban.
Why
A restart stops every jail, which flushes its bans out of the firewall (they stay in Fail2Ban's database and are restored when the jail starts again), so for a moment banned addresses are not blocked, and failures counted toward maxretry are forgotten. A reload applies the new settings to the running jails and does neither (checked in the Fail2Ban 1.1.0 source: Jail.stop/restoreCurrentBans, Server.reloadJails). The role already treats this as the better behaviour: service_jail reloads, and the comment on the Reload Fail2Ban handler explains why. The main entry point is the odd one out, and every edit of jail.local (a new jail, a changed bantime, and the fail2ban_ignoreip option of #155 / #156) goes through it.
state: reloaded on the systemd module also starts the service when it is not running, so first installs still work.
(An earlier version of this text said a restart released every banned address. That was wrong; see the correction comment below.)
Proposed change
tasks/configure.yml notifies Reload Fail2Ban.
Keep the Restart Fail2Ban handler, marked deprecated: handler names are global in a play, so a role outside this collection that notifies it by name would otherwise fail with "handler not found". It can go in the next major release.
Keep fail2ban-client -t as the gate before the reload, as service_jail does. When the whole role runs, the test comes before the reload; with --tags fail2ban_configure only, service.yml does not run and the reload has no separate gate (fail2ban-client reload still rejects a bad config and keeps the old daemon running).
README, role notes and a changelog fragment (minor_changes) updated.
Molecule: side_effect.yml records the daemon's PID and bans an address, then rewrites jail.local with a different maxretry; verify.yml asserts the new value is active, the ban is in force and the PID is unchanged. The PID is what separates a reload from a restart: bans are restored from the database, so the ban alone proves nothing.
Open question
Does any jail.local setting only take effect after a restart? The role only writes jail sections and (with #156) [DEFAULT] ignoreip, none of the server-level settings (loglevel, dbfile) that live in fail2ban.local, so I expect not. Please say if you know of one.
Ordering
It touches the same files as #156, so I will open the PR after #156 is merged.
## What
Make the main entry point reload Fail2Ban when `jail.local` changes, instead of restarting it. `tasks/configure.yml` notifies `Restart Fail2Ban`; the `service_jail` entry point already notifies `Reload Fail2Ban`.
## Why
A restart stops every jail, which flushes its bans out of the firewall (they stay in Fail2Ban's database and are restored when the jail starts again), so for a moment banned addresses are not blocked, and failures counted toward `maxretry` are forgotten. A reload applies the new settings to the running jails and does neither (checked in the Fail2Ban 1.1.0 source: `Jail.stop`/`restoreCurrentBans`, `Server.reloadJails`). The role already treats this as the better behaviour: `service_jail` reloads, and the comment on the `Reload Fail2Ban` handler explains why. The main entry point is the odd one out, and every edit of `jail.local` (a new jail, a changed `bantime`, and the `fail2ban_ignoreip` option of #155 / #156) goes through it.
`state: reloaded` on the systemd module also starts the service when it is not running, so first installs still work.
(An earlier version of this text said a restart released every banned address. That was wrong; see the correction comment below.)
## Proposed change
- `tasks/configure.yml` notifies `Reload Fail2Ban`.
- Keep the `Restart Fail2Ban` handler, marked deprecated: handler names are global in a play, so a role outside this collection that notifies it by name would otherwise fail with "handler not found". It can go in the next major release.
- Keep `fail2ban-client -t` as the gate before the reload, as `service_jail` does. When the whole role runs, the test comes before the reload; with `--tags fail2ban_configure` only, `service.yml` does not run and the reload has no separate gate (`fail2ban-client reload` still rejects a bad config and keeps the old daemon running).
- README, role notes and a changelog fragment (`minor_changes`) updated.
- Molecule: `side_effect.yml` records the daemon's PID and bans an address, then rewrites `jail.local` with a different `maxretry`; `verify.yml` asserts the new value is active, the ban is in force and the PID is unchanged. The PID is what separates a reload from a restart: bans are restored from the database, so the ban alone proves nothing.
## Open question
Does any `jail.local` setting only take effect after a restart? The role only writes jail sections and (with #156) `[DEFAULT] ignoreip`, none of the server-level settings (`loglevel`, `dbfile`) that live in `fail2ban.local`, so I expect not. Please say if you know of one.
## Ordering
It touches the same files as #156, so I will open the PR after #156 is merged.
Correction to the rationale in this issue. I wrote that a restart "clears Fail2Ban's in-memory ban list" and "releases every host that is currently banned". That is wrong for a default setup. I took it from the comment on the Reload Fail2Ban handler and did not check it; I have now read the Fail2Ban 1.1.0 source:
Stopping a jail flushes its bans out of the firewall but keeps them in the database (dbfile, default /var/lib/fail2ban/fail2ban.sqlite3).
Starting a jail calls restoreCurrentBans() (jail.py), which puts the unexpired bans back (and skips addresses that are now ignored).
A reload (reloadJails) applies the new settings to the running jails and only unbans or restarts when asked (--unban, --restart).
So the real cost of a restart is smaller than I said: for a moment banned addresses are not blocked, and failures counted toward maxretry are forgotten. The change is still worth making (the main entry point is the odd one out next to service_jail, and a reload has neither effect), but the issue should not claim that bans are lost. I am fixing the same wording in the handler comment, the README and the changelog fragment in the PR.
Two consequences for the proposal, both now in the issue body:
The test cannot use the ban to tell reload from restart, because the ban comes back from the database. It compares the daemon's PID before and after instead (a restart starts a new process, a reload does not).
The Restart Fail2Ban handler is kept, deprecated, so a role outside this collection that notifies it by name does not fail with "handler not found".
You labelled this Reviewed/Confirmed on the earlier text. If the corrected reasoning changes your view, please say so here.
Assisted-by: Claude Code
**Correction to the rationale in this issue.** I wrote that a restart "clears Fail2Ban's in-memory ban list" and "releases every host that is currently banned". That is wrong for a default setup. I took it from the comment on the `Reload Fail2Ban` handler and did not check it; I have now read the Fail2Ban 1.1.0 source:
- Stopping a jail flushes its bans out of the firewall but keeps them in the database (`dbfile`, default `/var/lib/fail2ban/fail2ban.sqlite3`).
- Starting a jail calls `restoreCurrentBans()` (`jail.py`), which puts the unexpired bans back (and skips addresses that are now ignored).
- A reload (`reloadJails`) applies the new settings to the running jails and only unbans or restarts when asked (`--unban`, `--restart`).
So the real cost of a restart is smaller than I said: for a moment banned addresses are not blocked, and failures counted toward `maxretry` are forgotten. The change is still worth making (the main entry point is the odd one out next to `service_jail`, and a reload has neither effect), but the issue should not claim that bans are lost. I am fixing the same wording in the handler comment, the README and the changelog fragment in the PR.
Two consequences for the proposal, both now in the issue body:
- The test cannot use the ban to tell reload from restart, because the ban comes back from the database. It compares the daemon's PID before and after instead (a restart starts a new process, a reload does not).
- The `Restart Fail2Ban` handler is kept, deprecated, so a role outside this collection that notifies it by name does not fail with "handler not found".
You labelled this `Reviewed/Confirmed` on the earlier text. If the corrected reasoning changes your view, please say so here.
Assisted-by: Claude Code
Handler names are not part of a role's interface: a caller never notifies a role's handler, and renaming or removing one needs no fragment. So Restart Fail2Ban does not need to be kept as deprecated for outside notifiers. Remove it if nothing in the role notifies it after this change. The minor_changes fragment for the reload behaviour stays.
## Decided by [Role interface and semver: output facts, handler names, dropped platforms and internal roles](https://git.rkdr.net/Mortis/Kamino/issues/257) (2026-11-20)
Handler names are not part of a role's interface: a caller never notifies a role's handler, and renaming or removing one needs no fragment. So `Restart Fail2Ban` does not need to be kept as deprecated for outside notifiers. Remove it if nothing in the role notifies it after this change. The `minor_changes` fragment for the reload behaviour stays.
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
Make the main entry point reload Fail2Ban when
jail.localchanges, instead of restarting it.tasks/configure.ymlnotifiesRestart Fail2Ban; theservice_jailentry point already notifiesReload Fail2Ban.Why
A restart stops every jail, which flushes its bans out of the firewall (they stay in Fail2Ban's database and are restored when the jail starts again), so for a moment banned addresses are not blocked, and failures counted toward
maxretryare forgotten. A reload applies the new settings to the running jails and does neither (checked in the Fail2Ban 1.1.0 source:Jail.stop/restoreCurrentBans,Server.reloadJails). The role already treats this as the better behaviour:service_jailreloads, and the comment on theReload Fail2Banhandler explains why. The main entry point is the odd one out, and every edit ofjail.local(a new jail, a changedbantime, and thefail2ban_ignoreipoption of #155 / #156) goes through it.state: reloadedon the systemd module also starts the service when it is not running, so first installs still work.(An earlier version of this text said a restart released every banned address. That was wrong; see the correction comment below.)
Proposed change
tasks/configure.ymlnotifiesReload Fail2Ban.Restart Fail2Banhandler, marked deprecated: handler names are global in a play, so a role outside this collection that notifies it by name would otherwise fail with "handler not found". It can go in the next major release.fail2ban-client -tas the gate before the reload, asservice_jaildoes. When the whole role runs, the test comes before the reload; with--tags fail2ban_configureonly,service.ymldoes not run and the reload has no separate gate (fail2ban-client reloadstill rejects a bad config and keeps the old daemon running).minor_changes) updated.side_effect.ymlrecords the daemon's PID and bans an address, then rewritesjail.localwith a differentmaxretry;verify.ymlasserts the new value is active, the ban is in force and the PID is unchanged. The PID is what separates a reload from a restart: bans are restored from the database, so the ban alone proves nothing.Open question
Does any
jail.localsetting only take effect after a restart? The role only writes jail sections and (with #156)[DEFAULT] ignoreip, none of the server-level settings (loglevel,dbfile) that live infail2ban.local, so I expect not. Please say if you know of one.Ordering
It touches the same files as #156, so I will open the PR after #156 is merged.
Correction to the rationale in this issue. I wrote that a restart "clears Fail2Ban's in-memory ban list" and "releases every host that is currently banned". That is wrong for a default setup. I took it from the comment on the
Reload Fail2Banhandler and did not check it; I have now read the Fail2Ban 1.1.0 source:dbfile, default/var/lib/fail2ban/fail2ban.sqlite3).restoreCurrentBans()(jail.py), which puts the unexpired bans back (and skips addresses that are now ignored).reloadJails) applies the new settings to the running jails and only unbans or restarts when asked (--unban,--restart).So the real cost of a restart is smaller than I said: for a moment banned addresses are not blocked, and failures counted toward
maxretryare forgotten. The change is still worth making (the main entry point is the odd one out next toservice_jail, and a reload has neither effect), but the issue should not claim that bans are lost. I am fixing the same wording in the handler comment, the README and the changelog fragment in the PR.Two consequences for the proposal, both now in the issue body:
Restart Fail2Banhandler is kept, deprecated, so a role outside this collection that notifies it by name does not fail with "handler not found".You labelled this
Reviewed/Confirmedon the earlier text. If the corrected reasoning changes your view, please say so here.Assisted-by: Claude Code
Decided by Role interface and semver: output facts, handler names, dropped platforms and internal roles (2026-11-20)
Handler names are not part of a role's interface: a caller never notifies a role's handler, and renaming or removing one needs no fragment. So
Restart Fail2Bandoes not need to be kept as deprecated for outside notifiers. Remove it if nothing in the role notifies it after this change. Theminor_changesfragment for the reload behaviour stays.