Skip to content

Commit 527582d

Browse files
authored
Merge pull request #290 from progmaticltd/dev
New version for 2020
2 parents b11f97d + 84f78dd commit 527582d

File tree

336 files changed

+6054
-2326
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

336 files changed

+6054
-2326
lines changed

.ansible-lint

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
config/ansible-lint-default.yml

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Ignore everything on the config folder, except sample and default files
22
config/*
33
!config/defaults.yml
4+
!config/*-default*.yml
45
!config/*-example.yml
56

67
# Ignore ansible error files
@@ -20,3 +21,10 @@ sandbox/*
2021
# Backup folder for deployment files
2122
backup/*
2223
!backup/readme.md
24+
25+
# Allow to include modules excluded from the repository
26+
modules/*
27+
!modules/readme.md
28+
29+
# Ignore python3 cache directories
30+
__pycache__/

.travis.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ official documentation.
166166
- Email addresses with recipient delimiter included, e.g. [email protected].
167167
- Optional master user creation, e.g. for families with children or moderated communities.
168168
- Server side full text search inside emails, attached documents and files and
169+
- Detailed weekly, monthly and yearly access report per country, ISP, IP addresses, etc.
169170
compressed archives, with better results than GMail.
170171
- Optional Roundcube webmail with sieve filters management, password change form, automatic identity
171172
creation, master account access, etc.
@@ -195,10 +196,8 @@ official documentation.
195196
- [Privoxy](https://www.privoxy.org/) easy installation, with adblock rules daily synchronisation, and optional tor
196197
chaining.
197198
- Embedded DNS server with DNSSEC and SSHFP (SSH fingerprint) records support
198-
- Automatic publication of DNS entries to Gandi DNS.
199199
- External IP address detection.
200-
- Static web site skeleton configuration, with https certificates.
201-
- Hugo web site server: [Hugo](https://gohugo.io/) and its [numerous themes](https://themes.gohugo.io/)
200+
- Static web site skeleton configuration, with https certificates and A+ security grade by default.
202201
- Personal backup server for each user, using borgbackup.
203202
- [Gogs git server](https://gogs.io/), a fast and lightweight git server written in Golang.
204203
- [Transmission daemon](https://transmissionbt.com/), accessible over https, public or private over your LAN. Files can

common/ansible-travis.cfg

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
---
2+
3+
- name: Get the certificates list
4+
register: certs
5+
find:
6+
path: '/etc/letsencrypt/archive/{{ cert_dir }}'
7+
recurse: yes
8+
patterns: 'cert*,chain*,fullchain*'
9+
10+
- name: Get the keys list
11+
register: keys
12+
find:
13+
path: '/etc/letsencrypt/archive/{{ cert_dir }}'
14+
recurse: yes
15+
patterns: 'privkey*'
16+
17+
# By default, consider the access to the private key is requested.
18+
# This might change to be explicitely requested by the caller task.
19+
- name: Set the default value of the "access_private_key" flag
20+
when: access_private_key is not defined
21+
set_fact:
22+
access_private_key: true
23+
24+
# Posix permissions: files should be readable, by default, only by root.
25+
# The ACL will extend this to other daemons
26+
- name: Set the unix mode for the certificate files readable by root only
27+
tags: cert
28+
file:
29+
path: '{{ file.path }}'
30+
owner: root
31+
group: root
32+
mode: '0600'
33+
with_items:
34+
- '{{ certs.files | selectattr("mode", "ne", "0600") | list }}'
35+
- '{{ keys.files | selectattr("mode", "ne", "0600") | list }}'
36+
loop_control:
37+
loop_var: file
38+
39+
# Now, we set the default acl for this directory: new certificates
40+
# will be automatically marked as readable by the entity.
41+
# This doesn't need to be done for nginx, as the certificates
42+
# are read by root anyway.
43+
- name: Set the acl and default acl permissions for the directory
44+
when: access_private_key
45+
tags: cert
46+
acl:
47+
path: '{{ path }}'
48+
entity: '{{ entity_group }}'
49+
etype: user
50+
permissions: 'r'
51+
recursive: false
52+
state: present
53+
default: true
54+
with_items:
55+
- '/etc/letsencrypt/archive/{{ cert_dir }}'
56+
loop_control:
57+
loop_var: path
58+
59+
# Create the list of files to modify. When the entity is nginx,
60+
# do not include the private key
61+
- name: Create the list of files to modify
62+
when: not access_private_key
63+
set_fact:
64+
files_list: '{{ certs.files }}'
65+
66+
# In this case, this is a specific entity (e.g. openldap)
67+
# we include the private key too.
68+
- name: Create the list of files to modify
69+
when: access_private_key
70+
set_fact:
71+
files_list: '{{ certs.files + keys.files }}'
72+
73+
# Explicitly set the mask for this files as read. Because the parent
74+
# directory permissions are '0777', any ACL modification would create
75+
# a mask as executable! This flaw is in the acl command, not ansible.
76+
- name: Set the acl mask for the files
77+
tags: cert
78+
acl:
79+
path: '{{ file.path }}'
80+
etype: mask
81+
state: present
82+
permissions: 'r'
83+
with_items:
84+
- '{{ files_list }}'
85+
loop_control:
86+
loop_var: file
87+
88+
# Finally, we set the existing certificates ACLs to be readable by
89+
# the entity. This is crucial, especially when restoring certificates
90+
# Do not recalculate the mask, or the files will be marked as executable!
91+
# This flaw is done by the acl command, not ansible.
92+
- name: Set the acl for the files
93+
tags: cert
94+
acl:
95+
path: '{{ file.path }}'
96+
etype: user
97+
entity: '{{ entity_group }}'
98+
state: present
99+
permissions: 'r'
100+
recalculate_mask: no_mask
101+
with_items:
102+
- '{{ files_list }}'
103+
loop_control:
104+
loop_var: file

common/roles/external-ip-type/tasks/main.yml

Lines changed: 16 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -2,105 +2,36 @@
22

33
################################################################################
44
# Get the external IP address, from configuration file,
5-
# or automatically through a script
6-
7-
# Automatic IP detection (IPv4 & IPv6)
8-
- name: Get the external IP address automatically
9-
tags: facts
10-
when: network.external_ip == "auto"
11-
get_url:
12-
url: https://api.ipify.org?format=text
13-
dest: /tmp/external_ip.txt
14-
15-
- name: Get the external IP address automatically (IPv6)
16-
tags: facts
17-
when: network.external_ip == "auto_ipv6"
18-
get_url:
19-
url: https://api6.ipify.org?format=text
20-
dest: /tmp/external_ip.txt
21-
22-
- name: Read the IP address detected
23-
register: external_ip_facts
24-
tags: facts
25-
when: network.external_ip is search("auto")
26-
shell: "cat /tmp/external_ip.txt"
27-
28-
- name: Store the IP address detected
29-
tags: facts
30-
when: network.external_ip is search("auto")
31-
set_fact:
32-
external_ip: '{{ external_ip_facts.stdout }}'
5+
# Check if a backup IP address is used
6+
# Detect both types of IP addresses
7+
# Detect if IPv6 is used
8+
################################################################################
339

34-
# Manual IP specification
10+
# First IP address, mandatory
3511
- name: Store the extenal IP address specified manually
3612
tags: facts
37-
when: not network.external_ip is search("auto")
3813
set_fact:
3914
external_ip: '{{ network.external_ip }}'
4015

41-
# Detect the main IP address type (IPv4 or IPv6)
42-
- name: Detect the external IP address type (IPv4 or IPv6 / A or AAAA)
43-
tags: facts
44-
register: main_ip_type
45-
shell:
46-
echo {{ external_ip }}
47-
| grep -E '^[0-9\.]+$' 2>&1 >/dev/null
48-
&& echo A || echo AAAA
49-
50-
- name: Store the external IP address type detected
16+
- name: Set external IP address type (A or AAAA)
5117
tags: facts
5218
set_fact:
53-
external_ip_type: '{{ (main_ip_type.stdout) }}'
54-
55-
19+
external_ip_type: '{{ external_ip | ipv6 | ternary("AAAA", "A") }}'
5620

57-
################################################################################
58-
# Backup IP address
59-
- name: Get the backup IP address automatically
60-
tags: facts
61-
when: network.backup_ip == "auto"
62-
get_url:
63-
url: https://api.ipify.org?format=text
64-
dest: /tmp/backup_ip.txt
65-
66-
- name: Get the backup IP address automatically (IPv6)
67-
tags: facts
68-
when: network.backup_ip == "auto_ipv6"
69-
get_url:
70-
url: https://api6.ipify.org?format=text
71-
dest: /tmp/backup_ip.txt
72-
73-
- name: Read the backup IP address detected
74-
register: backup_ip_facts
75-
tags: facts
76-
when: network.backup_ip is search("auto")
77-
shell: "cat /tmp/backup_ip.txt"
78-
79-
- name: Store the backup IP address detected
80-
tags: facts
81-
when: network.backup_ip is search("auto")
82-
set_fact:
83-
backup_ip: '{{ backup_ip_facts.stdout }}'
84-
85-
# Manual IP specification
86-
- name: Get the backup IP address specified manually
87-
when: network.backup_ip != None and not network.backup_ip is search("auto")
21+
# Backup IP address if defined
22+
- name: Get the backup IP address
23+
when: network.backup_ip != None and (network.backup_ip | length > 0)
8824
tags: facts
8925
set_fact:
9026
backup_ip: '{{ network.backup_ip }}'
9127

92-
# Detect the backup IP address type (IPv4 or IPv6)
9328
- name: Set backup IP address type (A or AAAA)
94-
when: network.backup_ip != None
9529
tags: facts
96-
register: backup_ip_type
97-
shell:
98-
echo {{ backup_ip }}
99-
| grep -E '^[0-9\.]+$' 2>&1 >/dev/null
100-
&& echo A || echo AAAA
30+
when: backup_ip is defined and (backup_ip | length > 0)
31+
set_fact:
32+
backup_ip_type: '{{ backup_ip | ipv6 | ternary("AAAA", "A") }}'
10133

102-
- name: Set backup IP address type (A or AAAA)
103-
tags: facts
104-
when: network.backup_ip != None
34+
- name: Check and remember if IPv6 is used
10535
set_fact:
106-
backup_ip_type: '{{ (backup_ip_type.stdout) }}'
36+
ipv6_used: '{{ external_ip_type == "AAAA" or
37+
(backup_ip_type is defined and backup_ip_type == "AAAA") }}'

common/roles/load-defaults/tasks/main.yml

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,15 @@
4242
# Merge user options with default options
4343
- name: Combine default and user defined password settings
4444
run_once: true
45+
no_log: true
4546
when: passwords is defined
4647
tags: defaults
4748
set_fact:
4849
passwords: '{{ passwords_default | combine(passwords, recursive=True) }}'
4950

5051
- name: Use default passwords settings
5152
run_once: true
53+
no_log: true
5254
when: passwords is not defined
5355
tags: defaults
5456
set_fact:
@@ -118,7 +120,6 @@
118120
set_fact:
119121
dictionaries: '{{ dictionaries_default }}'
120122

121-
################################################################################
122123
# Merge webmail defaults
123124
- name: Combine default and user defined webmail settings
124125
run_once: true
@@ -362,22 +363,6 @@
362363
set_fact:
363364
sogo: '{{ sogo_default }}'
364365

365-
################################################################################
366-
# Merge defaults hugo settings
367-
- name: Combine default and user defined hugo settings
368-
run_once: true
369-
when: hugo is defined
370-
tags: defaults
371-
set_fact:
372-
hugo: '{{ hugo_default | combine(hugo, recursive=True) }}'
373-
374-
- name: Use default hugo settings
375-
run_once: true
376-
when: hugo is not defined
377-
tags: defaults
378-
set_fact:
379-
hugo: '{{ hugo_default }}'
380-
381366
################################################################################
382367
# Merge defaults access_check settings
383368
- name: Combine default and user defined access_check settings

config/ansible-lint-default.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
3+
# This is a temporary ansible-lint file, to be able to start from a clean base.
4+
# We may uncomment some of the warnings once we find a proper way to fix them
5+
6+
# It is currently used by the CI environment (Jenkins) and the pre-commit hook
7+
8+
# Some files cannot be found by ansible lint, when using include_tasks.
9+
# See https://github.com/ansible/ansible-lint/issues/507
10+
# These files are excluded for now
11+
12+
# The current disabled warnings are:
13+
14+
# 701: No 'galaxy_info' found.
15+
# Not sure yet how to fix this, cannot find doc online yet.
16+
17+
# 503: Tasks that run when changed should likely be handlers.
18+
# This one should be fixed.
19+
20+
# 305: Use shell only when shell functionality is required
21+
# For this project, too many commands relies on shell scripts
22+
23+
# 301: Commands should not change things if nothing needs doing
24+
# Maybe some of the commands can be made as handlers
25+
26+
exclude_paths:
27+
- install/playbooks/roles/ldap/tasks/main.yml
28+
- install/playbooks/roles/postfix/tasks/main.yml
29+
- install/playbooks/roles/dovecot/tasks/main.yml
30+
parseable: true
31+
quiet: false
32+
rulesdir: []
33+
skip_list:
34+
- '701' # No 'galaxy_info' found
35+
- '503' # Tasks that run when changed should likely be handlers
36+
- '305' # Use shell only when shell functionality is required
37+
- '301' # Commands should not change things if nothing needs doing
38+
tags: []
39+
use_default_rules: true
40+
verbosity: 1

0 commit comments

Comments
 (0)