2023-10-17 13:02:13 +00:00
|
|
|
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
# Install and configure FAIL2BAN
|
2023-10-18 07:06:20 +00:00
|
|
|
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
|
2023-10-19 09:21:54 +00:00
|
|
|
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
2023-10-18 12:24:17 +00:00
|
|
|
# comprobe if fail2ban is installed if not then install fail2ban
|
|
|
|
# Gather the package facts
|
|
|
|
- name: Gather the package facts
|
2023-10-19 05:13:17 +00:00
|
|
|
package_facts:
|
2023-10-18 12:24:17 +00:00
|
|
|
manager: auto
|
2023-10-19 09:21:54 +00:00
|
|
|
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
2023-10-18 12:33:17 +00:00
|
|
|
|
2023-10-19 09:21:54 +00:00
|
|
|
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
2023-10-18 12:24:17 +00:00
|
|
|
# install packages if is not in the system
|
|
|
|
- name: install fail2ban package if is not in the system
|
2023-10-18 07:06:20 +00:00
|
|
|
apt:
|
2023-10-18 12:24:17 +00:00
|
|
|
name: fail2ban
|
2023-10-18 07:06:20 +00:00
|
|
|
state: present
|
2023-10-18 14:15:54 +00:00
|
|
|
when: "'fail2ban' not in ansible_facts.packages"
|
2023-10-19 09:21:54 +00:00
|
|
|
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
2023-10-18 12:24:17 +00:00
|
|
|
|
2023-10-19 09:21:54 +00:00
|
|
|
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
# configure fail2ban
|
|
|
|
# template a file to /etc/fail2ban/jail.local
|
|
|
|
- name: template a file to /etc/fail2ban/jail.local
|
|
|
|
template:
|
|
|
|
src: jail.j2
|
|
|
|
dest: "{{ path_jail_local }}"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: '0644'
|
|
|
|
backup: true
|
2023-10-20 07:51:22 +00:00
|
|
|
notify: Restart fail2ban
|
2023-10-19 09:21:54 +00:00
|
|
|
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|