ansible_playbooks/ufw_ubuntu_configure.yml

33 lines
691 B
YAML
Raw Permalink Normal View History

2023-08-03 11:26:38 -04:00
---
- name: Configure UFW to allow specific ports and use LIMIT for SSH
hosts: servers
become: true # This enables privilege escalation, necessary to modify firewall rules
tasks:
- name: Install UFW if not already installed
apt:
name: ufw
state: present
- name: Allow incoming traffic on ports 5432, 8083, and 8888
ufw:
rule: allow
port: "{{ item }}"
with_items:
- 5432
- 8083
- 8888
- 80
- 443
- name: Set up the LIMIT rule for SSH on port 22
ufw:
rule: limit
port: 22
proto: tcp
- name: Enable UFW firewall
ufw:
state: enabled