This repository has been archived on 2023-09-13. You can view files and clone it, but cannot push or open issues or pull requests.
homeserver-ansible/roles/firewall/tasks/main.yml

91 lines
1.6 KiB
YAML
Raw Normal View History

2022-03-01 17:43:44 -05:00
- name: Install packages
2022-02-27 16:05:34 -05:00
community.general.pacman:
name:
- ufw
2022-03-01 17:43:44 -05:00
- name: Deny all ports by default
2022-02-27 16:05:34 -05:00
community.general.ufw:
policy: deny
2022-03-01 17:56:41 -05:00
- name: Allow Matrix federation port
2022-02-27 16:05:34 -05:00
community.general.ufw:
rule: allow
2022-03-01 17:56:41 -05:00
port: 8448
2022-02-27 16:05:34 -05:00
proto: tcp
state: enabled
2022-03-01 17:56:41 -05:00
when: enable_synapse
2022-02-27 16:05:34 -05:00
2022-12-25 21:00:16 -05:00
- name: Allow Syncthing port
community.general.ufw:
rule: allow
port: 22000
proto: any
state: enabled
when: enable_syncthing
2022-03-01 17:56:41 -05:00
- name: Allow http/https ports
community.general.ufw:
rule: allow
port: "{{ item }}"
proto: tcp
state: enabled
when: enable_webserver
2022-02-27 16:05:34 -05:00
with_items:
- http
- https
2022-03-01 17:56:41 -05:00
2022-05-22 20:47:58 -04:00
- name: Allow coturn ports (turn/turns)
community.general.ufw:
rule: allow
port: "{{ item }}"
state: enabled
when: enable_coturn
with_items:
- turn
- turns
- name: Allow coturn UDP relay ports
community.general.ufw:
rule: allow
port: "49152:65535"
proto: udp
state: enabled
when: enable_coturn
- name: Allow coturn TCP relay ports
community.general.ufw:
rule: allow
port: "49152:65535"
proto: tcp
state: enabled
when: enable_coturn
2022-03-01 17:56:41 -05:00
- name: Allow ssh port
community.general.ufw:
rule: allow
port: "{{ sshd_port }}"
proto: tcp
state: enabled
2022-02-27 16:05:34 -05:00
2022-05-10 22:11:16 -04:00
- name: Allow gitea ssh port
community.general.ufw:
rule: allow
port: "2499"
proto: tcp
state: enabled
2022-02-27 16:05:34 -05:00
- name: Allow DNS port to LAN
community.general.ufw:
rule: allow
2022-03-01 17:56:41 -05:00
port: domain
2022-02-27 16:05:34 -05:00
proto: any
state: enabled
src: "{{ local_subnet }}"
2022-03-01 17:56:41 -05:00
when: enable_nameserver
2022-02-27 16:05:34 -05:00
- name: Enable firewall service
service:
name: ufw
state: started
enabled: yes