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

34 lines
1.3 KiB
YAML

#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Install and configure FAIL2BAN
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# comprobe if fail2ban is installed if not then install fail2ban
# Gather the package facts
- name: Gather the package facts
package_facts:
manager: auto
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# install packages if is not in the system
- name: install fail2ban package if is not in the system
apt:
name: fail2ban
state: present
when: "'fail2ban' not in ansible_facts.packages"
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# 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
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++