Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
immerda
Puppet Modules
monit
Commits
41f08e2b
Commit
41f08e2b
authored
Sep 11, 2012
by
mh
Browse files
migrate to parametrized classes
Instead of using global variables.
parent
3e67195f
Changes
2
Hide whitespace changes
Inline
Side-by-side
manifests/init.pp
View file @
41f08e2b
...
...
@@ -6,61 +6,60 @@
# Stig Sandbeck Mathisen <ssm@fnord.no>
# Micah Anderson micah@riseup.net
#
# To set any of the following, simply set them as
variables in your manifest
s
# To set any of the following, simply set them as
class parameter
s
# before the class is included, for example:
#
# $monit_enable_httpd = yes
# $monit_httpd_port = 8888
# $monit_secret="something secret, something safe"
# $monit_alert="someone@example.org"
# $monit_mailserver="mail.example.org"
# $monit_pool_interval="120"
#
# include monit
# class{'monit':
# alert => 'someone@example.org',
# mailserver => 'mail.example.com'
# }
#
# The following is a list of the currently available variables:
#
#
monit_alert:
who should get the email notifications?
#
Default: root@localhost
#
alert:
who should get the email notifications?
# Default: root@localhost
#
#
monit_
enable_httpd:
should the httpd daemon be enabled?
#
set this to 'yes' to enable it, be sure
#
you have set the $monit_default_secret
#
Valid values: yes or no
#
Default: no
# enable_httpd: should the httpd daemon be enabled?
# set this to 'yes' to enable it, be sure
# you have set the $monit_default_secret
# Valid values: yes or no
# Default: no
#
#
monit_
httpd_port:
what port should the httpd run on?
#
Default: 2812
# httpd_port: what port should the httpd run on?
# Default: 2812
#
#
#
monit_
mailserver:
where should monit be sending mail?
#
set this to the mailserver
#
Default: localhost
# mailserver: where should monit be sending mail?
# set this to the mailserver
# Default: localhost
#
#
monit_
pool_interval:
how often (in seconds) should monit poll?
#
Default: 120
# pool_interval: how often (in seconds) should monit poll?
# Default: 120
#
# secret: The secret for the httpd daemon. Please set it!
# Default: "This is not very secret, is it?"
#
class
monit
(
# The monit_secret is used with the fqdn of the host to make a
# password for the monit http server.
$secret
=
'This is not very secret, is it?'
,
class
monit
{
# The default alert recipient.
$alert
=
'root@localhost'
,
# How often should the daemon pool? Interval in seconds.
$pool_interval
=
'120'
,
# The monit_secret is used with the fqdn of the host to make a
# password for the monit http server.
$monit_default_secret
=
"This is not very secret, is it?"
# Should the httpd daemon be enabled, or not? By default it is not
$enable_httpd
=
'no'
,
# The default alert recipient. You can override this by setting the
# variable "$monit_alert" in your node specification.
$monit_default_alert
=
"root@localhost"
# port for the httpd daemon
$httpd_port
=
2812
,
# How often should the daemon pool? Interval in seconds.
case
$monit_pool_interval
{
''
:
{
$monit_pool_interval
=
'120'
}
}
# mailserver
$mailserver
=
'localhost'
){
# Should the httpd daemon be enabled, or not? By default it is not
case
$monit_enable_httpd
{
''
:
{
$monit_enable_httpd
=
'no'
}
}
# The package
package
{
"monit"
:
ensure
=>
installed
,
...
...
@@ -110,7 +109,7 @@ class monit {
case
$operatingsystem
{
"debian"
:
{
file
{
"/etc/default/monit"
:
content
=>
"startup=1
\n
CHECK_INTERVALS=
${monit
_
pool_interval}
\n
"
,
content
=>
"startup=1
\n
CHECK_INTERVALS=
${monit
::
pool_interval}
\n
"
,
before
=>
Service
[
"monit"
]
}
}
...
...
templates/monitrc.erb
View file @
41f08e2b
...
...
@@ -3,33 +3,21 @@
# This file is handled by puppet, any local changes will be lost
#
set alert
<%=
has_variable?
(
"monit_alert"
)
?
monit_alert
:
monit_default_
alert
%>
set alert
<%=
scope
.
scope
.
lookupvar
(
'monit::
alert
'
)
%>
<%-
if
monit_enable_httpd
.
to_s
==
'yes'
then
-%>
<%# BEGIN functions %>
<%
require
'digest/sha1'
def
password
if
defined?
(
monit_secret
)
s
=
monit_secret
else
s
=
monit_default_secret
end
return
Digest
::
SHA1
.
hexdigest
(
s
+
Digest
::
SHA1
.
hexdigest
(
s
+
fqdn
))
end
%>
<%# END functions %>
set httpd port
<%=
has_variable?
(
"monit_httpd_port"
)
?
monit_httpd_port
:
"2812"
%>
and use address localhost
<%-
if
scope
.
scope
.
lookupvar
(
'monit::enable_httpd'
)
==
'yes'
-%>
set httpd port
<%=
scope
.
scope
.
lookupvar
(
'monit::httpd_port'
)
%>
and use address localhost
allow localhost
allow monit:
<%=
password
%>
<%-
require
'digest/sha1'
s
=
scope
.
scope
.
lookupvar
(
'monit::secret'
)
-%>
allow monit:
<%=
Digest
::
SHA1
.
hexdigest
(
s
+
Digest
::
SHA1
.
hexdigest
(
s
+
fqdn
))
%>
<%-
end
-%>
set daemon
<%=
monit
_
pool_interval
%>
set daemon
<%=
scope
.
scope
.
lookupvar
(
'
monit
::
pool_interval
'
)
%>
set logfile syslog facility log_daemon
set mailserver
<%=
has_variable?
(
"
monit
_
mailserver
"
)
?
monit_mailserver
:
"localhost"
%>
set mailserver
<%=
scope
.
scope
.
lookupvar
(
'
monit
::
mailserver
'
)
%>
# Include settings from other files
include /etc/monit/conf.d/*.monitrc
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment