|
@@ -5,24 +5,18 @@
|
5
|
5
|
- name: Install ufw
|
6
|
6
|
apt: pkg=ufw state=present
|
7
|
7
|
|
8
|
|
-- name: Set firewall rules
|
9
|
|
- command: ufw allow {{ item }}
|
10
|
|
- register: ufw_result
|
11
|
|
- changed_when: "ufw_result.stdout.startswith('Rule')"
|
|
8
|
+- name: Set firewall rule for DNS
|
|
9
|
+ ufw: rule=allow port=domain
|
|
10
|
+
|
|
11
|
+- name: Set firewall rule for mosh
|
|
12
|
+ ufw: rule=allow port=60000:61000 proto=udp
|
|
13
|
+
|
|
14
|
+- name: Set firewall rules for web traffic and SSH
|
|
15
|
+ ufw: rule=allow port={{ item }} proto=tcp
|
12
|
16
|
with_items:
|
13
|
|
- - smtp/tcp
|
14
|
|
- - domain
|
15
|
|
- - http/tcp
|
16
|
|
- - https/tcp
|
17
|
|
- - ssh/tcp
|
18
|
|
- - ssmtp/tcp
|
19
|
|
- - pop3s/tcp
|
20
|
|
- - imaps/tcp
|
21
|
|
- - 5222/tcp # xmpp c2s
|
22
|
|
- - 5269/tcp # xmpp s2s
|
23
|
|
- - 6697/tcp # znc
|
24
|
|
- - "{{ openvpn_port }}/{{ openvpn_protocol }}"
|
25
|
|
- - 60000:61000/udp # mosh udp packets
|
|
17
|
+ - ssh
|
|
18
|
+ - http
|
|
19
|
+ - https
|
26
|
20
|
|
27
|
21
|
- name: Check status of ufw
|
28
|
22
|
command: ufw status
|
|
@@ -35,9 +29,9 @@
|
35
|
29
|
changed_when: False # never report as "changed"
|
36
|
30
|
|
37
|
31
|
- name: Disable logging (workaround for known bug in Debian 7)
|
38
|
|
- command: ufw logging off
|
|
32
|
+ ufw: logging=off
|
39
|
33
|
when: "ansible_lsb['codename'] == 'wheezy' and 'LOGLEVEL=off' not in ufw_config.stdout"
|
40
|
34
|
|
41
|
35
|
- name: Enable ufw
|
42
|
|
- command: ufw --force enable
|
|
36
|
+ ufw: state=enabled
|
43
|
37
|
when: "ufw_status.stdout.startswith('Status: inactive') or 'ENABLED=yes' not in ufw_config.stdout"
|