Merge ~hopem/charm-nagios:bug/1844658 into ~nagios-charmers/charm-nagios:master

Proposed by Edward Hope-Morley
Status: Merged
Approved by: Haw Loeung
Approved revision: 343ed3bcfdfdeff5c87604163a230a4319ec9cbe
Merged at revision: 282cb0948760c2309705fab734fca951d79ad0a1
Proposed branch: ~hopem/charm-nagios:bug/1844658
Merge into: ~nagios-charmers/charm-nagios:master
Diff against target: 60 lines (+16/-5)
3 files modified
config.yaml (+6/-0)
hooks/templates/contacts-cfg.tmpl (+1/-1)
hooks/upgrade-charm (+9/-4)
Reviewer Review Type Date Requested Status
Haw Loeung +1 Approve
James Hebden (community) Approve
Canonical IS Reviewers Pending
Review via email: mp+376818@code.launchpad.net

Commit message

Make admins contactgroup membership configurable

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
Joel Sing (jsing) wrote :

Change looks fine, but see comment inline. You'll also likely need to rebase this change.

Revision history for this message
Edward Hope-Morley (hopem) :
Revision history for this message
Edward Hope-Morley (hopem) wrote :

responded inline, will fixup

Revision history for this message
Edward Hope-Morley (hopem) wrote :

patch updated

Revision history for this message
James Hebden (ec0) wrote :

LGTM

review: Approve
Revision history for this message
Haw Loeung (hloeung) wrote :

LGTM

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

Change successfully merged at revision 282cb0948760c2309705fab734fca951d79ad0a1

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 da83582..4fb975c 100644
3--- a/config.yaml
4+++ b/config.yaml
5@@ -11,6 +11,12 @@ options:
6 default: true
7 description: |
8 Enable flap detection on monitored hosts and services.
9+ contactgroup-members:
10+ type: string
11+ default: "root"
12+ description: |
13+ Comma separated list of contacts to add as members of the admins
14+ group.
15 ssl:
16 type: string
17 default: "off"
18diff --git a/hooks/templates/contacts-cfg.tmpl b/hooks/templates/contacts-cfg.tmpl
19index 24a1372..34cf6ff 100644
20--- a/hooks/templates/contacts-cfg.tmpl
21+++ b/hooks/templates/contacts-cfg.tmpl
22@@ -46,6 +46,6 @@ define contact{
23 define contactgroup{
24 contactgroup_name admins
25 alias Nagios Administrators
26- members root{% if enable_pagerduty -%}, pagerduty{% endif %}
27+ members {{ contactgroup_members }}
28 }
29
30diff --git a/hooks/upgrade-charm b/hooks/upgrade-charm
31index 9edf436..1016391 100755
32--- a/hooks/upgrade-charm
33+++ b/hooks/upgrade-charm
34@@ -121,8 +121,7 @@ def enable_pagerduty_config():
35 proxy_switch = '--proxy {}'.format(proxy) if proxy else ''
36
37 # Ship the pagerduty_nagios.cfg file
38- template_values = {'enable_pagerduty': enable_pagerduty,
39- 'pagerduty_key': pagerduty_key,
40+ template_values = {'pagerduty_key': pagerduty_key,
41 'pagerduty_path': pagerduty_path,
42 'proxy_switch': proxy_switch,
43 'notification_levels': notification_levels}
44@@ -161,8 +160,14 @@ def enable_pagerduty_config():
45 os.remove(pagerduty_cron)
46
47 # Update contacts for admin
48- template_values = {'enable_pagerduty': enable_pagerduty,
49- 'admin_email': hookenv.config('admin_email')}
50+ contactgroup_members = hookenv.config("contactgroup-members")
51+ if enable_pagerduty:
52+ # avoid duplicates
53+ if "pagerduty" not in contactgroup_members:
54+ contactgroup_members += ", pagerduty"
55+
56+ template_values = {'admin_email': hookenv.config('admin_email'),
57+ 'contactgroup_members': contactgroup_members}
58
59 with open('hooks/templates/contacts-cfg.tmpl', 'r') as f:
60 templateDef = f.read()

Subscribers

People subscribed via source and target branches