Skip to content

Commit ec9d557

Browse files
committed
Add fail2ban config
1 parent 975ecfd commit ec9d557

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

files/fail2ban/jail.local

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[DEFAULT]
2+
3+
# "bantime" is the number of seconds that a host is banned.
4+
bantime = 1d
5+
6+
# A host is banned if it has generated "maxretry" during the last "findtime"
7+
findtime = 1h
8+
9+
# "maxretry" is the number of failures before a host get banned.
10+
maxretry = 5

matplotlib.org.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,31 @@
9191
offline: true
9292
state: enabled
9393

94+
# fail2ban setup
95+
# ##############
96+
- name: Setup fail2ban
97+
tags: fail2ban
98+
block:
99+
- name: Configure fail2ban
100+
ansible.builtin.copy:
101+
src: fail2ban/jail.local
102+
dest: /etc/fail2ban/jail.local
103+
notify:
104+
- Restart fail2ban
105+
106+
- name: Configure SSH fail2ban
107+
ansible.builtin.template:
108+
src: fail2ban/sshd.local.j2
109+
dest: /etc/fail2ban/jail.d/sshd.local
110+
notify:
111+
- Restart fail2ban
112+
113+
- name: Enable fail2ban service
114+
ansible.builtin.systemd:
115+
name: fail2ban.service
116+
enabled: true
117+
state: started
118+
94119
# Prepare and clone Git repositories
95120
# ##################################
96121
- name: Setup Git repositories
@@ -277,6 +302,11 @@
277302
ansible.builtin.systemd:
278303
daemon_reload: true
279304

305+
- name: Restart fail2ban
306+
ansible.builtin.systemd:
307+
name: fail2ban
308+
state: restarted
309+
280310
- name: Restart Caddy
281311
ansible.builtin.systemd:
282312
name: caddy

templates/fail2ban/sshd.local.j2

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[sshd]
2+
enabled = true
3+
ignoreip = 127.0.0.1/8 10.0.0.1/8 {{ ansible_eth0.ipv4.address }} {{ ansible_eth1.ipv4.address }}

0 commit comments

Comments
 (0)