Skip to content

Commit

Permalink
Merge pull request #706 from bastelfreak/datatypes
Browse files Browse the repository at this point in the history
replace validate_* with datatypes
  • Loading branch information
bastelfreak authored Nov 1, 2017
2 parents 8741d90 + eda89c0 commit 15a028f
Show file tree
Hide file tree
Showing 84 changed files with 429 additions and 1,128 deletions.
53 changes: 20 additions & 33 deletions manifests/config.pp
Original file line number Diff line number Diff line change
@@ -1,40 +1,27 @@
# private
class collectd::config (
$collectd_hostname = $collectd::collectd_hostname,
$config_file = $collectd::config_file,
$conf_content = $collectd::conf_content,
$fqdnlookup = $collectd::fqdnlookup,
$has_wordexp = $collectd::has_wordexp,
$include = $collectd::include,
$internal_stats = $collectd::internal_stats,
$interval = $collectd::interval,
$plugin_conf_dir = $collectd::plugin_conf_dir,
$plugin_conf_dir_mode = $collectd::plugin_conf_dir_mode,
$recurse = $collectd::recurse,
$root_group = $collectd::root_group,
$purge = $collectd::purge,
$purge_config = $collectd::purge_config,
$read_threads = $collectd::read_threads,
$timeout = $collectd::timeout,
$typesdb = $collectd::typesdb,
$write_queue_limit_high = $collectd::write_queue_limit_high,
$write_queue_limit_low = $collectd::write_queue_limit_low,
$write_threads = $collectd::write_threads,
$collectd_hostname = $collectd::collectd_hostname,
Stdlib::Absolutepath $config_file = $collectd::config_file,
$conf_content = $collectd::conf_content,
Boolean $fqdnlookup = $collectd::fqdnlookup,
Boolean $has_wordexp = $collectd::has_wordexp,
Array $include = $collectd::include,
Boolean $internal_stats = $collectd::internal_stats,
Integer $interval = $collectd::interval,
Stdlib::Absolutepath $plugin_conf_dir = $collectd::plugin_conf_dir,
$plugin_conf_dir_mode = $collectd::plugin_conf_dir_mode,
$recurse = $collectd::recurse,
$root_group = $collectd::root_group,
$purge = $collectd::purge,
Boolean $purge_config = $collectd::purge_config,
Integer $read_threads = $collectd::read_threads,
Integer $timeout = $collectd::timeout,
Array $typesdb = $collectd::typesdb,
$write_queue_limit_high = $collectd::write_queue_limit_high,
$write_queue_limit_low = $collectd::write_queue_limit_low,
Integer $write_threads = $collectd::write_threads,
) {

validate_absolute_path($config_file)
validate_bool($fqdnlookup)
validate_bool($has_wordexp)
validate_array($include)
validate_bool($internal_stats)
validate_integer($interval)
validate_absolute_path($plugin_conf_dir)
validate_bool($purge_config)
validate_integer($read_threads)
validate_integer($timeout)
validate_array($typesdb)
validate_integer($write_threads)

$_conf_content = $purge_config ? {
true => template('collectd/collectd.conf.erb'),
default => $conf_content,
Expand Down
64 changes: 32 additions & 32 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
#
class collectd (
$collectd_hostname = $collectd::params::collectd_hostname,
$conf_content = $collectd::params::conf_content,
$config_file = $collectd::params::config_file,
$fqdnlookup = $collectd::params::fqdnlookup,
$has_wordexp = $collectd::params::has_wordexp,
$include = $collectd::params::include,
$interval = $collectd::params::interval,
$internal_stats = $collectd::params::internal_stats,
$manage_package = $collectd::params::manage_package,
$manage_repo = $collectd::params::manage_repo,
$ci_package_repo = $collectd::params::ci_package_repo,
$manage_service = $collectd::params::manage_service,
$minimum_version = $collectd::params::minimum_version,
$package_ensure = $collectd::params::package_ensure,
$package_install_options = $collectd::params::package_install_options,
$package_name = $collectd::params::package_name,
$package_provider = $collectd::params::package_provider,
$plugin_conf_dir = $collectd::params::plugin_conf_dir,
$plugin_conf_dir_mode = $collectd::params::plugin_conf_dir_mode,
$purge = $collectd::params::purge,
$purge_config = $collectd::params::purge_config,
$read_threads = $collectd::params::read_threads,
$recurse = $collectd::params::recurse,
$root_group = $collectd::params::root_group,
$service_enable = $collectd::params::service_enable,
$service_ensure = $collectd::params::service_ensure,
$service_name = $collectd::params::service_name,
$timeout = $collectd::params::timeout,
$typesdb = $collectd::params::typesdb,
$write_queue_limit_high = $collectd::params::write_queue_limit_high,
$write_queue_limit_low = $collectd::params::write_queue_limit_low,
$write_threads = $collectd::params::write_threads,
$collectd_hostname = $collectd::params::collectd_hostname,
$conf_content = $collectd::params::conf_content,
$config_file = $collectd::params::config_file,
$fqdnlookup = $collectd::params::fqdnlookup,
$has_wordexp = $collectd::params::has_wordexp,
$include = $collectd::params::include,
$interval = $collectd::params::interval,
$internal_stats = $collectd::params::internal_stats,
$manage_package = $collectd::params::manage_package,
$manage_repo = $collectd::params::manage_repo,
Optional[Pattern[/(^5.4|^5.5|^5.6|^5.7|^master)/]] $ci_package_repo = $collectd::params::ci_package_repo,
$manage_service = $collectd::params::manage_service,
$minimum_version = $collectd::params::minimum_version,
$package_ensure = $collectd::params::package_ensure,
$package_install_options = $collectd::params::package_install_options,
$package_name = $collectd::params::package_name,
$package_provider = $collectd::params::package_provider,
$plugin_conf_dir = $collectd::params::plugin_conf_dir,
$plugin_conf_dir_mode = $collectd::params::plugin_conf_dir_mode,
$purge = $collectd::params::purge,
$purge_config = $collectd::params::purge_config,
$read_threads = $collectd::params::read_threads,
$recurse = $collectd::params::recurse,
$root_group = $collectd::params::root_group,
$service_enable = $collectd::params::service_enable,
$service_ensure = $collectd::params::service_ensure,
$service_name = $collectd::params::service_name,
$timeout = $collectd::params::timeout,
$typesdb = $collectd::params::typesdb,
$write_queue_limit_high = $collectd::params::write_queue_limit_high,
$write_queue_limit_low = $collectd::params::write_queue_limit_low,
$write_threads = $collectd::params::write_threads,
) inherits collectd::params {

$collectd_version_real = pick($::collectd_version, $minimum_version)
Expand Down
13 changes: 5 additions & 8 deletions manifests/install.pp
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
class collectd::install (
$package_ensure = $collectd::package_ensure,
$package_name = $collectd::package_name,
$package_provider = $collectd::package_provider,
$package_install_options = $collectd::package_install_options,
$manage_package = $collectd::manage_package,
$package_ensure = $collectd::package_ensure,
$package_name = $collectd::package_name,
$package_provider = $collectd::package_provider,
Optional[Array] $package_install_options = $collectd::package_install_options,
$manage_package = $collectd::manage_package,
) {
if $package_install_options != undef {
validate_array($package_install_options)
}

if $manage_package {
package { $package_name:
Expand Down
36 changes: 17 additions & 19 deletions manifests/plugin/amqp.pp
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
# https://collectd.org/wiki/index.php/Plugin:AMQP
class collectd::plugin::amqp (
$ensure = 'present',
$manage_package = undef,
$amqphost = 'localhost',
$amqpport = 5672,
$amqpvhost = 'graphite',
$amqpuser = 'graphite',
$amqppass = 'graphite',
$amqpformat = 'Graphite',
$amqpstorerates = false,
$amqpexchange = 'metrics',
$amqppersistent = true,
$amqproutingkey = 'collectd',
$graphiteprefix = 'collectd.',
$escapecharacter = '_',
$interval = undef,
$graphiteseparateinstances = false,
$graphitealwaysappendds = false,
$ensure = 'present',
$manage_package = undef,
$amqphost = 'localhost',
$amqpport = 5672,
$amqpvhost = 'graphite',
$amqpuser = 'graphite',
$amqppass = 'graphite',
$amqpformat = 'Graphite',
$amqpstorerates = false,
$amqpexchange = 'metrics',
Boolean $amqppersistent = true,
$amqproutingkey = 'collectd',
$graphiteprefix = 'collectd.',
$escapecharacter = '_',
$interval = undef,
Boolean $graphiteseparateinstances = false,
Boolean $graphitealwaysappendds = false,
) {

include ::collectd

$_manage_package = pick($manage_package, $::collectd::manage_package)

validate_bool($amqppersistent, $graphiteseparateinstances, $graphitealwaysappendds)

if $::osfamily == 'RedHat' {
if $_manage_package {
package { 'collectd-amqp':
Expand Down
16 changes: 5 additions & 11 deletions manifests/plugin/apache.pp
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
# https://collectd.org/wiki/index.php/Plugin:Apache
class collectd::plugin::apache (
$ensure = 'present',
$manage_package = undef,
$instances = { 'localhost' => { 'url' => 'http://localhost/mod_status?auto' } },
$interval = undef,
$package_install_options = $collectd::package_install_options,
$ensure = 'present',
$manage_package = undef,
Hash $instances = { 'localhost' => { 'url' => 'http://localhost/mod_status?auto' } },
$interval = undef,
Optional[Array] $package_install_options = $collectd::package_install_options,
) {

include ::collectd

$_manage_package = pick($manage_package, $::collectd::manage_package)

validate_hash($instances)

if $package_install_options != undef {
validate_array($package_install_options)
}

if $::osfamily == 'RedHat' {
if $_manage_package {
package { 'collectd-apache':
Expand Down
33 changes: 11 additions & 22 deletions manifests/plugin/bind.pp
Original file line number Diff line number Diff line change
@@ -1,34 +1,23 @@
# https://collectd.org/wiki/index.php/Plugin:BIND
class collectd::plugin::bind (
$url,
$ensure = 'present',
$manage_package = undef,
$memorystats = true,
$opcodes = true,
$parsetime = false,
$qtypes = true,
$resolverstats = false,
$serverstats = true,
$zonemaintstats = true,
$views = [],
$interval = undef,
$ensure = 'present',
$manage_package = undef,
Boolean $memorystats = true,
Boolean $opcodes = true,
Boolean $parsetime = false,
Boolean $qtypes = true,
Boolean $resolverstats = false,
Boolean $serverstats = true,
Boolean $zonemaintstats = true,
Array $views = [],
$interval = undef,
) {

include ::collectd

$_manage_package = pick($manage_package, $::collectd::manage_package)

validate_bool(
$memorystats,
$opcodes,
$parsetime,
$qtypes,
$resolverstats,
$serverstats,
$zonemaintstats,
)
validate_array($views)

if $::osfamily == 'RedHat' {
if $_manage_package {
package { 'collectd-bind':
Expand Down
12 changes: 5 additions & 7 deletions manifests/plugin/ceph.pp
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#== Class: collectd::plugin::ceph
#
# Class to manage ceph plugin for collectd
# Class to manage ceph plugin for collectd
# === Parameters
# [*ensure*]
# ensure param for collectd::plugin type
#
#
# [*daemons*]
# array of ceph daemons to create config for (replace clustername, hostname as appropriate)
# example: [ '[clustername]-osd.1', '[clustername]-osd.2', '[clustername]-osd.3', '[clustername]-mon.[hostname].asok' ]
#
#
#
# [*longrunavglatency*] If enabled, latency values(sum,count pairs) are
# calculated as the long run average - average since the ceph daemon was
Expand All @@ -32,9 +32,9 @@
# [*package_name*]
# to be used with manage_package; if manage_package is true, this gives the name
# of the package to manage. Defaults to 'collectd-ceph'
#
#
class collectd::plugin::ceph (
$daemons,
Array $daemons,
$ensure = 'present',
$longrunavglatency = false,
$convertspecialmetrictypes = true,
Expand All @@ -44,8 +44,6 @@

include ::collectd

validate_array($daemons)

if $manage_package {
package { 'collectd-ceph':
ensure => $ensure,
Expand Down
11 changes: 4 additions & 7 deletions manifests/plugin/cgroups.pp
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
# https://collectd.org/wiki/index.php/Plugin:cgroups
class collectd::plugin::cgroups (
$cgroups = undef,
$ensure = 'present',
$ignore_selected = false,
$interval = undef,
Optional[Array] $cgroups = undef,
$ensure = 'present',
Boolean $ignore_selected = false,
$interval = undef,
) {

include ::collectd

$cgroups_real = pick($cgroups, [])

validate_array($cgroups_real)
validate_bool($ignore_selected)

collectd::plugin { 'cgroups':
ensure => $ensure,
content => template('collectd/plugin/cgroups.conf.erb'),
Expand Down
15 changes: 4 additions & 11 deletions manifests/plugin/cpu.pp
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
# https://collectd.org/wiki/index.php/Plugin:CPU
class collectd::plugin::cpu (
$ensure = 'present',
$reportbystate = true,
$reportbycpu = true,
$valuespercentage = false,
$reportnumcpu = false,
Boolean $reportbystate = true,
Boolean $reportbycpu = true,
Boolean $valuespercentage = false,
Boolean $reportnumcpu = false,
$interval = undef,
) {

include ::collectd

validate_bool(
$reportbystate,
$reportbycpu,
$valuespercentage,
$reportnumcpu,
)

collectd::plugin { 'cpu':
ensure => $ensure,
content => template('collectd/plugin/cpu.conf.erb'),
Expand Down
4 changes: 1 addition & 3 deletions manifests/plugin/curl_json.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
define collectd::plugin::curl_json (
$url,
$instance,
$keys,
Hash $keys,
$ensure = 'present',
$host = undef,
$interval = undef,
Expand All @@ -21,8 +21,6 @@

include ::collectd

validate_hash($keys)

$_manage_package = pick($manage_package, $::collectd::manage_package)

if $_manage_package {
Expand Down
Loading

0 comments on commit 15a028f

Please sign in to comment.