33 lines
691 B
YAML
33 lines
691 B
YAML
|
---
|
||
|
- 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
|
||
|
|