Initial commit
This commit is contained in:
commit
1f22db68e1
5 changed files with 54 additions and 0 deletions
8
defaults/main.yml
Normal file
8
defaults/main.yml
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
fail2ban_config:
|
||||||
|
DEFAULT:
|
||||||
|
logtarget: SYSLOG
|
||||||
|
|
||||||
|
fail2ban_jail:
|
||||||
|
DEFAULT:
|
||||||
|
banaction: nftables-multiport
|
||||||
|
banaction_allports: nftables-allports
|
||||||
4
handlers/main.yml
Normal file
4
handlers/main.yml
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
- name: Restart fail2ban
|
||||||
|
ansible.builtin.systemd_service:
|
||||||
|
name: fail2ban
|
||||||
|
state: restarted
|
||||||
30
tasks/main.yml
Normal file
30
tasks/main.yml
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
- name: Install fail2ban
|
||||||
|
ansible.builtin.apt:
|
||||||
|
pkg: fail2ban
|
||||||
|
|
||||||
|
- name: Copy fail2ban config
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: fail2ban.local.j2
|
||||||
|
dest: /etc/fail2ban/fail2ban.local
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0644
|
||||||
|
notify: Restart fail2ban
|
||||||
|
|
||||||
|
- name: Copy jail config
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: jail.local.j2
|
||||||
|
dest: /etc/fail2ban/jail.local
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0644
|
||||||
|
notify: Restart fail2ban
|
||||||
|
|
||||||
|
- name: Clear debian default jail config
|
||||||
|
ansible.builtin.copy:
|
||||||
|
content: ''
|
||||||
|
dest: /etc/fail2ban/jail.d/defaults-debian.conf
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0644
|
||||||
|
notify: Restart fail2ban
|
||||||
6
templates/fail2ban.local.j2
Normal file
6
templates/fail2ban.local.j2
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
{% for section, settings in fail2ban_config.items() %}
|
||||||
|
[{{ section }}]
|
||||||
|
{% for key, value in settings.items() %}
|
||||||
|
{{ key }} = {{ value }}
|
||||||
|
{% endfor %}
|
||||||
|
{% endfor %}
|
||||||
6
templates/jail.local.j2
Normal file
6
templates/jail.local.j2
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
{% for section, settings in fail2ban_jail.items() %}
|
||||||
|
[{{ section }}]
|
||||||
|
{% for key, value in settings.items() %}
|
||||||
|
{{ key }} = {{ value }}
|
||||||
|
{% endfor %}
|
||||||
|
{% endfor %}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue