Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#709 Remove anchors (and create_resources) #763

Merged
merged 1 commit into from
Aug 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions manifests/api.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# = Class: sensu::api
#
# Manages the Sensu api
#
# == Parameters
#
# [*hasrestart*]
# Boolean. Value of hasrestart attribute for this service.
# Default: true
#
class sensu::api (
Boolean $hasrestart = $::sensu::hasrestart,
) {

if $::sensu::manage_services {

case $::sensu::api {
true: {
$service_ensure = 'running'
$service_enable = true
}
default: {
$service_ensure = 'stopped'
$service_enable = false
}
}

if $::osfamily != 'windows' {
service { 'sensu-api':
ensure => $service_ensure,
enable => $service_enable,
hasrestart => $hasrestart,
subscribe => [
Class['sensu::package'],
Sensu_api_config[$::fqdn],
Class['sensu::redis::config'],
Class['sensu::rabbitmq::config'],
],
}
}
}

if $::sensu::_purge_config and !$::sensu::server and !$::sensu::api and !$::sensu::enterprise {
$file_ensure = 'absent'
} else {
$file_ensure = 'present'
}

file { "${sensu::etc_dir}/conf.d/api.json":
ensure => $file_ensure,
owner => $::sensu::user,
group => $::sensu::group,
mode => $::sensu::file_mode,
}

sensu_api_config { $::fqdn:
ensure => $file_ensure,
base_path => "${sensu::etc_dir}/conf.d",
bind => $::sensu::api_bind,
host => $::sensu::api_host,
port => $::sensu::api_port,
user => $::sensu::api_user,
password => $::sensu::api_password,
ssl_port => $::sensu::api_ssl_port,
ssl_keystore_file => $::sensu::api_ssl_keystore_file,
ssl_keystore_password => $::sensu::api_ssl_keystore_password,
}
}
36 changes: 0 additions & 36 deletions manifests/api/config.pp

This file was deleted.

42 changes: 0 additions & 42 deletions manifests/api/service.pp

This file was deleted.

17 changes: 1 addition & 16 deletions manifests/check.pp
Original file line number Diff line number Diff line change
Expand Up @@ -223,27 +223,12 @@
# on top of any arbitrary plugin and extension configuration in $content.
$content_real = $content + $checks_scope

# Compute the services to notify
$notification_map = {
'Class[Sensu::Client::Service]' => $::sensu::client,
'Class[Sensu::Server::Service]' => $::sensu::server,
'Class[Sensu::Api::Service]' => $::sensu::api,
}

$notification_ary = $notification_map.reduce([]) |$memo, $kv| {
if $kv[1] {
$memo + [$kv[0]]
} else {
$memo
}
}

sensu::write_json { "${conf_dir}/checks/${check_name}.json":
ensure => $ensure,
content => $content_real,
owner => $user,
group => $group,
mode => $file_mode,
notify_list => $notification_ary,
notify_list => $::sensu::check_notify,
}
}
57 changes: 44 additions & 13 deletions manifests/client/service.pp → manifests/client.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,25 @@
#
# @param windows_log_number The integer value for the number of log files to keep on Windows OS family. keepFiles in sensu-client.xml.
#
class sensu::client::service (
Boolean $hasrestart = true,
class sensu::client (
Boolean $hasrestart = $::sensu::hasrestart,
$log_level = $::sensu::log_level,
$windows_logrotate = $::sensu::windows_logrotate,
$windows_log_size = $::sensu::windows_log_size,
$windows_log_number = $::sensu::windows_log_number,
) {

if $caller_module_name != $module_name {
fail("Use of private class ${name} by ${caller_module_name}")
}

# Service
if $::sensu::manage_services {

case $::sensu::client {
true: {
$ensure = 'running'
$enable = true
$service_ensure = 'running'
$service_enable = true
}
default: {
$ensure = 'stopped'
$enable = false
$service_ensure = 'stopped'
$service_enable = false
}
}

Expand All @@ -53,14 +50,48 @@
}

service { 'sensu-client':
ensure => $ensure,
enable => $enable,
ensure => $service_ensure,
enable => $service_enable,
hasrestart => $hasrestart,
subscribe => [
Class['sensu::package'],
Class['sensu::client::config'],
Sensu_client_config[$::fqdn],
Class['sensu::rabbitmq::config'],
],
}
}

# Config
if $::sensu::_purge_config and !$::sensu::client {
$file_ensure = 'absent'
} else {
$file_ensure = 'present'
}

file { "${sensu::conf_dir}/client.json":
ensure => $file_ensure,
owner => $::sensu::user,
group => $::sensu::group,
mode => $::sensu::file_mode,
}

$socket_config = {
bind => $::sensu::client_bind,
port => $::sensu::client_port,
}

sensu_client_config { $::fqdn:
ensure => $file_ensure,
base_path => $::sensu::conf_dir,
client_name => $::sensu::client_name,
address => $::sensu::client_address,
socket => $socket_config,
subscriptions => $::sensu::subscriptions,
safe_mode => $::sensu::safe_mode,
custom => $::sensu::client_custom,
keepalive => $::sensu::client_keepalive,
redact => $::sensu::redact,
deregister => $::sensu::client_deregister,
deregistration => $::sensu::client_deregistration,
}
}
43 changes: 0 additions & 43 deletions manifests/client/config.pp

This file was deleted.

2 changes: 1 addition & 1 deletion manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
ensure => $ensure,
config => $config,
event => $event,
notify => Class['sensu::client::service'],
notify => $::sensu::client_service,
}

}
39 changes: 33 additions & 6 deletions manifests/enterprise/package.pp → manifests/enterprise.pp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# @summary Installs the Sensu packages
#
# Installs the Sensu packages
# Installs Sensu enterprise
#
# @param deregister_handler The handler to use when deregistering a client on stop.
#
Expand Down Expand Up @@ -28,7 +28,7 @@
#
# @param heap_size Value of the HEAP_SIZE environment variable.
#
class sensu::enterprise::package (
class sensu::enterprise (
Optional[String] $deregister_handler = $::sensu::deregister_handler,
Optional[Boolean] $deregister_on_stop = $::sensu::deregister_on_stop,
Optional[String] $gem_path = $::sensu::gem_path,
Expand All @@ -39,12 +39,10 @@
Optional[String] $rubyopt = $::sensu::rubyopt,
Optional[Boolean] $use_embedded_ruby = $::sensu::use_embedded_ruby,
Variant[Undef,Integer,Pattern[/^(\d+)/]] $heap_size = $::sensu::heap_size,
Boolean $hasrestart = $::sensu::hasrestart,
){

if $caller_module_name != $module_name {
fail("Use of private class ${name} by ${caller_module_name}")
}

# Package
if $::sensu::enterprise {

package { 'sensu-enterprise':
Expand All @@ -60,4 +58,33 @@
require => Package['sensu-enterprise'],
}
}

# Service
if $::sensu::manage_services and $::sensu::enterprise {

case $::sensu::enterprise {
true: {
$ensure = 'running'
$enable = true
}
default: {
$ensure = 'stopped'
$enable = false
}
}

if $::osfamily != 'windows' {
service { 'sensu-enterprise':
ensure => $ensure,
enable => $enable,
hasrestart => $hasrestart,
subscribe => [
File['/etc/default/sensu-enterprise'],
Sensu_api_config[$::fqdn],
Class['sensu::redis::config'],
Class['sensu::rabbitmq::config'],
],
}
}
}
}
Loading