Browse Source

Moved ufw firewall rules into individual roles

Justin Plock 10 years ago
parent
commit
ea0b288818
No account linked to committer's email address

+ 1
- 1
README.textile View File

151
 
151
 
152
 h3. 5. Run the Ansible Playbooks
152
 h3. 5. Run the Ansible Playbooks
153
 
153
 
154
-First, make sure you've "got Ansible installed":http://docs.ansible.com/intro_installation.html#getting-ansible.
154
+First, make sure you've "got Ansible 1.6+ installed":http://docs.ansible.com/intro_installation.html#getting-ansible.
155
 
155
 
156
 To run the whole dang thing:
156
 To run the whole dang thing:
157
 
157
 

+ 13
- 19
roles/common/tasks/ufw.yml View File

5
 - name: Install ufw
5
 - name: Install ufw
6
   apt: pkg=ufw state=present
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
   with_items:
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
 - name: Check status of ufw
21
 - name: Check status of ufw
28
   command: ufw status
22
   command: ufw status
35
   changed_when: False  # never report as "changed"
29
   changed_when: False  # never report as "changed"
36
 
30
 
37
 - name: Disable logging (workaround for known bug in Debian 7)
31
 - name: Disable logging (workaround for known bug in Debian 7)
38
-  command: ufw logging off
32
+  ufw: logging=off
39
   when: "ansible_lsb['codename'] == 'wheezy' and 'LOGLEVEL=off' not in ufw_config.stdout"
33
   when: "ansible_lsb['codename'] == 'wheezy' and 'LOGLEVEL=off' not in ufw_config.stdout"
40
 
34
 
41
 - name: Enable ufw
35
 - name: Enable ufw
42
-  command: ufw --force enable
36
+  ufw: state=enabled
43
   when: "ufw_status.stdout.startswith('Status: inactive') or 'ENABLED=yes' not in ufw_config.stdout"
37
   when: "ufw_status.stdout.startswith('Status: inactive') or 'ENABLED=yes' not in ufw_config.stdout"

+ 3
- 0
roles/ircbouncer/tasks/znc.yml View File

54
   template: src=var_lib_znc_configs_znc.conf.j2 dest=/var/lib/znc/configs/znc.conf owner=znc group=znc
54
   template: src=var_lib_znc_configs_znc.conf.j2 dest=/var/lib/znc/configs/znc.conf owner=znc group=znc
55
   when: znc_config.rc != 0
55
   when: znc_config.rc != 0
56
 
56
 
57
+- name: Set firewall rule for znc
58
+  ufw: rule=allow port=6697 proto=tcp
59
+
57
 - name: Ensure znc is a system service
60
 - name: Ensure znc is a system service
58
   service: name=znc state=started enabled=true
61
   service: name=znc state=started enabled=true

+ 6
- 0
roles/mailserver/tasks/dovecot.yml View File

48
   file: state=directory path=/etc/dovecot
48
   file: state=directory path=/etc/dovecot
49
           group=dovecot owner=vmail mode=770 recurse=yes
49
           group=dovecot owner=vmail mode=770 recurse=yes
50
   notify: restart dovecot
50
   notify: restart dovecot
51
+
52
+- name: Set firewall rules for dovecot
53
+  ufw: rule=allow port={{ item }} proto=tcp
54
+  with_items:
55
+    - pop3s
56
+    - imaps

+ 6
- 0
roles/mailserver/tasks/postfix.yml View File

49
     - pgsql-virtual-mailbox-maps.cf
49
     - pgsql-virtual-mailbox-maps.cf
50
     - pgsql-virtual-alias-maps.cf
50
     - pgsql-virtual-alias-maps.cf
51
   notify: restart postfix
51
   notify: restart postfix
52
+
53
+- name: Set firewall rules for postfix
54
+  ufw: rule=allow port={{ item }} proto=tcp
55
+  with_items:
56
+    - smtp
57
+    - ssmtp

+ 3
- 0
roles/vpn/tasks/openvpn.yml View File

131
     - iptables -A FORWARD -j REJECT
131
     - iptables -A FORWARD -j REJECT
132
     - iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o {{ ansible_default_ipv4.interface }} -j MASQUERADE
132
     - iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o {{ ansible_default_ipv4.interface }} -j MASQUERADE
133
 
133
 
134
+- name: Allow OpenVPN through ufw
135
+  ufw: rule=allow port={{ openvpn_port }} proto={{ openvpn_protocol }}
136
+
134
 - name: Copy OpenVPN configuration file into place
137
 - name: Copy OpenVPN configuration file into place
135
   template: src=etc_openvpn_server.conf.j2 dest=/etc/openvpn/server.conf
138
   template: src=etc_openvpn_server.conf.j2 dest=/etc/openvpn/server.conf
136
   notify: restart openvpn
139
   notify: restart openvpn

+ 6
- 0
roles/xmpp/tasks/prosody.yml View File

20
 - name: Create Prosody accounts
20
 - name: Create Prosody accounts
21
   command: prosodyctl register {{ item.name }} {{ prosody_virtual_domain }} "{{ item.password }}"
21
   command: prosodyctl register {{ item.name }} {{ prosody_virtual_domain }} "{{ item.password }}"
22
   with_items: prosody_accounts
22
   with_items: prosody_accounts
23
+
24
+- name: Set firewall rules for Prosody
25
+  ufw: rule=allow port={{ item }} proto=tcp
26
+  with_items:
27
+    - 5222  # xmpp c2s
28
+    - 5269  # xmpp s2s

Loading…
Cancel
Save