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

Proposed by Haw Loeung
Status: Merged
Approved by: Barry Price
Approved revision: b5570d90fecba2a1065a5f0d89418e80fff49aba
Merged at revision: 879a011f01545c08b5fa502610f951c5c66bccd3
Proposed branch: ~hloeung/mailman3-core-charm:master
Merge into: mailman3-core-charm:master
Diff against target: 70 lines (+19/-3)
3 files modified
layer.yaml (+1/-0)
reactive/mailman3_core.py (+17/-2)
templates/mailman.tmpl (+1/-1)
Reviewer Review Type Date Requested Status
Barry Price Approve
Review via email: mp+347249@code.launchpad.net

Commit message

Ensure postfix is installed and configure it up

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
Barry Price (barryprice) wrote :

+1

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

Change successfully merged at revision 879a011f01545c08b5fa502610f951c5c66bccd3

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/layer.yaml b/layer.yaml
2index 0582e0f..d297df3 100644
3--- a/layer.yaml
4+++ b/layer.yaml
5@@ -9,3 +9,4 @@ options:
6 apt:
7 packages:
8 - mailman3
9+ - postfix
10diff --git a/reactive/mailman3_core.py b/reactive/mailman3_core.py
11index 31c2d23..99013c4 100644
12--- a/reactive/mailman3_core.py
13+++ b/reactive/mailman3_core.py
14@@ -1,5 +1,6 @@
15-import string
16 import random
17+import string
18+import subprocess
19 from charms.apt import purge, queue_install
20 from charms.reactive import clear_flag, endpoint_from_flag, set_flag, when, when_any, when_not # noqa: F401
21 from charmhelpers.core import hookenv, unitdata
22@@ -47,9 +48,21 @@ def initial_setup():
23 db.set('admin_port', 8001)
24 db.set('admin_ip', hookenv.unit_get('private-address'))
25 queue_install(['python3-mailman-hyperkitty'])
26+ set_flag('mailman.initial_setup')
27+
28+
29+@when('apt.installed.postfix')
30+@when_not('mailman.postfix.configured')
31+def configure_postfix():
32+ hookenv.status_set('maintenance', 'configuring postfix for posts to mailing lists')
33+ subprocess.check_output(['postconf', 'transport_maps=hash:/var/lib/mailman3/data/postfix_lmtp',
34+ 'local_recipient_maps=hash:/var/lib/mailman3/data/postfix_lmtp',
35+ 'relay_domains=hash:/var/lib/mailman3/data/postfix_domains'])
36+ subprocess.check_output(['postfix', 'reload'])
37 # Open the SMTP port
38 hookenv.open_port(25)
39- set_flag('mailman.initial_setup')
40+ set_flag('mailman.postfix.configured')
41+ hookenv.status_set('active', 'ready')
42
43
44 # HyperKitty's recommended dependencies include, basically, all of Django so
45@@ -160,6 +173,7 @@ def setup_nagios(nagios):
46 if hookenv.hook_name() == 'update-status':
47 return
48
49+ hookenv.status_set('maintenance', 'setting up NRPE checks')
50 # Ask charmhelpers.contrib.charmsupport's nrpe to work out our hostname
51 hostname = nrpe.get_nagios_hostname()
52 nrpe_setup = nrpe.NRPE(hostname=hostname)
53@@ -182,3 +196,4 @@ def setup_nagios(nagios):
54 nrpe_setup.add_check('postfix_port', 'Check postfix port', postfix_check)
55
56 nrpe_setup.write()
57+ hookenv.status_set('active', 'ready')
58diff --git a/templates/mailman.tmpl b/templates/mailman.tmpl
59index 2039bba..f09886d 100644
60--- a/templates/mailman.tmpl
61+++ b/templates/mailman.tmpl
62@@ -258,7 +258,7 @@ smtp_pass:
63 # Where the LMTP server listens for connections. Use 127.0.0.1 instead of
64 # localhost for Postfix integration, because Postfix only consults DNS
65 # (e.g. not /etc/hosts).
66-lmtp_host: 127.0.0.1
67+lmtp_host: localhost
68 lmtp_port: 8024
69
70 # Where can we find the mail server specific configuration file? The path can

Subscribers

People subscribed via source and target branches