28 lines
774 B
YAML
28 lines
774 B
YAML
# CrowdSec reads the same logs and bans through its bouncers. fail2ban is
|
|
# removed only on a host switched over on purpose (fail2ban_remove) where both
|
|
# are running, so a host never ends up without a ban mechanism.
|
|
- name: Check the CrowdSec services
|
|
command: systemctl is-active crowdsec crowdsec-firewall-bouncer
|
|
register: crowdsec_active
|
|
changed_when: false
|
|
failed_when: false
|
|
check_mode: false
|
|
tags: fail2ban
|
|
|
|
- name: Stop and disable fail2ban
|
|
systemd:
|
|
name: fail2ban
|
|
state: stopped
|
|
enabled: false
|
|
when: fail2ban_remove and crowdsec_active.rc == 0
|
|
failed_when: false
|
|
tags: fail2ban
|
|
|
|
- name: Remove fail2ban
|
|
apt:
|
|
name: fail2ban
|
|
state: absent
|
|
purge: true
|
|
when: fail2ban_remove and crowdsec_active.rc == 0
|
|
tags: fail2ban
|