diff --git a/manifests/plugin/aggregation.pp b/manifests/plugin/aggregation.pp index 467858e7f..ff1c43904 100644 --- a/manifests/plugin/aggregation.pp +++ b/manifests/plugin/aggregation.pp @@ -16,5 +16,9 @@ 'ensure' => $ensure, } - create_resources(collectd::plugin::aggregation::aggregator, $aggregators, $defaults) + $aggregators.each |String $resource, Hash $attributes| { + collectd::plugin::aggregation::aggregator { $resource: + * => $defaults + $attributes, + } + } } diff --git a/manifests/plugin/curl.pp b/manifests/plugin/curl.pp index 81dde252a..44b5f6222 100644 --- a/manifests/plugin/curl.pp +++ b/manifests/plugin/curl.pp @@ -27,5 +27,9 @@ 'ensure' => $ensure, } - create_resources(collectd::plugin::curl::page, $pages, $defaults) + $pages.each |String $resource, Hash $attributes| { + collectd::plugin::curl::page { $resource: + * => $defaults + $attributes, + } + } } diff --git a/manifests/plugin/dbi.pp b/manifests/plugin/dbi.pp index eb801e19c..7da68f2ae 100644 --- a/manifests/plugin/dbi.pp +++ b/manifests/plugin/dbi.pp @@ -10,7 +10,15 @@ include ::collectd - $_manage_package = pick($manage_package, $::collectd::manage_package) + $_manage_package = pick($manage_package, $::collectd::manage_package) + + $_databases_defaults = { + 'ensure' => $ensure, + } + + $_queries_defaults = { + 'ensure' => $ensure, + } if $facts['os']['family'] == 'RedHat' { if $_manage_package { @@ -53,10 +61,15 @@ target => "${collectd::plugin_conf_dir}/dbi-config.conf", } - $defaults = { - 'ensure' => $ensure, + $databases.each |String $resource, Hash $attributes| { + collectd::plugin::dbi::database { $resource: + * => $_databases_defaults + $attributes, + } } - create_resources(collectd::plugin::dbi::database, $databases, $defaults) - create_resources(collectd::plugin::dbi::query, $queries, $defaults) + $queries.each |String $resource, Hash $attributes| { + collectd::plugin::dbi::query { $resource: + * => $_queries_defaults + $attributes, + } + } } diff --git a/manifests/plugin/exec.pp b/manifests/plugin/exec.pp index 4d415abd8..28fd9d9c8 100644 --- a/manifests/plugin/exec.pp +++ b/manifests/plugin/exec.pp @@ -1,9 +1,10 @@ # See http://collectd.org/documentation/manpages/collectd.conf.5.shtml#plugin_exec class collectd::plugin::exec ( - Hash $commands = {}, - $interval = undef, - $ensure = 'present', - Boolean $globals = false, + Hash $commands = {}, + Hash $commands_defaults = {}, + $interval = undef, + $ensure = 'present', + Boolean $globals = false, ) { include ::collectd @@ -38,5 +39,9 @@ target => $exec_conf, } - create_resources(collectd::plugin::exec::cmd, $commands) + $commands.each |String $resource, Hash $attributes| { + collectd::plugin::exec::cmd { $resource: + * => $commands_defaults + $attributes, + } + } } diff --git a/manifests/plugin/filecount.pp b/manifests/plugin/filecount.pp index 3e885b3ee..b895ebbbb 100644 --- a/manifests/plugin/filecount.pp +++ b/manifests/plugin/filecount.pp @@ -13,7 +13,11 @@ $values = values($directories) if size($values) > 0 and is_hash($values[0]) { $content = undef - create_resources(collectd::plugin::filecount::directory, $directories, {ensure => $ensure}) + $directories.each |String $resource, Hash $attributes| { + collectd::plugin::filecount::directory { $resource: + * => { ensure => $ensure } + $attributes, + } + } } else { $content = template('collectd/plugin/filecount.conf.erb') } diff --git a/manifests/plugin/network.pp b/manifests/plugin/network.pp index 6cce4345c..147ff2848 100644 --- a/manifests/plugin/network.pp +++ b/manifests/plugin/network.pp @@ -12,14 +12,29 @@ include ::collectd + $listeners_defaults = { + 'ensure' => $ensure, + } + + $servers_defaults = { + 'ensure' => $ensure, + } + collectd::plugin { 'network': ensure => $ensure, content => template('collectd/plugin/network.conf.erb'), interval => $interval, } - $defaults = { - 'ensure' => $ensure, + + $listeners.each |String $resource, Hash $attributes| { + collectd::plugin::network::listener { $resource: + * => $listeners_defaults + $attributes, + } + } + + $servers.each |String $resource, Hash $attributes| { + collectd::plugin::network::server { $resource: + * => $servers_defaults + $attributes, + } } - create_resources(collectd::plugin::network::listener, $listeners, $defaults) - create_resources(collectd::plugin::network::server, $servers, $defaults) } diff --git a/manifests/plugin/postgresql.pp b/manifests/plugin/postgresql.pp index 16f8ac674..5a98b2c1a 100644 --- a/manifests/plugin/postgresql.pp +++ b/manifests/plugin/postgresql.pp @@ -10,7 +10,10 @@ include ::collectd - $_manage_package = pick($manage_package, $::collectd::manage_package) + $_manage_package = pick($manage_package, $::collectd::manage_package) + $databases_defaults = { 'ensure' => $ensure } + $queries_defaults = { 'ensure' => $ensure } + $writers_defaults = { 'ensure' => $ensure } if $facts['os']['family'] == 'RedHat' { if $_manage_package { @@ -45,11 +48,21 @@ target => "${collectd::plugin_conf_dir}/postgresql-config.conf", } - $defaults = { - 'ensure' => $ensure, + $databases.each |String $resource, Hash $attributes| { + collectd::plugin::postgresql::database { $resource: + * => $databases_defaults + $attributes, + } + } + + $queries.each |String $resource, Hash $attributes| { + collectd::plugin::postgresql::query { $resource: + * => $queries_defaults + $attributes, + } } - create_resources(collectd::plugin::postgresql::database, $databases, $defaults) - create_resources(collectd::plugin::postgresql::query, $queries, $defaults) - create_resources(collectd::plugin::postgresql::writer, $writers, $defaults) + $writers.each |String $resource, Hash $attributes| { + collectd::plugin::postgresql::writer { $resource: + * => $writers_defaults + $attributes, + } + } } diff --git a/manifests/plugin/powerdns.pp b/manifests/plugin/powerdns.pp index a49f8b9e9..c1629d8a2 100644 --- a/manifests/plugin/powerdns.pp +++ b/manifests/plugin/powerdns.pp @@ -3,13 +3,16 @@ Enum['present', 'absent'] $ensure = 'present', Integer $order = 10, Optional[Numeric] $interval = undef, - Optional[Hash[String, Hash]] $servers = undef, - Optional[Hash[String, Hash]] $recursors = undef, + Optional[Hash[String, Hash]] $servers = {}, + Optional[Hash[String, Hash]] $recursors = {}, Optional[String] $local_socket = undef, ) { include collectd + $servers_defaults = { 'ensure' => $ensure } + $recursors_defaults = { 'ensure' => $ensure } + collectd::plugin { 'powerdns': ensure => $ensure, order => $order, @@ -36,21 +39,15 @@ target => "${collectd::plugin_conf_dir}/powerdns-config.conf", } - $defaults = { 'ensure' => $ensure } - - if $servers { - create_resources( - collectd::plugin::powerdns::server, - $servers, - $defaults, - ) + $servers.each |String $resource, Hash $attributes| { + collectd::plugin::powerdns::server { $resource: + * => $servers_defaults + $attributes, + } } - if $recursors { - create_resources( - collectd::plugin::powerdns::recursor, - $recursors, - $defaults - ) + $recursors.each |String $resource, Hash $attributes| { + collectd::plugin::powerdns::recursor { $resource: + * => $recursors_defaults + $attributes, + } } } diff --git a/manifests/plugin/processes.pp b/manifests/plugin/processes.pp index ec1f79784..a4ca0a5a4 100644 --- a/manifests/plugin/processes.pp +++ b/manifests/plugin/processes.pp @@ -12,6 +12,9 @@ include ::collectd + $processes_defaults = { 'ensure' => $ensure } + $process_matches_defaults = { 'ensure' => $ensure } + collectd::plugin { 'processes': ensure => $ensure, order => $order, @@ -38,23 +41,21 @@ target => "${collectd::plugin_conf_dir}/processes-config.conf", } - $defaults = { 'ensure' => $ensure } - if $processes { $process_resources = collectd_convert_processes($processes) - create_resources( - collectd::plugin::processes::process, - $process_resources, - $defaults, - ) - + $process_resources.each |String $resource, Hash $attributes| { + collectd::plugin::processes::process { $resource: + * => $processes_defaults + $attributes, + } + } } + if $process_matches { $process_matches_resources = collectd_convert_processes($process_matches) - create_resources( - collectd::plugin::processes::processmatch, - $process_matches_resources, - $defaults - ) + $process_matches_resources.each |String $resource, Hash $attributes| { + collectd::plugin::processes::processmatch { $resource: + * => $process_matches_defaults + $attributes, + } + } } } diff --git a/manifests/plugin/python.pp b/manifests/plugin/python.pp index 2f6a4ecea..9f11d4b45 100644 --- a/manifests/plugin/python.pp +++ b/manifests/plugin/python.pp @@ -93,5 +93,10 @@ 'ensure' => $ensure, 'modulepath' => $module_dirs[0], } - create_resources(collectd::plugin::python::module, $modules, $defaults) + + $modules.each |String $resource, Hash $attributes| { + collectd::plugin::python::module { $resource: + * => $defaults + $attributes, + } + } } diff --git a/manifests/plugin/tail.pp b/manifests/plugin/tail.pp index a6d205e71..70ae77eb8 100644 --- a/manifests/plugin/tail.pp +++ b/manifests/plugin/tail.pp @@ -2,14 +2,18 @@ # https://collectd.org/wiki/index.php/Plugin:Tail class collectd::plugin::tail ( $interval = undef, - Optional[Hash] $files = undef, + Optional[Hash] $files = {}, ) { collectd::plugin { 'tail': interval => $interval, } - if $files { - create_resources(collectd::plugin::tail::file, $files) + $defaults = {} + + $files.each |String $resource, Hash $attributes| { + collectd::plugin::tail::file { $resource: + * => $defaults + $attributes, + } } } diff --git a/manifests/plugin/write_graphite.pp b/manifests/plugin/write_graphite.pp index aeddec8a6..061ef6c5b 100644 --- a/manifests/plugin/write_graphite.pp +++ b/manifests/plugin/write_graphite.pp @@ -1,6 +1,6 @@ # https://collectd.org/wiki/index.php/Graphite class collectd::plugin::write_graphite ( - Hash $carbons = {}, + Hash $carbons = {}, $carbon_defaults = {}, $ensure = 'present', $globals = false, @@ -38,7 +38,11 @@ target => $graphite_conf, } - create_resources(collectd::plugin::write_graphite::carbon, $carbons, $carbon_defaults) + $carbons.each |String $resource, Hash $attributes| { + collectd::plugin::write_graphite::carbon { $resource: + * => $carbon_defaults + $attributes, + } + } } 'absent': { file { $graphite_conf: