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

Added support for consolidation of all rules #45

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
10 changes: 8 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ else
end

gem 'metadata-json-lint'
gem 'puppetlabs_spec_helper', '>= 0.1.0'
gem 'puppetlabs_spec_helper', '>= 1.1.1'
gem 'facter', '>= 1.7.0'
gem 'rspec-puppet'
gem 'puppet-lint', :git => 'https://github.com/rodjek/puppet-lint.git'
gem 'puppet-lint', '>= 1.0', '< 3.0'
gem 'puppet-lint-absolute_classname-check'
gem 'puppet-lint-alias-check'
gem 'puppet-lint-empty_string-check'
Expand All @@ -30,3 +30,9 @@ if RUBY_VERSION >= '1.8.7' and RUBY_VERSION < '1.9'
# rake >= 11 does not support ruby 1.8.7
gem 'rake', '~> 10.0'
end

if RUBY_VERSION >= '1.8.7' and RUBY_VERSION < '2.0'
gem 'json', '~> 1.0'
gem 'json_pure', '~> 1.0'
end

12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,18 @@ Boolean to purge the nrpe.d directory of entries not managed by Puppet.

- *Default*: false

plugins_consolidate
-------------------
Boolean to consolidate all plugins into one file under nrpe.d instead of one file for each plugin.

- *Default*: false

plugins_consolidate_filename
----------------------------
Filename to use when plugins_consolidate is set to true. Should be specified without file extension.

- *Default*: 'plugins'

===

# Define `nrpe::plugin`
Expand Down
25 changes: 24 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
$service_name = 'USE_DEFAULTS',
$service_enable = true,
$plugins = undef,
$plugins_consolidate = false,
$plugins_consolidate_filename = 'plugins',
$purge_plugins = false,
$hiera_merge_plugins = false,
$nrpe_package_provider = undef,
Expand Down Expand Up @@ -258,6 +260,13 @@
$hiera_merge_plugins_bool = $hiera_merge_plugins
}

if is_string($plugins_consolidate) {
$plugins_consolidate_bool = str2bool($plugins_consolidate)
} else {
$plugins_consolidate_bool = $plugins_consolidate
}


# Validate params
validate_re($nrpe_config_mode, '^\d{4}$',
"nrpe::nrpe_config_mode must be a four digit octal mode. Detected value is <${nrpe_config_mode}>.")
Expand Down Expand Up @@ -349,6 +358,20 @@
$plugins_real = $plugins
}
validate_hash($plugins_real)
create_resources('nrpe::plugin',$plugins_real)

if $plugins_consolidate_bool and $plugins_consolidate_filename != undef {
file { $plugins_consolidate_filename:
ensure => file,
path => "${include_dir_real}/${plugins_consolidate_filename}.cfg",
content => template('nrpe/consolidated.erb'),
owner => $nrpe_config_owner,
group => $nrpe_config_group,
mode => $nrpe_config_mode,
require => File['nrpe_config_dot_d'],
notify => Service['nrpe_service'],
}
} else {
create_resources('nrpe::plugin',$plugins_real)
}
}
}
Loading