Browse Source

Merge remote-tracking branch 'upstream/master' into jp-readlater

Conflicts:
	README.textile
	site.yml
	vars/defaults.yml
Justin Plock 10 years ago
parent
commit
8bd44ef965

+ 3
- 2
README.textile View File

50
 * "RFC6238":http://tools.ietf.org/html/rfc6238 two-factor authentication compatible with "Google Authenticator":http://en.wikipedia.org/wiki/Google_Authenticator and various hardware tokens
50
 * "RFC6238":http://tools.ietf.org/html/rfc6238 two-factor authentication compatible with "Google Authenticator":http://en.wikipedia.org/wiki/Google_Authenticator and various hardware tokens
51
 * Nightly backups to "Tarsnap":https://www.tarsnap.com/.
51
 * Nightly backups to "Tarsnap":https://www.tarsnap.com/.
52
 * Git hosting via "cgit":http://git.zx2c4.com/cgit/about/ and "gitolite":https://github.com/sitaramc/gitolite.
52
 * Git hosting via "cgit":http://git.zx2c4.com/cgit/about/ and "gitolite":https://github.com/sitaramc/gitolite.
53
+* "Newebe":http://newebe.org, a social network.
53
 * Read-it-later via "Wallabag":https://www.wallabag.org/
54
 * Read-it-later via "Wallabag":https://www.wallabag.org/
54
 * A bunch of nice-to-have tools like "mosh":http://mosh.mit.edu and "htop":http://htop.sourceforge.net that make life with a server a little easier.
55
 * A bunch of nice-to-have tools like "mosh":http://mosh.mit.edu and "htop":http://htop.sourceforge.net that make life with a server a little easier.
55
 
56
 
99
 
100
 
100
 Create a new machine key for your server:
101
 Create a new machine key for your server:
101
 
102
 
102
-bc. tarsnap-keygen --keyfile roles/tarsnap/files/root_tarsnap.key --user me@example.com --machine example.com
103
+bc. tarsnap-keygen --keyfile roles/tarsnap/files/decrypted_tarsnap.key --user me@example.com --machine example.com
103
 
104
 
104
 h3. 3. Prep the server
105
 h3. 3. Prep the server
105
 
106
 
152
 
153
 
153
 h3. 5. Run the Ansible Playbooks
154
 h3. 5. Run the Ansible Playbooks
154
 
155
 
155
-First, make sure you've "got Ansible installed":http://docs.ansible.com/intro_installation.html#getting-ansible.
156
+First, make sure you've "got Ansible 1.6+ installed":http://docs.ansible.com/intro_installation.html#getting-ansible.
156
 
157
 
157
 To run the whole dang thing:
158
 To run the whole dang thing:
158
 
159
 

+ 15
- 27
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')"
12
-  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
8
+- name: Deny everything and enable UFW
9
+  ufw: state=enabled policy=deny
26
 
10
 
27
-- name: Check status of ufw
28
-  command: ufw status
29
-  register: ufw_status
30
-  changed_when: False  # never report as "changed"
11
+- name: Set firewall rule for DNS
12
+  ufw: rule=allow port=domain
13
+
14
+- name: Set firewall rule for mosh
15
+  ufw: rule=allow port=60000:61000 proto=udp
16
+
17
+- name: Set firewall rules for web traffic and SSH
18
+  ufw: rule=allow port={{ item }} proto=tcp
19
+  with_items:
20
+    - ssh
21
+    - http
22
+    - https
31
 
23
 
32
 - name: Check config of ufw
24
 - name: Check config of ufw
33
   command: cat /etc/ufw/ufw.conf
25
   command: cat /etc/ufw/ufw.conf
35
   changed_when: False  # never report as "changed"
27
   changed_when: False  # never report as "changed"
36
 
28
 
37
 - name: Disable logging (workaround for known bug in Debian 7)
29
 - name: Disable logging (workaround for known bug in Debian 7)
38
-  command: ufw logging off
30
+  ufw: logging=off
39
   when: "ansible_lsb['codename'] == 'wheezy' and 'LOGLEVEL=off' not in ufw_config.stdout"
31
   when: "ansible_lsb['codename'] == 'wheezy' and 'LOGLEVEL=off' not in ufw_config.stdout"
40
-
41
-- name: Enable ufw
42
-  command: ufw --force enable
43
-  when: "ufw_status.stdout.startswith('Status: inactive') or 'ENABLED=yes' not in ufw_config.stdout"

+ 6
- 1
roles/git/tasks/cgit.yml View File

4
   with_items:
4
   with_items:
5
     - groff
5
     - groff
6
     - python-pip
6
     - python-pip
7
+    - libssl-dev
7
 
8
 
8
 - name: Install cgit pip dependencies
