]> git.donarmstrong.com Git - dsa-puppet.git/blob - modules/stdlib/lib/puppet/parser/functions/getvar.rb
162114995b3f6645b7ec884d434d86e260f9828c
[dsa-puppet.git] / modules / stdlib / lib / puppet / parser / functions / getvar.rb
1 module Puppet::Parser::Functions
2
3   newfunction(:getvar, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args|
4     Lookup a variable in a remote namespace.
5
6     For example:
7
8         $foo = getvar('site::data::foo')
9         # Equivalent to $foo = $site::data::foo
10
11     This is useful if the namespace itself is stored in a string:
12
13         $datalocation = 'site::data'
14         $bar = getvar("${datalocation}::bar")
15         # Equivalent to $bar = $site::data::bar
16     ENDHEREDOC
17
18     unless args.length == 1
19       raise Puppet::ParseError, ("getvar(): wrong number of arguments (#{args.length}; must be 1)")
20     end
21
22     self.lookupvar("#{args[0]}")
23
24   end
25
26 end