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
fbae5f44
Commit
fbae5f44
authored
Sep 11, 2012
by
mh
Browse files
whitespace + make puppet-lint happy
parent
c380b254
Changes
5
Hide whitespace changes
Inline
Side-by-side
manifests/base.pp
View file @
fbae5f44
# Base class that setups the common things
class
monit::base
{
package
{
"monit"
:
ensure
=>
installed
,
}
service
{
"monit"
:
ensure
=>
running
,
require
=>
Package
[
"monit"
],
}
# How to tell monit to reload its configuration
exec
{
"monit reload"
:
command
=>
"/usr/sbin/monit reload"
,
refreshonly
=>
true
,
}
# Default values for all file resources
File
{
owner
=>
"root"
,
group
=>
"root"
,
mode
=>
0400
,
notify
=>
Exec
[
"monit reload"
],
require
=>
Package
[
"monit"
],
}
# The main configuration directory, this should have been provided by
# the "monit" package, but we include it just to be sure.
file
{
"/etc/monit"
:
ensure
=>
directory
,
mode
=>
0700
,
}
package
{
'monit'
:
ensure
=>
installed
,
}
service
{
'monit'
:
ensure
=>
running
,
require
=>
Package
[
'monit'
],
}
# The configuration snippet directory. Other packages can put
# *.monitrc files into this directory, and monit will include them.
file
{
"/etc/monit/conf.d"
:
ensure
=>
directory
,
mode
=>
0700
,
}
# How to tell monit to reload its configuration
exec
{
'monit reload'
:
command
=>
'/usr/sbin/monit reload'
,
refreshonly
=>
true
,
}
# The main configuration file
file
{
"/etc/monit/monitrc"
:
content
=>
template
(
"monit/monitrc.erb"
),
}
# Default values for all file resources
File
{
owner
=>
'root'
,
group
=>
0
,
mode
=>
'0400'
,
notify
=>
Exec
[
'monit reload'
],
require
=>
Package
[
'monit'
],
}
# The main configuration directory, this should have been provided by
# the "monit" package, but we include it just to be sure.
file
{
'/etc/monit'
:
ensure
=>
directory
,
mode
=>
'0700'
;
# The configuration snippet directory. Other packages can put
# *.monitrc files into this directory, and monit will include them.
'/etc/monit/conf.d'
:
ensure
=>
directory
,
mode
=>
'0700'
;
'/etc/monit/monitrc'
:
content
=>
template
(
'monit/monitrc.erb'
);
}
# A template configuration snippet. It would need to be included,
# since monit's "include" statement cannot handle an empty directory.
monit::snippet
{
"
monit_template
"
:
source
=>
"
puppet://
$server
/modules/monit/template.monitrc
"
,
monit::snippet
{
'
monit_template
'
:
source
=>
'
puppet:///modules/monit/template.monitrc
'
,
}
}
manifests/check/process.pp
View file @
fbae5f44
...
...
@@ -6,11 +6,14 @@
# pidfile - the pidfile monit will check
# start - the command used by monit to start the service
# stop - the command used by monit to stop the service
# customlines - lets you inject custom lines into the monitrc snippet, just pass an array, and it will appear in the configuration file
# customlines - lets you inject custom lines into the monitrc snippet,
# just pass an array, and it will appear in the
# configuration file
#
# Actions:
# The following actions gets taken by this defined type:
# - creates /etc/monit/conf.d/namevar.monitrc as root:root mode 0400 based on _template_
# - creates /etc/monit/conf.d/namevar.monitrc as root:root mode 0400
# based on _template_
#
# Requires:
# - Package["monit"]
...
...
@@ -24,22 +27,24 @@
# customlines => ["if failed port 22 then restart",
# "if 2 restarts within 3 cycles then timeout"]
# }
# (end)
define
monit::check::process
(
$ensure
=
present
,
$process
=
$name
,
$pidfile
=
"/var/run/
$name
.pid"
,
$start
=
"/etc/init.d/
$name
start"
,
$start_extras
=
""
,
$stop
=
"/etc/init.d/
$name
stop"
,
$stop_extras
=
""
,
$customlines
=
""
)
{
file
{
"/etc/monit/conf.d/
$name
.monitrc"
:
ensure
=>
$ensure
,
owner
=>
"root"
,
group
=>
"root"
,
mode
=>
0400
,
content
=>
template
(
"monit/check_process.monitrc.erb"
),
notify
=>
Service
[
"monit"
],
}
#
define
monit::check::process
(
$ensure
=
present
,
$process
=
$name
,
$pidfile
=
"/var/run/
${name}
.pid"
,
$start
=
"/etc/init.d/
${name}
start"
,
$start_extras
=
''
,
$stop
=
"/etc/init.d/
${name}
stop"
,
$stop_extras
=
''
,
$customlines
=
''
)
{
file
{
"/etc/monit/conf.d/
${name}
.monitrc"
:
ensure
=>
$ensure
,
owner
=>
'root'
,
group
=>
0
,
mode
=>
'0400'
,
content
=>
template
(
'monit/check_process.monitrc.erb'
),
notify
=>
Service
[
'monit'
],
}
}
manifests/debian.pp
View file @
fbae5f44
# Debian specific things
class
monit::debian
inherits
monit::base
{
# Monit is disabled by default on debian / ubuntu
file
{
"
/etc/default/monit
"
:
# Monit is disabled by default on debian / ubuntu
file
{
'
/etc/default/monit
'
:
content
=>
"startup=1
\n
CHECK_INTERVALS=
${monit::pool_interval}
\n
"
,
before
=>
Service
[
"
monit
"
]
}
before
=>
Service
[
'
monit
'
]
}
}
manifests/init.pp
View file @
fbae5f44
...
...
@@ -40,12 +40,12 @@
# 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?'
,
# 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?'
,
# The default alert recipient.
$alert
=
'root@localhost'
,
# The default alert recipient.
$alert
=
'root@localhost'
,
# How often should the daemon pool? Interval in seconds.
$pool_interval
=
'120'
,
...
...
manifests/snippet.pp
View file @
fbae5f44
...
...
@@ -2,7 +2,8 @@
# Creates a monit configuration snippet in /etc/monit/conf.d/
#
# Parameters:
# namevar - the name of this resource will be used for the configuration file name
# namevar - the name of this resource will be used for the
# configuration file name
# ensure - present or absent
# content - as for the "file" type
# source - as for the "file" type
...
...
@@ -11,7 +12,6 @@
# Requires:
# Package["monit"]
#
#
# Sample usage:
# (start code)
# monit::check::process{"openssh":
...
...
@@ -21,24 +21,33 @@
# customlines => ["if failed port 22 then restart"]
# }
# (end)
define
monit::snippet
(
$ensure
=
present
,
$target
=
""
,
$source
=
""
,
$content
=
""
)
{
file
{
"/etc/monit/conf.d/
$name
.monitrc"
:
ensure
=>
$ensure
,
owner
=>
"root"
,
group
=>
"root"
,
mode
=>
0400
,
notify
=>
Service
[
"monit"
],
content
=>
$content
?
{
""
=>
undef
,
default
=>
$content
},
source
=>
$source
?
{
""
=>
undef
,
default
=>
$source
},
target
=>
$target
?
{
""
=>
undef
,
default
=>
$target
},
}
define
monit::snippet
(
$ensure
=
present
,
$target
=
undef
,
$source
=
undef
,
$content
=
undef
){
file
{
"/etc/monit/conf.d/
${name}
.monitrc"
:
ensure
=>
$ensure
,
owner
=>
'root'
,
group
=>
0
,
mode
=>
'0400'
,
notify
=>
Service
[
'monit'
],
}
if
$content
{
File
[
"/etc/monit/conf.d/
${name}
.monitrc"
]{
content
=>
$content
}
}
if
$target
{
File
[
"/etc/monit/conf.d/
${name}
.monitrc"
]{
target
=>
$target
}
}
if
$source
{
File
[
"/etc/monit/conf.d/
${name}
.monitrc"
]{
source
=>
$source
}
}
}
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