abusesa::recorder: Add parameter to disable services management

This commit is contained in:
Ossi Salmi 2016-09-15 11:14:52 +03:00
parent e23c67c8f3
commit 7afc1a3569

View file

@ -135,6 +135,9 @@ class abusesa::recorder(
# $remote: # $remote:
# Enable remote. Defaults to true. # Enable remote. Defaults to true.
# #
# $services:
# Manage probe and remote services. Defaults to true.
#
# === Sample usage # === Sample usage
# #
# abusesa::recorder::interface { 'eth0': # abusesa::recorder::interface { 'eth0':
@ -156,6 +159,7 @@ define abusesa::recorder::interface(
$remoteopt='', $remoteopt='',
$probe=true, $probe=true,
$remote=true, $remote=true,
$services=true,
) { ) {
Class['abusesa::recorder'] -> Abusesa::Recorder::Interface[$name] Class['abusesa::recorder'] -> Abusesa::Recorder::Interface[$name]
@ -173,6 +177,12 @@ define abusesa::recorder::interface(
group => 'root', group => 'root',
} }
if $probe == true and $services == true {
$probe_notify = Service["probe-${name}"]
} else {
$probe_notify = undef
}
file { "/etc/abusesa/probe.d/${name}": file { "/etc/abusesa/probe.d/${name}":
ensure => $probe ? { ensure => $probe ? {
true => present, true => present,
@ -183,12 +193,10 @@ define abusesa::recorder::interface(
group => 'root', group => 'root',
content => template('abusesa/recorder/probe.erb'), content => template('abusesa/recorder/probe.erb'),
require => File["/var/lib/recorder/${name}"], require => File["/var/lib/recorder/${name}"],
notify => $probe ? { notify => $probe_notify,
true => Service["probe-${name}"],
false => undef,
},
} }
if $services == true {
service { "probe-${name}": service { "probe-${name}":
ensure => $probe ? { ensure => $probe ? {
true => running, true => running,
@ -201,6 +209,13 @@ define abusesa::recorder::interface(
status => "pgrep -f /var/run/probe/${name}.pid", status => "pgrep -f /var/run/probe/${name}.pid",
subscribe => Exec['/usr/local/src/abusesa-recorder-linux.sh'], subscribe => Exec['/usr/local/src/abusesa-recorder-linux.sh'],
} }
}
if $remote == true and $services == true {
$remote_notify = Service["remote-${name}"]
} else {
$remote_notify = undef
}
file { "/etc/abusesa/remote.d/${name}": file { "/etc/abusesa/remote.d/${name}":
ensure => $remote ? { ensure => $remote ? {
@ -212,12 +227,10 @@ define abusesa::recorder::interface(
group => 'root', group => 'root',
content => template('abusesa/recorder/remote.erb'), content => template('abusesa/recorder/remote.erb'),
require => File["/var/lib/recorder/${name}"], require => File["/var/lib/recorder/${name}"],
notify => $remote ? { notify => $remote_notify,
true => Service["remote-${name}"],
false => undef,
},
} }
if $services == true {
service { "remote-${name}": service { "remote-${name}":
ensure => $remote ? { ensure => $remote ? {
true => running, true => running,
@ -231,5 +244,6 @@ define abusesa::recorder::interface(
require => Service["probe-${name}"], require => Service["probe-${name}"],
subscribe => Exec['/usr/local/src/abusesa-recorder-linux.sh'], subscribe => Exec['/usr/local/src/abusesa-recorder-linux.sh'],
} }
}
} }