Files
server-infra/roles/ufw/tasks/main.yml
2026-07-06 15:34:49 -05:00

34 lines
688 B
YAML

---
- name: Install ufw
ansible.builtin.apt:
name: ufw
state: present
- name: Set UFW default incoming policy to deny
community.general.ufw:
direction: incoming
policy: deny
- name: Set UFW default outgoing policy to allow
community.general.ufw:
direction: outgoing
policy: allow
- name: Allow SSH from LAN only
community.general.ufw:
rule: allow
port: "{{ ufw_ssh_port }}"
proto: tcp
from_ip: "{{ ufw_ssh_allowed_network }}"
- name: Allow HTTP and HTTPS
community.general.ufw:
rule: allow
port: "{{ item }}"
proto: tcp
loop: "{{ ufw_allowed_tcp_ports }}"
- name: Enable UFW
community.general.ufw:
state: enabled