The main entry point notified a restart. A restart stops every jail, which flushes its bans out of the firewall until they are restored from Fail2Ban's database when the jail starts again, and forgets failures counted toward maxretry. A reload applies the new settings to the running jails. service_jail already reloads. The Restart Fail2Ban handler is removed: nothing notifies it any more, and a handler name is not part of the role's interface (#257). A new side_effect.yml bans an address, records the daemon's PID and rewrites jail.local; verify asserts the new maxretry is active, the ban is in force and the PID is unchanged (the PID is what separates a reload from a restart, since bans are restored from the database). Assisted-by: Claude Code
14 lines
928 B
YAML
14 lines
928 B
YAML
---
|
|
# The main entry point and service_jail both reload instead of restarting the daemon. 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. state=reloaded starts the service if it is not running. The configuration test
|
|
# (`fail2ban-client -t`) runs as a task in service.yml and service_jail.yml, so a broken file fails every run of the full role
|
|
# instead of only the one that wrote it, and when the whole role runs it comes before this handler (with only the configure tag it
|
|
# does not, and the reload itself rejects a bad configuration).
|
|
- name: Reload Fail2Ban
|
|
become: true
|
|
ansible.builtin.systemd:
|
|
name: fail2ban
|
|
state: reloaded
|