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
diff --git a/config.yaml b/config.yaml
index da83582..4fb975c 100644
--- a/config.yaml
+++ b/config.yaml
@@ -11,6 +11,12 @@ options:
11 default: true11 default: true
12 description: |12 description: |
13 Enable flap detection on monitored hosts and services.13 Enable flap detection on monitored hosts and services.
14 contactgroup-members:
15 type: string
16 default: "root"
17 description: |
18 Comma separated list of contacts to add as members of the admins
19 group.
14 ssl:20 ssl:
15 type: string21 type: string
16 default: "off"22 default: "off"
diff --git a/hooks/templates/contacts-cfg.tmpl b/hooks/templates/contacts-cfg.tmpl
index 24a1372..34cf6ff 100644
--- a/hooks/templates/contacts-cfg.tmpl
+++ b/hooks/templates/contacts-cfg.tmpl
@@ -46,6 +46,6 @@ define contact{
46define contactgroup{46define contactgroup{
47 contactgroup_name admins47 contactgroup_name admins
48 alias Nagios Administrators48 alias Nagios Administrators
49 members root{% if enable_pagerduty -%}, pagerduty{% endif %}49 members {{ contactgroup_members }}
50 }50 }
5151
diff --git a/hooks/upgrade-charm b/hooks/upgrade-charm
index 9edf436..1016391 100755
--- a/hooks/upgrade-charm
+++ b/hooks/upgrade-charm
@@ -121,8 +121,7 @@ def enable_pagerduty_config():
121 proxy_switch = '--proxy {}'.format(proxy) if proxy else ''121 proxy_switch = '--proxy {}'.format(proxy) if proxy else ''
122122
123 # Ship the pagerduty_nagios.cfg file123 # Ship the pagerduty_nagios.cfg file
124 template_values = {'enable_pagerduty': enable_pagerduty,124 template_values = {'pagerduty_key': pagerduty_key,
125 'pagerduty_key': pagerduty_key,
126 'pagerduty_path': pagerduty_path,125 'pagerduty_path': pagerduty_path,
127 'proxy_switch': proxy_switch,126 'proxy_switch': proxy_switch,
128 'notification_levels': notification_levels}127 'notification_levels': notification_levels}
@@ -161,8 +160,14 @@ def enable_pagerduty_config():
161 os.remove(pagerduty_cron)160 os.remove(pagerduty_cron)
162161
163 # Update contacts for admin162 # Update contacts for admin
164 template_values = {'enable_pagerduty': enable_pagerduty,163 contactgroup_members = hookenv.config("contactgroup-members")
165 'admin_email': hookenv.config('admin_email')}164 if enable_pagerduty:
165 # avoid duplicates
166 if "pagerduty" not in contactgroup_members:
167 contactgroup_members += ", pagerduty"
168
169 template_values = {'admin_email': hookenv.config('admin_email'),
170 'contactgroup_members': contactgroup_members}
166171
167 with open('hooks/templates/contacts-cfg.tmpl', 'r') as f:172 with open('hooks/templates/contacts-cfg.tmpl', 'r') as f:
168 templateDef = f.read()173 templateDef = f.read()

Subscribers

People subscribed via source and target branches