Puppet Function: realize_collectd_plugins

Defined in:
lib/puppet/parser/functions/realize_collectd_plugins.rb
Function type:
Ruby 3.x API

Overview

realize_collectd_plugins()Any

wrapper around realize() to fit the needs of the collectd module

Returns:

  • (Any)


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/puppet/parser/functions/realize_collectd_plugins.rb', line 1

Puppet::Parser::Functions::newfunction(
  :realize_collectd_plugins,
  :doc => "wrapper around realize() to fit the needs of the collectd module"
) do |args|

  raise Puppet::ParseError,
    ("accepts exactly 3 arguments") unless args.length == 3

  builtins = args.pop
  prefix   = args.pop
  plugins  = args.pop

  raise Puppet::ParseError,
    ("1st arg must be an Array")  unless plugins.is_a?(Array)
  raise Puppet::ParseError,
    ("2nd arg must be an String") unless prefix.is_a?(String)
  raise Puppet::ParseError,
    ("3rd arg must be an Array")  unless builtins.is_a?(Array)

  # see http://docs.puppetlabs.com/guides/custom_functions.html#calling-functions-from-functions
  Puppet::Parser::Functions.autoloader.loadall

  (plugins - builtins).each do |plugin|
    resource_name = "Collectd::Setup::Loadplugin[#{prefix}#{plugin}]"
    #Puppet.send(:warning, "about to realize #{resource_name}")
    function_realize([resource_name])
  end
end