Skip to content

Commit 29bcd5a

Browse files
committed
Add postfix
1 parent eafcd42 commit 29bcd5a

File tree

8 files changed

+114
-3
lines changed

8 files changed

+114
-3
lines changed

defaults/main.yml

+4
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ mailman3_distribute_maps_virtualenv_dir: "{{ mailman3_core_var_dir }}/distribute
354354

355355
# Base set of Python packages
356356
__mailman3_pip_packages:
357+
- importlib-resources==5.13.0
357358
- mailman
358359
- mailman-web
359360
- mailman-hyperkitty # ??
@@ -433,3 +434,6 @@ mailman3_install_nginx: true
433434
# Override this will a value similar to mailman3_web_url. Used in /etc/mailman3/hyperkitty.cfg:
434435
mailman3_hyperkitty_server_url: "http://localhost"
435436
mailman3_nginx_ssl_certs: "include snippets/snakeoil.conf;"
437+
mailman3_mta: postfix
438+
mailman3_relayhost: smtp.mailgun.org:587
439+
mailman3_sasl_passwd: smtp.mailgun.org [email protected]:12345

docs/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ mailman3_django_superusers:
4545
mailman3_archiver_key: ___
4646
mailman3_hyperkitty_server_url: 'https://mailman-staging.boost.cpp.al'
4747
48-
# Manually set this in /etc/postfix/main.cf. Ansible is not doing that.
48+
# Manually set this in /etc/postfix/main.cf. Now that ansible is installing main.cf, it should already be present.
4949
# transport_maps = hash:/var/lib/mailman3/data/postfix_lmtp
5050
# local_recipient_maps = hash:/var/lib/mailman3/data/postfix_lmtp
5151
# relay_domains = hash:/var/lib/mailman3/data/postfix_domains

handlers/main.yml

+11
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,14 @@
3333
ansible.builtin.service:
3434
name: nginx
3535
state: restarted
36+
37+
- name: Generate sasl_passwd.db
38+
ansible.builtin.command:
39+
cmd: postmap sasl_password
40+
chdir: /etc/postfix/sasl
41+
changed_when: always
42+
43+
- name: Restart postfix
44+
ansible.builtin.service:
45+
name: postfix
46+
state: restarted

tasks/config.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@
4747
ansible.builtin.cron:
4848
name: "mailman digests"
4949
special_time: daily
50-
job: "{{ mailman3_install_dir}}/bin/mailman digests --periodic"
50+
job: "{{ mailman3_install_dir }}/bin/mailman digests --periodic"
5151
user: "{{ __mailman3_core_user_name }}"
5252

5353
- name: Install notify cron task
5454
ansible.builtin.cron:
5555
name: "mailman notify"
5656
special_time: daily
57-
job: "{{ mailman3_install_dir}}/bin/mailman notify"
57+
job: "{{ mailman3_install_dir }}/bin/mailman notify"
5858
user: "{{ __mailman3_core_user_name }}"

tasks/main.yml

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
vars:
77
_mailman3_user: "{{ mailman3_core_user }}"
88

9+
- name: Install postfix
10+
ansible.builtin.include_tasks: postfix.yml
11+
when: mailman3_mta == "postfix"
12+
913
- name: Include web user creation tasks
1014
ansible.builtin.include_tasks: user.yml
1115
when: mailman3_create_web_user

tasks/postfix.yml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
- name: Install postfix
3+
ansible.builtin.package:
4+
name:
5+
- postfix
6+
- mailutils
7+
8+
- name: Install main.cf
9+
ansible.builtin.template:
10+
src: postfix_main.cf.j2
11+
dest: /etc/postfix/main.cf
12+
owner: root
13+
group: root
14+
mode: '0644'
15+
notify: Restart postfix
16+
17+
- name: Create sasl directory
18+
ansible.builtin.file:
19+
path: /etc/postfix/sasl
20+
state: directory
21+
mode: '0755'
22+
owner: root
23+
group: root
24+
25+
- name: Create sasl_passwd file
26+
ansible.builtin.template:
27+
src: sasl_passwd.j2
28+
dest: /etc/postfix/sasl/sasl_passwd
29+
owner: root
30+
group: root
31+
mode: '0600'
32+
notify: Generate sasl_passwd.db

templates/postfix_main.cf.j2

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# See /usr/share/postfix/main.cf.dist for a commented, more complete version
2+
3+
4+
# Debian specific: Specifying a file name will cause the first
5+
# line of that file to be used as the name. The Debian default
6+
# is /etc/mailname.
7+
#myorigin = /etc/mailname
8+
9+
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
10+
biff = no
11+
12+
# appending .domain is the MUA's job.
13+
append_dot_mydomain = no
14+
append_dot_mydomain = no
15+
16+
# Uncomment the next line to generate "delayed mail" warnings
17+
#delay_warning_time = 4h
18+
19+
readme_directory = no
20+
21+
# See http://www.postfix.org/COMPATIBILITY_README.html -- default to 3.6 on
22+
# fresh installs.
23+
compatibility_level = 3.6
24+
25+
26+
27+
# TLS parameters
28+
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
29+
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
30+
smtpd_tls_security_level=may
31+
32+
smtp_tls_CApath=/etc/ssl/certs
33+
smtp_tls_security_level=may
34+
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
35+
36+
37+
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
38+
myhostname = {{ inventory_hostname }}
39+
alias_maps = hash:/etc/aliases
40+
alias_database = hash:/etc/aliases
41+
myorigin = /etc/mailname
42+
mydestination = $myhostname, localhost
43+
relayhost = {{ mailman3_relayhost }}
44+
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
45+
mailbox_size_limit = 0
46+
recipient_delimiter = +
47+
inet_interfaces = all
48+
inet_protocols = all
49+
50+
smtp_sasl_auth_enable = yes
51+
smtp_sasl_password_maps = hash:/etc/postfix/sasl/sasl_passwd
52+
smtp_sasl_security_options = noanonymous
53+
#smtp_sasl_tls_security_options = noanonymous
54+
smtp_sasl_mechanism_filter = AUTH LOGIN
55+
permit_sasl_authenticated = defer_unauth_destinations
56+
57+
transport_maps = hash:/var/lib/mailman3/data/postfix_lmtp
58+
local_recipient_maps = hash:/var/lib/mailman3/data/postfix_lmtp
59+
relay_domains = hash:/var/lib/mailman3/data/postfix_domains

templates/sasl_passwd.j2

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{ mailman3_sasl_passwd }}

0 commit comments

Comments
 (0)