Przeglądaj źródła

Moved ufw firewall rules into individual roles

Justin Plock 10 lat temu
rodzic
commit
ea0b288818
No account linked to committer's email address

+ 1
- 1
README.textile Wyświetl plik

@@ -151,7 +151,7 @@ For git hosting, copy your public key into place. @cp ~/.ssh/id_rsa.pub roles/gi
151 151
 
152 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 156
 To run the whole dang thing:
157 157
 

+ 13
- 19
roles/common/tasks/ufw.yml Wyświetl plik

@@ -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"

+ 3
- 0
roles/ircbouncer/tasks/znc.yml Wyświetl plik

@@ -54,5 +54,8 @@
54 54
   template: src=var_lib_znc_configs_znc.conf.j2 dest=/var/lib/znc/configs/znc.conf owner=znc group=znc
55 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 60
 - name: Ensure znc is a system service
58 61
   service: name=znc state=started enabled=true

+ 6
- 0
roles/mailserver/tasks/dovecot.yml Wyświetl plik

@@ -48,3 +48,9 @@
48 48
   file: state=directory path=/etc/dovecot
49 49
           group=dovecot owner=vmail mode=770 recurse=yes
50 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 Wyświetl plik

@@ -49,3 +49,9 @@
49 49
     - pgsql-virtual-mailbox-maps.cf
50 50
     - pgsql-virtual-alias-maps.cf
51 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 Wyświetl plik

@@ -131,6 +131,9 @@
131 131
     - iptables -A FORWARD -j REJECT
132 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 137
 - name: Copy OpenVPN configuration file into place
135 138
   template: src=etc_openvpn_server.conf.j2 dest=/etc/openvpn/server.conf
136 139
   notify: restart openvpn

+ 6
- 0
roles/xmpp/tasks/prosody.yml Wyświetl plik

@@ -20,3 +20,9 @@
20 20
 - name: Create Prosody accounts
21 21
   command: prosodyctl register {{ item.name }} {{ prosody_virtual_domain }} "{{ item.password }}"
22 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

Ładowanie…
Anuluj
Zapisz