deployment/roles/net-security/tasks/main.yml

40 lines
826 B
YAML
Raw Normal View History

2021-12-12 16:36:49 +01:00
- name: Install fail2ban & ufw.
2021-12-11 16:28:17 +01:00
apt:
2021-12-12 16:36:49 +01:00
name:
- fail2ban
- ufw
2021-12-11 16:28:17 +01:00
state: present
# TODO add proper fail2ban config
- name: Ensure fail2ban is started & enabled.
service:
name: fail2ban
state: started
enabled: true
2021-12-12 16:36:49 +01:00
- name: Ensure ufw is started & enabled.
service:
name: fail2ban
state: started
enabled: true
- name: Allow SSH connections.
community.general.ufw:
rule: allow
port: 2222
2021-12-12 22:34:38 +01:00
- name: Open necessary ports for Docker swarm communication.
community.general.ufw:
rule: allow
port: "{{ item }}"
loop:
- 2377 # cluster management communications
- 7946 # communication among nodes
- 4789 # overlay network traffic
2021-12-12 16:36:49 +01:00
- name: Block everything else by default & enable firewall.
community.general.ufw:
default: deny
state: enabled