9
 - name: Install cgit pip dependencies
9
   pip: name={{ item }}
10
   pip: name={{ item }}
38
             owner=www-data
39
             owner=www-data
39
   notify: restart apache
40
   notify: restart apache
40
 
41
 
42
+- name: Enable Apache cgi module
43
+  command: a2enmod cgi creates=/etc/apache2/mods-enabled/cgi.load
44
+  notify: restart apache
45
+
41
 - name: Enable Apache rewrite module
46
 - name: Enable Apache rewrite module
42
   command: a2enmod rewrite creates=/etc/apache2/mods-enabled/rewrite.load
47
   command: a2enmod rewrite creates=/etc/apache2/mods-enabled/rewrite.load
43
   notify: restart apache
48
   notify: restart apache
44
 
49
 
45
 - name:  Enable cgit site
50
 - name:  Enable cgit site
46
   command: a2ensite cgit creates=/etc/apache2/sites-enabled/cgit
51
   command: a2ensite cgit creates=/etc/apache2/sites-enabled/cgit
47
-  notify: restart apache
52
+  notify: restart apache

+ 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

+ 0
- 1
roles/mailserver/templates/etc_postfix_main.cf.j2 View File

106
   bl.spamcop.net*2
106
   bl.spamcop.net*2
107
   dnsbl.sorbs.net*1
107
   dnsbl.sorbs.net*1
108
   spam.spamrats.com*2
108
   spam.spamrats.com*2
109
-  dnsbl.ahbl.org*2
110
 postscreen_dnsbl_threshold = 3
109
 postscreen_dnsbl_threshold = 3
111
 postscreen_dnsbl_action = enforce
110
 postscreen_dnsbl_action = enforce
112
 postscreen_greet_action = enforce
111
 postscreen_greet_action = enforce

+ 5
- 0
roles/newebe/files/newebe.conf View File

1
+[program:newebe]
2
+autorestart=false
3
+command=newebe_server.py --configfile=/usr/local/etc/newebe/config.yaml
4
+redirect_stderr=true
5
+user=newebe

+ 7
- 0
roles/newebe/files/supervisor.conf View File

