Merge ~aggkolaitis/charm-nagios:change_nagios_gui_username into ~nagios-charmers/charm-nagios:master

Proposed by Angelos Kolaitis
Status: Merged
Approved by: Xav Paice
Approved revision: 06b9eee99d28253ea89b8c5f1ea1bfeb438d75cb
Merged at revision: e3e2f757faa38e825a0cbf38e90c0f1ce876679e
Proposed branch: ~aggkolaitis/charm-nagios:change_nagios_gui_username
Merge into: ~nagios-charmers/charm-nagios:master
Diff against target: 244 lines (+39/-35)
3 files modified
config.yaml (+8/-4)
hooks/templates/nagios-cgi.tmpl (+25/-28)
hooks/upgrade-charm (+6/-3)
Reviewer Review Type Date Requested Status
Andrea Ieri Approve
Stuart Bishop (community) Approve
Canonical IS Reviewers Pending
Nagios Charm developers Pending
Review via email: mp+374089@code.launchpad.net

Commit message

Added a configuration option to change default 'nagiosadmin' user name

LP: 1671831

Description of the change

Added a configuration option to change default 'nagiosadmin' user name

LP: 1671831

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
Stuart Bishop (stub) wrote :

Looks good. Some minor issues inline, nothing particularly important. Still needs a ~nagios-charmers review.

review: Approve
Revision history for this message
Angelos Kolaitis (aggkolaitis) wrote :

Thanks for the initial review, the code should be OK now.

Revision history for this message
Andrea Ieri (aieri) wrote :

Looks good. Just a very minor nit inline.
Also, for the future: whitespace fixes are welcome, but I think it would be cleaner to keep them in a separate 'noop' commit.

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

