Puppet Function: glob

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

Overview

glob()Any

Returns an Array of file entries of a directory or an Array of directories. Uses same patterns as Dir#glob

Returns:

  • (Any)


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'modules/stdlib/lib/puppet/parser/functions/glob.rb', line 5

newfunction(:glob, :type => :rvalue, :doc => <<-'DOC'
  Returns an Array of file entries of a directory or an Array of directories.
  Uses same patterns as Dir#glob
  DOC
           ) do |arguments|

  unless arguments.size == 1
    raise(Puppet::ParseError, 'glob(): Wrong number of arguments given ' \
      "(#{arguments.size} for 1)")
  end

  pattern = arguments[0]

  unless pattern.is_a?(String) || pattern.is_a?(Array)
    raise(Puppet::ParseError, 'glob(): Requires either array or string ' \
      'to work')
  end

  Dir.glob(pattern)
end