Files
ansible/roles/security/tasks/main.yml
T
alessandrovitali 9fbba9ffd6 fix: remove OS checks
either use the generic package module or OS-specific tasks that won't silently fail playbook runs
2026-07-09 16:17:30 +02:00

34 lines
665 B
YAML

---
- name: Create SSH drop-in directory
ansible.builtin.file:
path: /etc/ssh/sshd_config.d
state: directory
owner: root
group: root
mode: "0755"
become: true
- name: Harden SSH configuration with drop-in template
ansible.builtin.template:
src: sshd.conf.j2
dest: /etc/ssh/sshd_config.d/sshd.conf
owner: root
group: root
mode: "0644"
validate: "sshd -t -f %s"
notify: Restart sshd
become: true
- name: Install fail2ban
ansible.builtin.apt:
name:
- fail2ban
state: present
become: true
- name: Start fail2ban
ansible.builtin.service:
name: fail2ban
state: started
enabled: yes