Change successfully merged at revision e3e2f757faa38e825a0cbf38e90c0f1ce876679e

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 4ce0f18..f116659 100644
--- a/config.yaml
+++ b/config.yaml
@@ -104,8 +104,8 @@ options:
104 admin_pager:104 admin_pager:
105 type: string105 type: string
106 default: pageroot@localhost106 default: pageroot@localhost
107 description: |107 description: >
108 Email address used for the admin pager, used by $ADMINPAGER$ in 108 Email address used for the admin pager, used by $ADMINPAGER$ in
109 notification commands.109 notification commands.
110 enable_pagerduty:110 enable_pagerduty:
111 type: boolean111 type: boolean
@@ -137,6 +137,11 @@ options:
137 default: 1137 default: 1
138 description: |138 description: |
139 Log messages to syslog as well as main file.139 Log messages to syslog as well as main file.
140 nagiosadmin:
141 type: string
142 default: 'nagiosadmin'
143 description: >
144 Username for Nagios admin user.
140 password:145 password:
141 type: string146 type: string
142 default: ''147 default: ''
@@ -168,7 +173,7 @@ options:
168 type: string173 type: string
169 description: |174 description: |
170 A string to pass to the Nagios load monitoring command. Default is175 A string to pass to the Nagios load monitoring command. Default is
171 to report warning at 5.0, 4.0 and 3.0 averages, critical at 10.0, 176 to report warning at 5.0, 4.0 and 3.0 averages, critical at 10.0,
172 6.0 and 4.0.177 6.0 and 4.0.
173 pagerduty_notification_levels:178 pagerduty_notification_levels:
174 default: u,c,r179 default: u,c,r
@@ -206,4 +211,3 @@ options:
206 u - Unknown211 u - Unknown
207 w - Warning212 w - Warning
208 o - OK213 o - OK
209
diff --git a/hooks/templates/nagios-cgi.tmpl b/hooks/templates/nagios-cgi.tmpl
index 11cb275..443a1ed 100644
--- a/hooks/templates/nagios-cgi.tmpl
+++ b/hooks/templates/nagios-cgi.tmpl
@@ -1,6 +1,6 @@
1#################################################################1#################################################################
2#2#
3# CGI.CFG - Sample CGI Configuration File for Nagios 3# CGI.CFG - Sample CGI Configuration File for Nagios
4#4#
5#################################################################5#################################################################
66
@@ -72,9 +72,9 @@ nagios_check_command=/usr/lib/nagios/plugins/check_nagios /var/cache/nagios3/sta
7272
7373
74# AUTHENTICATION USAGE74# AUTHENTICATION USAGE
75# This option controls whether or not the CGIs will use any 75# This option controls whether or not the CGIs will use any
76# authentication when displaying host and service information, as76# authentication when displaying host and service information, as
77# well as committing commands to Nagios for processing. 77# well as committing commands to Nagios for processing.
78#78#
79# Read the HTML documentation to learn how the authorization works!79# Read the HTML documentation to learn how the authorization works!
80#80#
@@ -116,7 +116,7 @@ use_ssl_authentication=0
116# access to the CGIs has been authenticated in some manner! If you116# access to the CGIs has been authenticated in some manner! If you
117# define this variable, anyone who has not authenticated to the web117# define this variable, anyone who has not authenticated to the web
118# server will inherit all rights you assign to this user!118# server will inherit all rights you assign to this user!
119 119
120#default_user_name=guest120#default_user_name=guest
121121
122122
@@ -129,7 +129,7 @@ use_ssl_authentication=0
129# not use authorization. You may use an asterisk (*) to129# not use authorization. You may use an asterisk (*) to
130# authorize any user who has authenticated to the web server.130# authorize any user who has authenticated to the web server.
131131
132authorized_for_system_information=nagiosadmin132authorized_for_system_information={{ nagiosadmin }}
133133
134134
135135
@@ -141,7 +141,7 @@ authorized_for_system_information=nagiosadmin
141# an asterisk (*) to authorize any user who has authenticated141# an asterisk (*) to authorize any user who has authenticated
142# to the web server.142# to the web server.
143143
144authorized_for_configuration_information=nagiosadmin144authorized_for_configuration_information={{ nagiosadmin }}
145145
146146
147147
@@ -154,7 +154,7 @@ authorized_for_configuration_information=nagiosadmin
154# You may use an asterisk (*) to authorize any user who has154# You may use an asterisk (*) to authorize any user who has
155# authenticated to the web server.155# authenticated to the web server.
156156
157authorized_for_system_commands=nagiosadmin157authorized_for_system_commands={{ nagiosadmin }}
158158
159159
160160
@@ -169,11 +169,11 @@ authorized_for_system_commands=nagiosadmin
169169
170{%if ro_password%}170{%if ro_password%}
171authorized_for_read_only=nagiosro171authorized_for_read_only=nagiosro
172authorized_for_all_services=nagiosadmin,nagiosro172authorized_for_all_services={{ nagiosadmin }},nagiosro
173authorized_for_all_hosts=nagiosadmin,nagiosro173authorized_for_all_hosts={{ nagiosadmin }},nagiosro
174{% else %}174{% else %}
175authorized_for_all_services=nagiosadmin175authorized_for_all_services={{ nagiosadmin }}
176authorized_for_all_hosts=nagiosadmin176authorized_for_all_hosts={{ nagiosadmin }}
177{% endif %}177{% endif %}
178178
179179
@@ -181,14 +181,14 @@ authorized_for_all_hosts=nagiosadmin
181# GLOBAL HOST/SERVICE COMMAND ACCESS181# GLOBAL HOST/SERVICE COMMAND ACCESS
182# These two options are comma-delimited lists of all usernames that182# These two options are comma-delimited lists of all usernames that
183# can issue host or service related commands via the command183# can issue host or service related commands via the command
184# CGI (cmd.cgi) for all hosts and services that are being monitored. 184# CGI (cmd.cgi) for all hosts and services that are being monitored.
185# By default, users can only issue commands for hosts or services 185# By default, users can only issue commands for hosts or services
186# that they are contacts for (unless you you choose to not use 186# that they are contacts for (unless you you choose to not use
187# authorization). You may use an asterisk (*) to authorize any187# authorization). You may use an asterisk (*) to authorize any
188# user who has authenticated to the web server.188# user who has authenticated to the web server.
189189
190authorized_for_all_service_commands=nagiosadmin190authorized_for_all_service_commands={{ nagiosadmin }}
191authorized_for_all_host_commands=nagiosadmin191authorized_for_all_host_commands={{ nagiosadmin }}
192192
193193
194194
@@ -204,7 +204,7 @@ authorized_for_all_host_commands=nagiosadmin
204204
205205
206# STATUSMAP BACKGROUND IMAGE206# STATUSMAP BACKGROUND IMAGE
207# This option allows you to specify an image to be used as a 207# This option allows you to specify an image to be used as a
208# background in the statusmap CGI. It is assumed that the image208# background in the statusmap CGI. It is assumed that the image
209# resides in the HTML images path (i.e. /usr/local/nagios/share/images).209# resides in the HTML images path (i.e. /usr/local/nagios/share/images).
210# This path is automatically determined by appending "/images"210# This path is automatically determined by appending "/images"
@@ -222,7 +222,7 @@ authorized_for_all_host_commands=nagiosadmin
222# STATUSMAP TRANSPARENCY INDEX COLOR222# STATUSMAP TRANSPARENCY INDEX COLOR
223# These options set the r,g,b values of the background color used the statusmap CGI,223# These options set the r,g,b values of the background color used the statusmap CGI,
224# so normal browsers that can't show real png transparency set the desired color as224# so normal browsers that can't show real png transparency set the desired color as
225# a background color instead (to make it look pretty). 225# a background color instead (to make it look pretty).
226# Defaults to white: (R,G,B) = (255,255,255).226# Defaults to white: (R,G,B) = (255,255,255).
227227
228#color_transparency_index_r=255228#color_transparency_index_r=255
@@ -263,7 +263,7 @@ default_statuswrl_layout=4
263263
264264
265# STATUSWRL INCLUDE265# STATUSWRL INCLUDE
266# This option allows you to include your own objects in the 266# This option allows you to include your own objects in the
267# generated VRML world. It is assumed that the file267# generated VRML world. It is assumed that the file
268# resides in the HTML path (i.e. /usr/local/nagios/share).268# resides in the HTML path (i.e. /usr/local/nagios/share).
269269
@@ -289,15 +289,15 @@ ping_syntax=/bin/ping -n -U -c 5 $HOSTADDRESS$
289289
290# REFRESH RATE290# REFRESH RATE
291# This option allows you to specify the refresh rate in seconds291# This option allows you to specify the refresh rate in seconds
292# of various CGIs (status, statusmap, extinfo, and outages). 292# of various CGIs (status, statusmap, extinfo, and outages).
293293
294refresh_rate=90294refresh_rate=90
295295
296# DEFAULT PAGE LIMIT296# DEFAULT PAGE LIMIT
297# This option allows you to specify the default number of results 297# This option allows you to specify the default number of results
298# displayed on the status.cgi. This number can be adjusted from298# displayed on the status.cgi. This number can be adjusted from
299# within the UI after the initial page load. Setting this to 0299# within the UI after the initial page load. Setting this to 0
300# will show all results. 300# will show all results.
301301
302result_limit=100302result_limit=100
303303
@@ -339,7 +339,7 @@ escape_html_tags=1
339339
340340
341# URL TARGET FRAMES341# URL TARGET FRAMES
342# These options determine the target frames in which notes and 342# These options determine the target frames in which notes and
343# action URLs will open.343# action URLs will open.
344344
345action_url_target=_blank345action_url_target=_blank
@@ -349,8 +349,8 @@ notes_url_target=_blank
349349
350350
351# LOCK AUTHOR NAMES OPTION351# LOCK AUTHOR NAMES OPTION
352# This option determines whether users can change the author name 352# This option determines whether users can change the author name
353# when submitting comments, scheduling downtime. If disabled, the 353# when submitting comments, scheduling downtime. If disabled, the
354# author names will be locked into their contact name, as defined in Nagios.354# author names will be locked into their contact name, as defined in Nagios.
355# Values: 0 = allow editing author names355# Values: 0 = allow editing author names
356# 1 = lock author names (disallow editing)356# 1 = lock author names (disallow editing)
@@ -378,6 +378,3 @@ lock_author_names=1
378# This option should be the URL used to access your instance of Splunk378# This option should be the URL used to access your instance of Splunk
379379
380#splunk_url=http://127.0.0.1:8000/380#splunk_url=http://127.0.0.1:8000/
381
382
383
diff --git a/hooks/upgrade-charm b/hooks/upgrade-charm
index 19e736c..d70a368 100755
--- a/hooks/upgrade-charm
+++ b/hooks/upgrade-charm
@@ -38,6 +38,7 @@ pagerduty_cfg = "/etc/nagios3/conf.d/pagerduty_nagios.cfg"
38pagerduty_cron = "/etc/cron.d/nagios-pagerduty-flush"38pagerduty_cron = "/etc/cron.d/nagios-pagerduty-flush"
39password = hookenv.config('password')39password = hookenv.config('password')
40ro_password = hookenv.config('ro-password')40ro_password = hookenv.config('ro-password')
41nagiosadmin = hookenv.config('nagiosadmin') or 'nagiosadmin'
4142
4243
43# Checks the charm relations for legacy relations44# Checks the charm relations for legacy relations
@@ -284,7 +285,8 @@ def update_config():
284285
285286
286def update_cgi_config():287def update_cgi_config():
287 template_values = {'ro_password': ro_password}288 template_values = {'nagiosadmin': nagiosadmin,
289 'ro_password': ro_password}
288 with open('hooks/templates/nagios-cgi.tmpl', 'r') as f:290 with open('hooks/templates/nagios-cgi.tmpl', 'r') as f:
289 templateDef = f.read()291 templateDef = f.read()
290292
@@ -361,8 +363,9 @@ update_localhost()
361update_cgi_config()363update_cgi_config()
362update_password('nagiosro', ro_password)364update_password('nagiosro', ro_password)
363if password:365if password:
364 update_password('nagiosadmin', password)366 update_password(nagiosadmin, password)
365367if nagiosadmin != 'nagiosadmin':
368 update_password('nagiosadmin', False)
366369
367subprocess.call(['hooks/mymonitors-relation-joined'])370subprocess.call(['hooks/mymonitors-relation-joined'])
368subprocess.call(['hooks/monitors-relation-changed'])371subprocess.call(['hooks/monitors-relation-changed'])

Subscribers

People subscribed via source and target branches