mirror of
https://github.com/Manoj-HV30/cloud-vps.git
synced 2026-07-13 08:50:11 +00:00
47 lines
842 B
YAML
47 lines
842 B
YAML
---
|
|
# Security hardening — UFW firewall + fail2ban
|
|
- name: Install security packages
|
|
apt:
|
|
name:
|
|
- ufw
|
|
- fail2ban
|
|
state: present
|
|
|
|
- name: Set UFW default deny incoming
|
|
community.general.ufw:
|
|
direction: incoming
|
|
default: deny
|
|
|
|
- name: Set UFW default allow outgoing
|
|
community.general.ufw:
|
|
direction: outgoing
|
|
default: allow
|
|
|
|
- name: Allow SSH through UFW
|
|
community.general.ufw:
|
|
rule: allow
|
|
port: "22"
|
|
proto: tcp
|
|
|
|
- name: Allow HTTP through UFW
|
|
community.general.ufw:
|
|
rule: allow
|
|
port: "80"
|
|
proto: tcp
|
|
|
|
- name: Allow HTTPS through UFW
|
|
community.general.ufw:
|
|
rule: allow
|
|
port: "443"
|
|
proto: tcp
|
|
|
|
- name: Enable UFW
|
|
community.general.ufw:
|
|
state: enabled
|
|
|
|
- name: Enable and start fail2ban
|
|
systemd:
|
|
name: fail2ban
|
|
enabled: true
|
|
state: started
|