Merge ~hloeung/mailman3-core-charm:master into mailman3-core-charm:master

Proposed by Haw Loeung
Status: Merged
Approved by: Laurent Sesquès
Approved revision: f1c2f9bca9c8e1dde80318919912b120aca6ff28
Merged at revision: df40351eb2f552e99d7591ee0a08ca6cf5ba2710
Proposed branch: ~hloeung/mailman3-core-charm:master
Merge into: mailman3-core-charm:master
Diff against target: 81 lines (+18/-8)
3 files modified
config.yaml (+5/-0)
reactive/mailman3_core.py (+12/-7)
templates/mailman.tmpl (+1/-1)
Reviewer Review Type Date Requested Status
Laurent Sesquès Approve
Review via email: mp+347949@code.launchpad.net

Commit message

Prefer IPv4, otherwise we'll end up with issues such as talking to hosts IPv6 even though all we have are link-local addresses

Allow overriding site_owner, which is the e-mail used for subscription notifications and such.

Also make the postfix hash maps.

To post a comment you must log in.
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
Laurent Sesquès (sajoupa) :
review: Approve
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision df40351eb2f552e99d7591ee0a08ca6cf5ba2710

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/config.yaml b/config.yaml
2index 564d78b..8265ce4 100644
3--- a/config.yaml
4+++ b/config.yaml
5@@ -1,4 +1,9 @@
6 options:
7+ site_owner:
8+ default: admin@changeme.internal
9+ type: string
10+ description: |
11+ E-mail used by mailman for e-mail verifications etc.
12 hostname:
13 default: ""
14 type: string
15diff --git a/reactive/mailman3_core.py b/reactive/mailman3_core.py
16index 2437a75..3a99872 100644
17--- a/reactive/mailman3_core.py
18+++ b/reactive/mailman3_core.py
19@@ -30,7 +30,7 @@ def write_config():
20 group="list",
21 perms=0o640,
22 context={'config': config})
23- host.service('restart', 'mailman3')
24+ host.service_restart('mailman3')
25
26
27 # Once mailman is installed, we can generate our REST API password
28@@ -59,7 +59,6 @@ def configure_postfix():
29
30 myhostname = config.get('hostname', subprocess.getoutput(['hostname', '--fqdn']).strip())
31 subprocess.check_output(['postconf', 'myhostname={}'.format(myhostname)])
32-
33 smtpd_tls_cert_file = config.get('ssl_cert', '')
34 if not smtpd_tls_cert_file and os.path.exists('/etc/ssl/certs/ssl-cert-snakeoil.pem'):
35 smtpd_tls_cert_file = '/etc/ssl/certs/ssl-cert-snakeoil.pem'
36@@ -77,14 +76,19 @@ def configure_postfix():
37 subprocess.check_output(['postconf', 'smtp_tls_security_level=may',
38 'smtp_tls_policy_maps=hash:/etc/postfix/tls_policy'])
39 host.write_file('/etc/postfix/tls_policy', smtp_tls_policy_maps)
40+ subprocess.check_output(['postmap', '/etc/postfix/tls_policy'])
41
42- subprocess.check_output(['postconf', 'inet_interfaces=all',
43+ subprocess.check_output(['postconf', 'smtp_address_preference=ipv4', 'lmtp_address_preference=ipv4',
44 'default_transport=smtp', 'relay_transport=smtp',
45 'smtpd_relay_restrictions=permit_mynetworks defer_unauth_destination'])
46- subprocess.check_output(['postconf', 'transport_maps=hash:/var/lib/mailman3/data/postfix_lmtp',
47- 'local_recipient_maps=hash:/var/lib/mailman3/data/postfix_lmtp',
48- 'relay_domains=hash:/var/lib/mailman3/data/postfix_domains'])
49- subprocess.check_output(['postfix', 'reload'])
50+ if os.path.exists('/var/lib/mailman3/data/postfix_lmtp'):
51+ subprocess.check_output(['postconf', 'transport_maps=hash:/var/lib/mailman3/data/postfix_lmtp',
52+ 'local_recipient_maps=hash:/var/lib/mailman3/data/postfix_lmtp'])
53+ subprocess.check_output(['postmap', '/var/lib/mailman3/data/postfix_lmtp'])
54+ if os.path.exists('/var/lib/mailman3/data/postfix_domains'):
55+ subprocess.check_output(['postconf', 'relay_domains=hash:/var/lib/mailman3/data/postfix_domains'])
56+ subprocess.check_output(['postmap', '/var/lib/mailman3/data/postfix_domains'])
57+ host.service_reload('postfix')
58 # Open the SMTP port
59 hookenv.open_port(25)
60 set_flag('mailman.postfix.configured')
61@@ -128,6 +132,7 @@ def configure_database(pgsql):
62 @when('config.changed')
63 def write_updated_config():
64 hookenv.status_set('maintenance', 'updating configuration')
65+ clear_flag('mailman.postfix.configured')
66 write_config()
67 hookenv.status_set('active', 'ready')
68
69diff --git a/templates/mailman.tmpl b/templates/mailman.tmpl
70index f09886d..2508cff 100644
71--- a/templates/mailman.tmpl
72+++ b/templates/mailman.tmpl
73@@ -25,7 +25,7 @@
74 # delivered to a human, but which can't be delivered to a list owner (e.g. a
75 # bounce from a list owner), will be sent to this address. It should point to
76 # a human.
77-site_owner: changeme@example.com
78+site_owner: {{ config.site_owner }}
79
80 # This is the local-part of an email address used in the From field whenever a
81 # message comes from some entity to which there is no natural reply recipient.

Subscribers

People subscribed via source and target branches