Skip to content

Commit

Permalink
Remove anchor pattern sensu#709
Browse files Browse the repository at this point in the history
Removed anchors and create_resources

Note: an anchor in init.pp has been temporarily left in place.
It has a purpose and might not trivial to replace.
Could remain in code base as far as I'm concerned.

Syntax fix

Added forgotten defaults var in init.pp resource hashes

Fixed order in hash merging
  • Loading branch information
alvagante committed Jul 21, 2017
1 parent c9e88ea commit 7b00827
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 43 deletions.
2 changes: 1 addition & 1 deletion manifests/api/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# Default: true
#
class sensu::api::service (
Boolean $hasrestart = true,
Boolean $hasrestart = $::sensu::hasrestart,
) {

if $caller_module_name != $module_name {
Expand Down
2 changes: 1 addition & 1 deletion manifests/client/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# Default: $::sensu::windows_log_number
#
class sensu::client::service (
Boolean $hasrestart = true,
Boolean $hasrestart = $::sensu::hasrestart,
$log_level = $::sensu::log_level,
$windows_logrotate = $::sensu::windows_logrotate,
$windows_log_size = $::sensu::windows_log_size,
Expand Down
16 changes: 8 additions & 8 deletions manifests/enterprise/dashboard.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
#
# Installs the Sensu Enterprise Dashboard
class sensu::enterprise::dashboard (
Boolean $hasrestart = true,
Boolean $hasrestart = $::sensu::hasrestart,
) {

anchor { 'sensu::enterprise::dashboard::begin': }
-> class { '::sensu::enterprise::dashboard::package': }
-> class { '::sensu::enterprise::dashboard::config': }
-> class { '::sensu::enterprise::dashboard::service':
hasrestart => $hasrestart,
}
-> anchor { 'sensu::enterprise::dashboard::end': }
contain '::sensu::enterprise::dashboard::package'
contain '::sensu::enterprise::dashboard::config'
contain '::sensu::enterprise::dashboard::service'

Class['::sensu::enterprise::dashboard::package']
-> Class['::sensu::enterprise::dashboard::config']
-> Class['::sensu::enterprise::dashboard::service']

}
2 changes: 1 addition & 1 deletion manifests/enterprise/dashboard/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Installs the Sensu Enterprise Dashboard
class sensu::enterprise::dashboard::service (
Boolean $hasrestart = true,
Boolean $hasrestart = $::sensu::enterprise::dashboard::hasrestart,
) {

if $caller_module_name != $module_name {
Expand Down
2 changes: 1 addition & 1 deletion manifests/enterprise/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# Default: true

class sensu::enterprise::service (
Boolean $hasrestart = true,
Boolean $hasrestart = $::sensu::hasrestart,
) {

if $caller_module_name != $module_name {
Expand Down
80 changes: 50 additions & 30 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -659,12 +659,31 @@
# managed after all plugins. It must always exist in the catalog.
anchor { 'plugins_before_checks': }

# Create resources from hiera lookups
create_resources('::sensu::extension', $extensions)
create_resources('::sensu::handler', $handlers, $handler_defaults)
create_resources('::sensu::check', $checks, $check_defaults)
create_resources('::sensu::filter', $filters, $filter_defaults)
create_resources('::sensu::mutator', $mutators)
$extensions.each |$k,$v| {
::sensu::extension { $k:
* => $v,
}
}
$handlers.each |$k,$v| {
::sensu::handler { $k:
* => $handler_defaults + $v,
}
}
$checks.each |$k,$v| {
::sensu::check { $k:
* => $check_defaults + $v,
}
}
$filters.each |$k,$v| {
::sensu::filter { $k:
* => $filter_defaults + $v,
}
}
$mutators.each |$k,$v| {
::sensu::mutator { $k:
* => $v,
}
}

case $::osfamily {
'Debian','RedHat': {
Expand Down Expand Up @@ -694,30 +713,31 @@

# Include everything and let each module determine its state. This allows
# transitioning to purged config and stopping/disabling services
anchor { 'sensu::begin': }
-> class { '::sensu::package': }
-> class { '::sensu::enterprise::package': }
-> class { '::sensu::transport': }
-> class { '::sensu::rabbitmq::config': }
-> class { '::sensu::api::config': }
-> class { '::sensu::redis::config': }
-> class { '::sensu::client::config': }
-> class { '::sensu::client::service':
hasrestart => $hasrestart,
}
-> class { '::sensu::api::service':
hasrestart => $hasrestart,
}
-> class { '::sensu::server::service':
hasrestart => $hasrestart,
}
-> class { '::sensu::enterprise::service':
hasrestart => $hasrestart,
}
-> class { '::sensu::enterprise::dashboard':
hasrestart => $hasrestart,
}
-> anchor {'sensu::end': }
contain ::sensu::package
contain ::sensu::enterprise::package
contain ::sensu::transport
contain ::sensu::rabbitmq::config
contain ::sensu::api::config
contain ::sensu::redis::config
contain ::sensu::client::config
contain ::sensu::client::service
contain ::sensu::api::service
contain ::sensu::server::service
contain ::sensu::enterprise::service
contain ::sensu::enterprise::dashboard

Class['::sensu::package']
-> Class['::sensu::enterprise::package']
-> Class['::sensu::transport']
-> Class['::sensu::rabbitmq::config']
-> Class['::sensu::api::config']
-> Class['::sensu::redis::config']
-> Class['::sensu::client::config']
-> Class['::sensu::client::service']
-> Class['::sensu::api::service']
-> Class['::sensu::server::service']
-> Class['::sensu::enterprise::service']
-> Class['::sensu::enterprise::dashboard']

if $plugins_dir {
sensu::plugin { $plugins_dir: type => 'directory' }
Expand Down
2 changes: 1 addition & 1 deletion manifests/server/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# Default: true

class sensu::server::service (
Boolean $hasrestart = true,
Boolean $hasrestart = $::sensu::hasrestart,
) {

if $caller_module_name != $module_name {
Expand Down

0 comments on commit 7b00827

Please sign in to comment.