This repository has been archived on 2022-06-21. You can view files and clone it, but cannot push or open issues or pull requests.
2022-05-30 12:02:36 +00:00
|
|
|
---
|
|
|
|
- name: Update the package cache
|
|
|
|
apt:
|
|
|
|
update_cache: true
|
|
|
|
cache_valid_time: 3600
|
|
|
|
|
|
|
|
- name: Install ufw
|
|
|
|
apt:
|
|
|
|
name: ufw
|
|
|
|
|
|
|
|
- name: "Allow access on ports: {{ ufw_allow_ports | join(' ') }}"
|
|
|
|
ufw:
|
|
|
|
rule: allow
|
|
|
|
port: "{{ item }}"
|
|
|
|
proto: tcp
|
|
|
|
state: enabled
|
|
|
|
with_items: "{{ ufw_allow_ports }}"
|
|
|
|
notify: Restart ufw
|
|
|
|
|
|
|
|
- name: "Disallow access on ports: {{ ufw_disallow_ports | join(' ') }}"
|
|
|
|
ufw:
|
|
|
|
rule: deny
|
|
|
|
port: "{{ item }}"
|
|
|
|
with_items: "{{ ufw_disallow_ports }}"
|
|
|
|
notify: Restart ufw
|
|
|
|
|
|
|
|
- name: Default policy deny
|
|
|
|
ufw:
|
|
|
|
policy: deny
|
|
|
|
|
|
|
|
- name: Enable the firewall
|
|
|
|
ufw:
|
|
|
|
state: enabled
|
2022-06-21 13:12:55 +00:00
|
|
|
|
|
|
|
- name: Deny connections if an IP address has attempted to initiate 6 or more connections in the last 30 seconds
|
|
|
|
ufw:
|
|
|
|
rule: limit
|
|
|
|
port: 222
|
|
|
|
proto: tcp
|