clarified: Manage probe and remote services individually

Fixes #4.
This commit is contained in:
Ossi Salmi 2013-09-02 14:00:13 +03:00
parent f33820a1f5
commit c05b882bdb

View file

@ -15,8 +15,8 @@ class clarified::analyzer {
file { "/usr/local/src/clarified-analyzer-linux-i686.sh":
ensure => present,
mode => "0755",
owner => root,
group => root,
owner => "root",
group => "root",
source => "puppet:///files/packages/${clarified_analyzer_package}",
before => Exec["/usr/local/src/clarified-analyzer-linux-i686.sh"],
}
@ -50,8 +50,8 @@ class clarified::recorder {
file { $recorder_datadir:
ensure => directory,
mode => "0700",
owner => root,
group => root,
owner => "root",
group => "root",
}
file { "/var/lib/recorder":
@ -63,8 +63,8 @@ class clarified::recorder {
file { "/var/lib/recorder":
ensure => directory,
mode => "0700",
owner => root,
group => root,
owner => "root",
group => "root",
}
}
@ -73,8 +73,8 @@ class clarified::recorder {
"/etc/clarified/remote.d", ]:
ensure => directory,
mode => "0644",
owner => root,
group => root,
owner => "root",
group => "root",
before => Exec["/usr/local/src/clarified-recorder-linux.sh"],
}
@ -88,8 +88,8 @@ class clarified::recorder {
file { "/usr/local/src/clarified-recorder-linux.sh":
ensure => present,
mode => "0755",
owner => root,
group => root,
owner => "root",
group => "root",
source => "puppet:///files/packages/${clarified_recorder_package}",
before => Exec["/usr/local/src/clarified-recorder-linux.sh"],
}
@ -117,18 +117,24 @@ class clarified::recorder {
file { "/etc/init.d/clarified-probe":
ensure => present,
mode => "0755",
owner => root,
group => root,
owner => "root",
group => "root",
source => "/usr/local/probe/probe-init.sh",
require => Exec["/usr/local/src/clarified-recorder-linux.sh"],
before => Service["clarified-probe"],
notify => Exec["add-service-clarified-probe"],
}
exec { "add-service-clarified-probe":
path => "/bin:/usr/bin:/sbin:/usr/sbin",
command => $::operatingsystem ? {
"debian" => "update-rc.d clarified-probe defaults",
"ubuntu" => "update-rc.d clarified-probe defaults",
default => "chkconfig --add clarified-probe",
},
refreshonly => true,
before => Service["clarified-probe"],
}
service { "clarified-probe":
ensure => running,
enable => true,
hasrestart => true,
status => "pgrep -f /usr/local/probe",
enable => true,
}
}
@ -179,17 +185,39 @@ define clarified::probe($interface="", $snaplen="65535", $keeptime="100GB",
$interface_real = $name
}
file { "/var/lib/recorder/${name}":
ensure => directory,
mode => "0700",
owner => "root",
group => "root",
}
file { "/etc/clarified/probe.d/${name}":
ensure => $probe ? {
true => present,
false => absent,
},
mode => "0755",
owner => root,
group => root,
owner => "root",
group => "root",
content => template("clarified/probe.erb"),
require => File["/etc/clarified/probe.d"],
notify => Service["clarified-probe"],
require => File["/var/lib/recorder/${name}"],
notify => $probe ? {
true => Service["probe-${name}"],
false => undef,
},
}
service { "probe-${name}":
ensure => $probe ? {
true => running,
false => stopped,
},
provider => "base",
start => "/etc/clarified/probe.d/${name} start",
restart => "/etc/clarified/probe.d/${name} restart",
stop => "pkill -f /var/run/probe/${name}.pid",
status => "pgrep -f /var/run/probe/${name}.pid",
}
file { "/etc/clarified/remote.d/${name}":
@ -198,20 +226,26 @@ define clarified::probe($interface="", $snaplen="65535", $keeptime="100GB",
false => absent,
},
mode => "0755",
owner => root,
group => root,
owner => "root",
group => "root",
content => template("clarified/remote.erb"),
require => File["/etc/clarified/remote.d"],
notify => Service["clarified-probe"],
require => File["/var/lib/recorder/${name}"],
notify => $remote ? {
true => Service["remote-${name}"],
false => undef,
},
}
file { "/var/lib/recorder/${name}":
ensure => directory,
mode => "0700",
owner => root,
group => root,
require => File["/var/lib/recorder"],
before => Service["clarified-probe"],
service { "remote-${name}":
ensure => $remote ? {
true => running,
false => stopped,
},
provider => "base",
start => "/etc/clarified/remote.d/${name} start",
restart => "/etc/clarified/remote.d/${name} restart",
stop => "pkill -f /var/run/remote/${name}.pid",
status => "pgrep -f /var/run/remote/${name}.pid",
}
}