lab-ansible/roles/virt-common/tasks/firewall.yml

119 lines
3.1 KiB
YAML
Raw Normal View History

2023-10-28 23:00:05 +00:00
# vim: ft=yaml.ansible
2023-10-29 19:46:52 +00:00
# code: language=ansible
2023-10-28 23:00:05 +00:00
---
2023-11-12 17:22:08 +00:00
- name: General firewall rules
notify: Reload firewalld
block:
2023-11-13 20:17:17 +00:00
- name: Move Guest LAN and and IoT LAN networks to zone 'drop'
2023-11-12 17:22:08 +00:00
ansible.posix.firewalld:
zone: drop
source: "{{ item }}"
permanent: true
state: enabled
2023-11-13 20:17:17 +00:00
loop:
- 192.168.2.0/24
- 192.168.4.0/24
- name: Move Home LAN and VPN networks to zone 'dmz'
ansible.posix.firewalld:
zone: dmz
source: "{{ item }}"
permanent: true
state: enabled
2023-11-12 17:22:08 +00:00
loop:
- 192.168.1.0/24
- 192.168.8.0/24
2023-11-11 20:09:17 +00:00
2023-11-13 20:17:17 +00:00
- name: Move Lab LAN network to zone 'public'
2023-11-12 17:22:08 +00:00
ansible.posix.firewalld:
2023-11-13 20:17:17 +00:00
zone: public
2023-11-12 17:22:08 +00:00
source: 192.168.17.0/24
permanent: true
state: enabled
2023-11-12 17:22:08 +00:00
- name: Move internal network to zone 'internal'
ansible.posix.firewalld:
zone: internal
source: 10.2.0.0/16
permanent: true
state: enabled
2023-11-11 20:09:17 +00:00
2023-11-13 20:17:17 +00:00
- name: Default deny incoming connections to SSH port in all zones
2023-11-12 17:22:08 +00:00
ansible.posix.firewalld:
zone: "{{ item }}"
service: ssh
permanent: true
state: disabled
loop:
2023-11-13 20:17:17 +00:00
- drop
2023-11-12 17:22:08 +00:00
- dmz
2023-11-13 20:17:17 +00:00
- public
2023-11-12 17:22:08 +00:00
- internal
2023-11-12 17:22:08 +00:00
# Until sapt-labx-ctl01 is deployed
2023-11-13 20:17:17 +00:00
- name: Allow incoming connections to SSH port in zone 'dmz'
2023-11-12 17:22:08 +00:00
ansible.posix.firewalld:
2023-11-13 20:17:17 +00:00
zone: dmz
2023-11-12 17:22:08 +00:00
service: ssh
permanent: true
state: enabled
2023-11-11 20:09:17 +00:00
2023-11-12 17:22:08 +00:00
# When sapt-labx-ctl01 is deployed
2023-11-13 20:17:17 +00:00
# - name: Allow incoming connections from control machines to SSH port in zone 'public'
2023-11-12 17:22:08 +00:00
# ansible.posix.firewalld:
2023-11-13 20:17:17 +00:00
# zone: public
# source: "{{ hostvars[item].ansible_host }}"
2023-11-12 17:22:08 +00:00
# service: ssh
# permanent: true
# state: enabled
2023-11-13 20:17:17 +00:00
# loop: "{{ groups['control_infra'] }}"
2023-11-26 16:37:17 +00:00
- name: Firewall rules for database servers
when: hostname in groups['dbservers']
2023-11-12 17:22:08 +00:00
notify: Reload firewalld
block:
2023-11-26 16:37:17 +00:00
- name: Allow incoming connections from internal subnet to PostgreSQL port in zone 'internal'
ansible.posix.firewalld:
zone: internal
2023-11-26 16:37:17 +00:00
source: "{{ internal_subnet }}"
2023-11-11 20:09:17 +00:00
service: postgresql
permanent: true
state: enabled
2023-11-12 17:18:56 +00:00
2023-11-13 20:17:17 +00:00
- name: Firewall rules for proxy servers
when: hostname in group['proxyservers']
notify: Reload firewalld
block:
- name: Allow incoming connections to HTTP port in zones 'drop' and 'dmz'
ansible.posix.firewalld:
zone: "{{ item }}"
service: http
permanent: true
state: enabled
loop:
- drop
- dmz
- name: Allow incoming connections to HTTPS port in zones 'drop' and 'dmz'
ansible.posix.firewalld:
zone: "{{ item }}"
service: https
permanent: true
state: enabled
loop:
- drop
- dmz
- name: Allow incoming connections to HTTP/3 port in zones 'drop' and 'dmz'
ansible.posix.firewalld:
zone: "{{ item }}"
service: http3
permanent: true
state: enabled
loop:
- drop
- dmz
2023-11-12 17:18:56 +00:00
- name: Flush handlers
ansible.builtin.meta: flush_handlers