1 # Test whether a given class or definition is defined
2 require 'puppet/parser/functions'
4 Puppet::Parser::Functions.newfunction(:getparam,
7 Takes a resource reference and name of the parameter and
8 returns value of resource's parameter.
12 define example_resource($param) {
15 example_resource { "example_resource_instance":
16 param => "param_value"
19 getparam(Example_resource["example_resource_instance"], "param")
21 Would return: param_value
24 reference, param = vals
25 raise(ArgumentError, 'Must specify a reference') unless reference
26 raise(ArgumentError, 'Must specify name of a parameter') unless param and param.instance_of? String
28 return '' if param.empty?
30 if resource = findresource(reference.to_s)
31 return resource[param] if resource[param]