Sha256: ba92cee65ddb2a6424cff2a323a15e2e168938416d380f77304af94617475574

Contents?: true

Size: 1.12 KB

Versions: 19

Compression:

Stored size: 1.12 KB

Contents

#
# global_array.rb
#
# See: global_param.rb
#
module Puppet::Parser::Functions
  newfunction(:global_array, :type => :rvalue, :doc => <<-EOS
This function performs a lookup for a variable value in various locations:
See: global_params()
If no value is found in the defined sources, it returns an empty array ([])
    EOS
) do |args|
    
    value = nil
    CORL.run do
      raise(Puppet::ParseError, "global_array(): Define at least the variable name " +
        "given (#{args.size} for 1)") if args.size < 1
    
      var_name = args[0]
      default  = ( args.size > 1 ? args[1] : [] ) 
      options  = ( args.size > 2 ? args[2] : {} )
      node     = CORL::Provisioner::Puppetnode.node
    
      config = CORL::Config.init_flat(options, [ :param, :global_array, var_name ], {
        :provisioner     => :puppetnode,
        :hiera_scope     => self,
        :puppet_scope    => self,
        :search          => 'core::default',
        :force           => true,
        :merge           => true,
        :undefined_value => :undef
      })
      value = node.lookup_array(var_name, default, config)
    end
    return value
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
corl-0.5.18 lib/puppet/parser/functions/global_array.rb
corl-0.5.17 lib/puppet/parser/functions/global_array.rb
corl-0.5.16 lib/puppet/parser/functions/global_array.rb
corl-0.5.15 lib/puppet/parser/functions/global_array.rb
corl-0.5.14 lib/puppet/parser/functions/global_array.rb
corl-0.5.13 lib/puppet/parser/functions/global_array.rb
corl-0.5.12 lib/puppet/parser/functions/global_array.rb
corl-0.5.11 lib/puppet/parser/functions/global_array.rb
corl-0.5.10 lib/puppet/parser/functions/global_array.rb
corl-0.5.9 lib/puppet/parser/functions/global_array.rb
corl-0.5.8 lib/puppet/parser/functions/global_array.rb
corl-0.5.7 lib/puppet/parser/functions/global_array.rb
corl-0.5.6 lib/puppet/parser/functions/global_array.rb
corl-0.5.5 lib/puppet/parser/functions/global_array.rb
corl-0.5.4 lib/puppet/parser/functions/global_array.rb
corl-0.5.3 lib/puppet/parser/functions/global_array.rb
corl-0.5.2 lib/puppet/parser/functions/global_array.rb
corl-0.5.1 lib/puppet/parser/functions/global_array.rb
corl-0.5.0 lib/puppet/parser/functions/global_array.rb