vn-ansible/roles/config-fail2ban/tasks/main.yaml

41 lines
1.6 KiB
YAML
Raw Normal View History

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
2023-10-26 12:16:21 +00:00
#- name: Gather the package facts
# package_facts:
# manager: auto
2023-10-19 09:21:54 +00:00
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2023-10-18 12:24:17 +00:00
# install packages if is not in the system
2023-10-26 12:18:17 +00:00
- name: install fail2ban package if is not in the system
apt:
name: fail2ban
state: present
# when: "'fail2ban' not in ansible_facts.packages" # ansible comprobes if is ok its installed
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:
2023-10-27 08:02:22 +00:00
src: jail2.j2
2023-10-19 09:21:54 +00:00
dest: "{{ path_jail_local }}"
owner: root
group: root
mode: '0644'
backup: true
2023-10-26 12:16:21 +00:00
notify: restart fail2ban
2023-10-19 09:21:54 +00:00
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2023-10-26 12:16:21 +00:00
# service nftables should start on boot.
- name: service nftables should start on boot
2023-10-23 15:15:57 +00:00
service:
2023-10-26 12:16:21 +00:00
name: "{{ nftables_daemon }}"
2023-10-23 15:15:57 +00:00
enabled: yes
2023-10-26 12:16:21 +00:00
notify: restart nftables
2023-10-23 15:15:57 +00:00
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++