hac/ansible/roles/fail2ban/tasks/main.yml

27 lines
565 B
YAML
Raw Normal View History

2024-03-20 13:45:58 +01:00
---
- name: Install fail2ban
ansible.builtin.apt:
name: "fail2ban"
state: latest
2024-03-22 23:47:35 +01:00
when: ansible_facts['os_family'] == "Debian"
- name: Install fail2ban
ansible.builtin.dnf:
name: "fail2ban"
state: latest
when: ansible_facts['os_family'] == "RedHat"
2024-03-20 13:45:58 +01:00
- name: Copy sshd.conf
2024-03-22 23:47:35 +01:00
ansible.builtin.template:
src: 'sshd.conf.j2'
2024-03-20 13:45:58 +01:00
dest: '/etc/fail2ban/jail.d/sshd.conf'
mode: "0640"
notify:
- Restart fail2ban
- name: Start fail2ban.service
ansible.builtin.systemd:
state: started
name: fail2ban.service
enabled: true