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

Proposed by Haw Loeung
Status: Merged
Approved by: Tom Haddon
Approved revision: 8cc808c745a1744bb688e1bd06847d0818647987
Merged at revision: 07d5e8623530146b15cd2c37afa29654f5c80ec7
Proposed branch: ~hloeung/mailman3-core-charm:master
Merge into: mailman3-core-charm:master
Diff against target: 76 lines (+15/-14)
3 files modified
config.yaml (+0/-4)
layer.yaml (+3/-2)
reactive/mailman3_core.py (+12/-8)
Reviewer Review Type Date Requested Status
Tom Haddon Approve
Review via email: mp+346439@code.launchpad.net

Commit message

Set proper status - LP: #1772399

Description of the change

Set proper status - LP: #1772399

Also, fix admin credential generation to only do so when it doesn't
exist.

Finally, don't always run apt purging, especially on update-status
hooks.

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
Tom Haddon (mthaddon) wrote :

LGTM

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

Change successfully merged at revision 07d5e8623530146b15cd2c37afa29654f5c80ec7

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 e5db6d3..6dfb59a 100644
3--- a/config.yaml
4+++ b/config.yaml
5@@ -1,8 +1,4 @@
6 options:
7- additional-packages:
8- type: string
9- default: ""
10- description: "Additional packages to install on the unit."
11 nagios_context:
12 default: "juju"
13 type: string
14diff --git a/layer.yaml b/layer.yaml
15index 52b8b6f..0582e0f 100644
16--- a/layer.yaml
17+++ b/layer.yaml
18@@ -1,9 +1,10 @@
19 repo: lp:mailman3-core-charm
20 includes:
21+ - 'layer:basic'
22+ - 'layer:apt'
23 - 'interface:generic-ip-port-user-pass'
24+ - 'interface:nrpe-external-master'
25 - 'interface:pgsql'
26- - 'layer:apt'
27- - 'layer:basic'
28 options:
29 apt:
30 packages:
31diff --git a/reactive/mailman3_core.py b/reactive/mailman3_core.py
32index 45a07f0..1e61cce 100644
33--- a/reactive/mailman3_core.py
34+++ b/reactive/mailman3_core.py
35@@ -37,14 +37,15 @@ def write_config():
36 @when_not('mailman.initial_setup')
37 def initial_setup():
38 db = unitdata.kv()
39- # Generate a relatively random password
40- chars = string.ascii_letters + string.digits
41- password = ''.join((random.choice(chars)) for x in range(40))
42- db.set('admin_password', password)
43- # Let's just hard set this for now, we can expose it in the juju config later
44- db.set('admin_user', 'restadmin')
45- db.set('admin_port', 8001)
46- db.set('admin_ip', hookenv.unit_get('private-address'))
47+ if not db.get('admin_password'):
48+ # Generate a relatively random password
49+ chars = string.ascii_letters + string.digits
50+ password = ''.join((random.choice(chars)) for x in range(40))
51+ db.set('admin_password', password)
52+ # Let's just hard set this for now, we can expose it in the juju config later
53+ db.set('admin_user', 'restadmin')
54+ db.set('admin_port', 8001)
55+ db.set('admin_ip', hookenv.unit_get('private-address'))
56 queue_install(['python3-mailman-hyperkitty'])
57 # Open the SMTP port
58 hookenv.open_port(25)
59@@ -58,6 +59,7 @@ def initial_setup():
60 @when_not('mailman.django.purged')
61 def purge_extra_mailman_crap():
62 purge('python-django-hyperkitty')
63+ set_flag('mailman.django.purged')
64
65
66 # When we connect to the database units, request our database and extensions
67@@ -86,7 +88,9 @@ def configure_database(pgsql):
68 @when('db.master.available')
69 @when('config.changed')
70 def write_updated_config():
71+ hookenv.status_set('maintenance', 'updating configuration')
72 write_config()
73+ hookenv.status_set('active', 'ready')
74
75
76 # Make sure we've got our REST API creds, then publish our relation data.

Subscribers

People subscribed via source and target branches