---
- name: Install UFW Firewall
  apt:
    name: ufw

- name: UFW - Disable all other incoming by default
  ufw:
    policy: deny
    direction: incoming

- name: UFW - Allow all other outgoing by default
  ufw:
    policy: allow
    direction: outgoing

- name: UFW - Enable AzuraCast TCP Ports
  ufw:
    rule: allow
    port: "{{ ufw_allow_rule }}"
    proto: tcp
  loop:
    - 80
    - 443
    - 2022
    - '8000:8999'
  loop_control:
    loop_var: ufw_allow_rule

- name: UFW - Enable SSH
  ufw:
    rule: limit
    port: ssh
    proto: tcp

- name: UFW - Turn on Firewall
  ufw:
    state: enabled
