1 module Puppet::Parser::Functions
3 newfunction(:getvar, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args|
4 Lookup a variable in a remote namespace.
8 $foo = getvar('site::data::foo')
9 # Equivalent to $foo = $site::data::foo
11 This is useful if the namespace itself is stored in a string:
13 $datalocation = 'site::data'
14 $bar = getvar("${datalocation}::bar")
15 # Equivalent to $bar = $site::data::bar
18 unless args.length == 1
19 raise Puppet::ParseError, ("getvar(): wrong number of arguments (#{args.length}; must be 1)")
23 self.lookupvar("#{args[0]}")
24 rescue Puppet::ParseError # Eat the exception if strict_variables = true is set