Files
Kamino/roles/fail2ban/meta/argument_specs.yml
T
Defame1297andClaude Sonnet 5.5 1ea478b124
Build / build (pull_request) Successful in 23s
Lint / lint (pull_request) Successful in 16s
Molecule / molecule (pull_request) Successful in 3m11s
feat(fail2ban): add the fail2ban role
Copied from the environment repository's roles/fail2ban and scrubbed for the
Collection: galaxy namespace mortis, the molecule scenario calls the role by
its FQCN (and takes its paths from the workflow, like docker's), README
examples use mortis.kamino.fail2ban, repository-local issue references are
dropped. mock_roles in .ansible-lint lists the new FQCN.

Not verified locally: the molecule scenario (runs on the kamino-molecule
runner in CI) and ansible-test sanity.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
2026-11-08 21:20:08 +00:00

100 lines
4.4 KiB
YAML

---
argument_specs:
main:
short_description: Install and configure Fail2Ban
description:
- >-
Installs fail2ban and python3-systemd, validates C(fail2ban_jails), writes /etc/fail2ban/jail.local, tests the
configuration, ensures the service and checks that every enabled jail is loaded.
options:
fail2ban_package_name:
type: str
default: fail2ban
description:
- Name of the Fail2Ban package.
fail2ban_jails:
type: list
elements: dict
description:
- Jails written to jail.local. The role default is a single C(sshd) jail on the systemd backend.
- >-
Each item needs C(name), C(enabled), C(filter), C(maxretry), C(bantime) and C(findtime), plus one of
C(logpath), C(journalmatch) or C(backend) set to systemd.
- Optional keys are C(port) (default any), C(backend), C(journalmatch) and C(logpath).
fail2ban_service:
type: dict
description:
- Service management. The role default is C(enabled=true), C(state=started). Missing keys fall back to those values.
- Enabled jails are only checked with fail2ban-client when state is started.
options:
enabled:
type: bool
description: Whether the service starts at boot.
state:
type: str
description: Desired systemd state of the service, for example started or stopped.
fail2ban_defaults:
type: dict
description:
- >-
Fallback C(maxretry), C(bantime) and C(findtime). The role default is 5, 600 and 600. Only used by the
service_jail entry point; main-entry jails must set all three (C(tasks/validate.yml) asserts them), so
there the fallback only applies when validation is skipped, for example under C(--tags fail2ban_configure).
options:
maxretry:
type: int
description: Fallback number of failures before a ban.
bantime:
type: raw
description: Fallback ban duration, seconds or a Fail2Ban time string.
findtime:
type: raw
description: Fallback window in which failures are counted, seconds or a Fail2Ban time string.
service_jail:
short_description: Deploy one service jail and filter into jail.d
description:
- Entry point for a service role that owns its jail, used with C(include_role) and C(tasks_from=service_jail).
- >-
Installs Fail2Ban, writes /etc/fail2ban/filter.d/<name>.conf and /etc/fail2ban/jail.d/<name>.local, reloads
Fail2Ban and tests the configuration. It never touches jail.local.
options:
fail2ban_package_name:
type: str
default: fail2ban
description:
- Name of the Fail2Ban package installed by this entry point.
fail2ban_service_name:
type: str
required: true
description:
- Service name, used as the jail section name and the file names under filter.d and jail.d.
fail2ban_service_jail:
type: raw
required: true
description:
- >-
Mapping describing the jail. Must contain C(logpath) or C(journalmatch). Optional keys are C(enabled) (default
true), C(port) (default any), C(filter) (default the service name), C(backend) (default systemd, only used
with journalmatch), C(maxretry), C(bantime) and C(findtime), which fall back to C(fail2ban_defaults).
- Typed raw because callers pass a templated variable, for example C(gitea_fail2ban_jail). It is asserted to be a mapping.
fail2ban_service_filter:
type: raw
required: true
description:
- Mapping with C(failregex) (required) and C(ignoreregex) (optional, default empty).
- Typed raw because callers pass a templated variable. It is asserted to be a mapping.
fail2ban_defaults:
type: dict
description:
- Fallback C(maxretry), C(bantime) and C(findtime), read from the role defaults.
options:
maxretry:
type: int
description: Fallback number of failures before a ban.
bantime:
type: raw
description: Fallback ban duration.
findtime:
type: raw
description: Fallback failure counting window.