initial commit

This commit is contained in:
Ludovic Cartier 2024-12-16 19:28:37 +01:00
parent 98722ebc6f
commit 04d63c93f2
4 changed files with 59 additions and 0 deletions

7
files/defaults.conf Normal file
View File

@ -0,0 +1,7 @@
[DEFAULT]
bantime= 3600
findtime= 10
maxretry= 3
ignoreip= 127.0.0.1/8

2
files/sshd.conf Normal file
View File

@ -0,0 +1,2 @@
[sshd]
enabled = true

6
handlers/main.yml Normal file
View File

@ -0,0 +1,6 @@
---
- name: 'fail2ban | restart fail2ban'
systemd:
name: fail2ban
state: restarted
tags: ['fail2ban']

44
tasks/main.yml Normal file
View File

@ -0,0 +1,44 @@
---
- name: 'fail2ban | apt update cache'
apt:
update_cache: yes
cache_valid_time: 86400 #One day
tags: ['fail2ban']
- name: 'fail2ban | install iptables packages'
apt:
name: "{{ item }}"
update_cache: true
state: present
with_items:
- fail2ban
tags: ['fail2ban']
- name: 'fail2ban | delete default config'
file:
path: "/etc/fail2ban/jail.d/defaults-debian.conf"
state: absent
notify:
- 'fail2ban | restart fail2ban'
tags: ['fail2ban']
- name: 'fail2ban | configuring fail2ban'
copy:
src: defaults.conf
dest: /etc/fail2ban/jail.d/defaults.conf
mode: 0644
force: yes
notify:
- 'fail2ban | restart fail2ban'
tags: ['fail2ban']
- name: 'fail2ban | enable sshd jail'
copy:
src: sshd.conf
dest: /etc/fail2ban/jail.d/sshd.conf
mode: 0644
force: yes
notify:
- 'fail2ban | restart fail2ban'
tags: ['fail2ban']