1
+; supervisor config file
2
+
3
+[supervisord]
4
+nodaemon=true
5
+
6
+[include]
7
+files = /etc/supervisor/conf.d/*.conf

+ 0
- 0
roles/newebe/handlers/main.yml View File


+ 84
- 0
roles/newebe/tasks/main.yml View File

1
+- name: Install Python
2
+  apt: pkg=python,python-setuptools,python-pip,python-dev
3
+
4
+- name: Install Python tools
5
+  apt: pkg=python-imaging,python-pycurl
6
+
7
+- name: Install build tools
8
+  apt: pkg=build-essential,git
9
+
10
+- name: Install Python libs
11
+  apt: pkg=libxml2-dev,libxslt-dev,python-imaging
12
+
13
+- name: Install Supervisor
14
+  apt: pkg=supervisor
15
+
16
+- name: Install CouchDB
17
+  apt: pkg=couchdb
18
+
19
+- name: Install Newebe
20
+  pip: name='git+https://github.com/gelnior/newebe.git#egg=newebe'
21
+
22
+- name: Add group Newebe
23
+  group: name=newebe
24
+
25
+- name: Add user Newebe
26
+  user: name=newebe shell=/bin/bash groups=newebe
27
+
28
+- name: Create Newebe Config folder
29
+  file: path=/usr/local/etc/newebe/ 
30
+        owner=newebe 
31
+        group=newebe 
32
+        state=directory
33
+
34
+- name: Create Newebe folder
35
+  file: path=/usr/local/var/newebe/ 
36
+        owner=newebe 
37
+        group=newebe 
38
+        state=directory
39
+
40
+- name: Create Newebe log folder
41
+  file: path=/usr/local/var/log/newebe/ 
42
+        owner=newebe 
43
+        group=newebe 
44
+        state=directory
45
+
46
+- name: Set Newebe config file
47
+  template: src=usr_local_etc_newebe_config.j2
48
+            dest=/usr/local/etc/newebe/config.yaml 
49
+            owner=newebe 
50
+            group=newebe
51
+
52
+- name: Set Supervisor config file
53
+  copy: src=newebe.conf dest=/etc/supervisor/conf.d/newebe.conf
54
+
55
+- name: Set Newebe Supervisor config file
56
+  copy: src=supervisor.conf dest=/etc/supervisor/supervisor.conf
57
+
58
+- name: Reload Supervisor and start Newebe
59
+  command: /usr/bin/supervisorctl update
60
+
61
+- name: Ensure that newebe is started
62
+  supervisorctl: name=newebe state=started
63
+
64
+- name: Add mod_proxy module to Apache
65
+  raw: a2enmod proxy
66
+# When Ansible 1.6 will be available  
67
+# apache2_module: state=present name=proxy
68
+
69
+- name: Add proxy_http module to Apache
70
+  raw: a2enmod proxy_http
71
+# When Ansible 1.6 will be available  
72
+# apache2_module: state=present name=proxy_http
73
+#
74
+- name: Configure the Apache HTTP server for Newebe
75
+  template: src=etc_apache2_sites-available_newebe.j2
76
+            dest=/etc/apache2/sites-available/newebe
77
+            group=www-data
78
+            owner=www-data
79
+  notify: restart apache
80
+
81
+- name: Enable the site
82
+  command: a2ensite newebe
83
+           creates=/etc/apache2/sites-enabled/newebe
84
+  notify: restart apache

+ 27
- 0
roles/newebe/templates/etc_apache2_sites-available_newebe.j2 View File

1
+<VirtualHost *:80>
2
+    ServerName {{ newebe_domain }}
3
+
4
+    Redirect permanent / https://{{ newebe_domain }}/
5
+</VirtualHost>
6
+
7
+<VirtualHost *:443>
8
+
9
+    ServerName {{ newebe_domain }}
10
+    SSLEngine On
11
+
12
+    SSLProtocol ALL -SSLv2
13
+    SSLHonorCipherOrder On
14
+    SSLCipherSuite ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AES:RSA+3DES:!ADH:!AECDH:!MD5:!DSS
15
+    SSLCertificateFile /etc/ssl/certs/wildcard_public_cert.crt
16
+    SSLCertificateKeyFile /etc/ssl/private/wildcard_private.key
17
+    SSLCACertificateFile /etc/ssl/certs/wildcard_ca.pem
18
+    Header add Strict-Transport-Security "max-age=15768000; includeSubdomains"
19
+
20
+    ErrorLog /var/log/apache2/newebe.info-error_log
21
+    CustomLog /var/log/apache2/newebe.info-access_log common
22
+
23
+
24
+    ProxyPass / http://127.0.0.1:8282/
25
+    ProxyPassReverse / http://127.0.0.1:8282/
26
+
27
+</VirtualHost>

+ 7
- 0
roles/newebe/templates/usr_local_etc_newebe_config.j2 View File

1
+main:
2
+    port: 8282
3
+    debug: False
4
+    ssl: False
5
+    path: "/usr/local/var/newebe/"
6
+    logpath: "/usr/local/var/log/newebe"
7
+    timezone: {{ zpush_timezone }}

+ 1
- 1
roles/tarsnap/files/tarsnap.sh View File

25
 TARSNAP="/usr/local/bin/tarsnap"
25
 TARSNAP="/usr/local/bin/tarsnap"
26
 
26
 
27
 # Extra flags to pass to tarsnap
27
 # Extra flags to pass to tarsnap
28
-EXTRA_FLAGS="-C /"
28
+EXTRA_FLAGS="-L -C /"
29
 
29
 
30
 # end of config
30
 # end of config
31
 
31
 

+ 16
- 0
roles/tarsnap/tasks/tarsnap.yml View File

1
+- name: Check if tarsnap {{ tarsnap_version }} is installed
2
+  shell: tarsnap --version | grep {{ tarsnap_version }} --color=never
3
+  register: tarnsap_installed
4
+  changed_when: "tarnsap_installed.stderr != ''"
5
+  ignore_errors: yes
6
+
1
 - name: Install dependencies for Tarsnap
7
 - name: Install dependencies for Tarsnap
8
+  when: tarnsap_installed|failed
2
   apt: pkg={{ item }} state=installed
9
   apt: pkg={{ item }} state=installed
3
   with_items:
10
   with_items:
4
     - libssl-dev
11
     - libssl-dev
6
     - e2fslibs-dev
13
     - e2fslibs-dev
7
 
14
 
8
 - name: Download the current tarsnap code signing key
15
 - name: Download the current tarsnap code signing key
16
+  when: tarnsap_installed|failed
9
   get_url:
17
   get_url:
10
     url=https://www.tarsnap.com/tarsnap-signing-key.asc
18
     url=https://www.tarsnap.com/tarsnap-signing-key.asc
11
     dest=/root/tarsnap-signing-key.asc
19
     dest=/root/tarsnap-signing-key.asc
12
 
20
 
13
 - name: Add the tarsnap code signing key to your list of keys
21
 - name: Add the tarsnap code signing key to your list of keys
22
+  when: tarnsap_installed|failed
14
   command:
23
   command:
15
     gpg --import tarsnap-signing-key.asc
24
     gpg --import tarsnap-signing-key.asc
16
     chdir=/root/
25
     chdir=/root/
17
 
26
 
18
 - name: Download tarsnap SHA file
27
 - name: Download tarsnap SHA file
28
+  when: tarnsap_installed|failed
19
   get_url:
29
   get_url:
20
     url="https://www.tarsnap.com/download/tarsnap-sigs-{{ tarsnap_version }}.asc"
30
     url="https://www.tarsnap.com/download/tarsnap-sigs-{{ tarsnap_version }}.asc"
21
     dest="/root/tarsnap-sigs-{{ tarsnap_version }}.asc"
31
     dest="/root/tarsnap-sigs-{{ tarsnap_version }}.asc"
22
 
32
 
23
 - name: Make the command that gets the current sha
33
 - name: Make the command that gets the current sha
34
+  when: tarnsap_installed|failed
24
   template:
35
   template:
25
     src=getSha.sh
36
     src=getSha.sh
26
     dest=/root/getSha.sh
37
     dest=/root/getSha.sh
27
     mode=0755
38
     mode=0755
28
 
39
 
29
 - name: get the SHA256sum for this tarsnap release
40
 - name: get the SHA256sum for this tarsnap release
41
+  when: tarnsap_installed|failed
30
   command:
42
   command:
31
     ./getSha.sh
43
     ./getSha.sh
32
     chdir=/root
44
     chdir=/root
33
   register: tarsnap_sha
45
   register: tarsnap_sha
34
 
46
 
35
 - name: Download Tarsnap source
47
 - name: Download Tarsnap source
48
+  when: tarnsap_installed|failed
36
   get_url:
49
   get_url:
37
     url="https://www.tarsnap.com/download/tarsnap-autoconf-{{ tarsnap_version }}.tgz"
50
     url="https://www.tarsnap.com/download/tarsnap-autoconf-{{ tarsnap_version }}.tgz"
38
     dest="/root/tarsnap-autoconf-{{ tarsnap_version }}.tgz"
51
     dest="/root/tarsnap-autoconf-{{ tarsnap_version }}.tgz"
39
     sha256sum={{ tarsnap_sha.stdout_lines[0] }}
52
     sha256sum={{ tarsnap_sha.stdout_lines[0] }}
40
 
53
 
41
 - name: Decompress Tarsnap source
54
 - name: Decompress Tarsnap source
55
+  when: tarnsap_installed|failed
42
   command: tar xzf /root/tarsnap-autoconf-{{ tarsnap_version }}.tgz chdir=/root creates=/root/tarsnap-autoconf-{{ tarsnap_version }}/COPYING
56
   command: tar xzf /root/tarsnap-autoconf-{{ tarsnap_version }}.tgz chdir=/root creates=/root/tarsnap-autoconf-{{ tarsnap_version }}/COPYING
43
 
57
 
44
 - name: Configure Tarsnap for local build
58
 - name: Configure Tarsnap for local build
59
+  when: tarnsap_installed|failed
45
   command: ./configure chdir=/root/tarsnap-autoconf-{{ tarsnap_version }} creates=/root/tarsnap-autoconf-{{ tarsnap_version }}/Makefile
60
   command: ./configure chdir=/root/tarsnap-autoconf-{{ tarsnap_version }} creates=/root/tarsnap-autoconf-{{ tarsnap_version }}/Makefile
46
 
61
 
47
 - name: Build and install Tarsnap
62
 - name: Build and install Tarsnap
63
+  when: tarnsap_installed|failed
48
   command: make all install clean chdir=/root/tarsnap-autoconf-{{ tarsnap_version }} creates=/usr/local/bin/tarsnap
64
   command: make all install clean chdir=/root/tarsnap-autoconf-{{ tarsnap_version }} creates=/usr/local/bin/tarsnap
49
 
65
 
50
 - name: Copy Tarsnap key file into place
66
 - name: Copy Tarsnap key file into place

+ 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

+ 1
- 0
site.yml View File

22
     - tarsnap
22
     - tarsnap
23
     - news
23
     - news
24
     - git
24
     - git
25
+    - newebe
25
     - readlater
26
     - readlater

+ 3
- 0
vars/defaults.yml View File

106
 cgit_domain: "git.{{ domain }}"
106
 cgit_domain: "git.{{ domain }}"
107
 gitolite_version: 3.5.3.1
107
 gitolite_version: 3.5.3.1
108
 
108
 
109
+# newebe
110
+newebe_domain: "newebe.{{ domain }}"
111
+
109
 # wallabag
112
 # wallabag
110
 wallabag_version: 1.6.1b
113
 wallabag_version: 1.6.1b
111
 wallabag_domain: "read.{{ domain }}"
114
 wallabag_domain: "read.{{ domain }}"

Loading…
Cancel
Save