feat(fail2ban): add fail2ban_ignoreip to exempt trusted addresses #156

Merged
Defame1297 merged 6 commits from feat/fail2ban-ignoreip into main 2026-11-15 17:31:40 +00:00
6 Commits
Author SHA1 Message Date
Dragonish 9dcb933bf9 test(fail2ban): match the validation message in the ignoreip rejection cases
Build / build (pull_request) Successful in 13s
Lint / lint (pull_request) Successful in 28s
Molecule / molecule (pull_request) Successful in 1m2s
The three rejection cases only printed "Rejected as expected", so they would
also pass when the role failed for another reason. Assert that the failure
carries the validation message of fail2ban_ignoreip.

Assisted-by: Claude Code
2026-11-15 13:35:14 +00:00
Dragonish 0703ab85dc Merge remote-tracking branch 'origin/feat/fail2ban-ignoreip' into feat/fail2ban-ignoreip 2026-11-15 13:33:44 +00:00
Defame1297 9f0e0bda85 Merge branch 'main' into feat/fail2ban-ignoreip
Build / build (pull_request) Successful in 11s
Lint / lint (pull_request) Successful in 26s
Molecule / molecule (pull_request) Successful in 51s
2026-11-15 13:26:55 +00:00
Dragonish 2b994363d7 fix(fail2ban): refuse a scalar or non-string fail2ban_ignoreip
argument_specs accepts a plain string for a list option and leaves it a string,
and accepts a list holding a number or null. The pattern check then iterated a
string per character and rendered "1 . 2 . 3 . 4", or died with a TypeError on
null. Check the type first (assert stops at the first false item).

Also refuse ";" and "%" in an entry: Fail2Ban's config parser treats ";" after
whitespace as an inline comment, which drops the rest of the ignoreip line
without an error, and "%" as interpolation syntax, which fails the whole config
after jail.local is written. Add Molecule cases for a scalar string and a
semicolon entry.

Document what review found: service_jail does not read the variable, the
[DEFAULT] value replaces an ignoreip set in jail.conf or jail.d/*.conf, a failed
hostname lookup leaves the entry ineffective with a log warning (addresses and
networks are safer), and --tags fail2ban_configure skips the validation.

Assisted-by: Claude Code
2026-11-15 13:20:43 +00:00
Defame1297 d77b3778cd Merge branch 'main' into feat/fail2ban-ignoreip
Build / build (pull_request) Successful in 10s
Lint / lint (pull_request) Successful in 25s
Molecule / molecule (pull_request) Successful in 51s
2026-11-15 12:39:51 +00:00
DragonishandClaude Sonnet 5.5 57b15df1ac feat(fail2ban): add fail2ban_ignoreip to exempt trusted addresses
Build / build (pull_request) Successful in 11s
Lint / lint (pull_request) Successful in 26s
Molecule / molecule (pull_request) Successful in 52s
Write fail2ban_ignoreip as ignoreip in the [DEFAULT] section of jail.local, so
it applies to every jail, the service jails in jail.d included. The default is
Fail2Ban's own (127.0.0.1/8 and ::1). Entries are validated (no whitespace,
\Z-anchored) because they are joined into one line.

The first run after upgrading adds the [DEFAULT] section and restarts Fail2Ban
once.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Q72rsMCgwaR1sbYZangwbp
2026-11-15 11:55:17 +00:00