vn-ansible/linux/base-config-debian/config-fail2ban.yaml

49 lines
1.5 KiB
YAML
Raw Normal View History

2023-10-17 13:10:41 +00:00
---
- hosts: "{{ ip_addr }}"
become: yes
become_method: sudo
2023-10-18 12:24:17 +00:00
gather_facts: yes
2023-10-17 13:10:41 +00:00
tasks:
2023-10-19 09:59:11 +00:00
- name: set variables
set_fact:
bantime: "10m"
maxretry: "10"
findtime: "10m"
jails:
- name: sshd
enabled: true
filter: sshd
logpath: /var/log/lastlog
port: ['ssh', '22']
maxretry: 10
bantime: 10m
findtime: 10m
- name: asterisk
enabled: true
filter: asterisk
logpath: /var/log/asterisk/messages
port: ['asterisk', '5060']
maxretry: 10
bantime: 10m
findtime: 10m
2023-10-17 13:10:41 +00:00
2023-10-18 10:26:07 +00:00
- name: "[CONFIG FAIL2BAN] Install and configure fail2ban service"
2023-10-17 13:10:41 +00:00
import_role:
2023-10-19 09:21:54 +00:00
name: config-fail2ban
#In this template:
#{{ bantime }}, {{ maxretry }}, and {{ findtime }} represent the global default values for these settings.
#For each jail, you can specify various options including:
#{{ jail.name }}: The name of the jail.
#{{ jail.enabled }}: Whether the jail is enabled or not.
#{{ jail.filter }}: The filter for the jail.
#{{ jail.logpath }}: The log file path that Fail2Ban should monitor.
#{{ jail.port | join(' ') }}: The port(s) to monitor.
#{{ jail.maxretry }}: The maximum number of retries before banning.
#{{ jail.bantime }}: The ban time for this jail.
#{{ jail.findtime }}: The time window for counting retries.