HEX
Server: Apache
System: Linux dinesh8189 5.15.98-grsec-sharedvalley-2.lc.el8.x86_64 #1 SMP Thu Mar 9 09:07:30 -03 2023 x86_64
User: cgmgerenciamento1 (814285)
PHP: 8.1.26
Disabled: apache_child_terminate,dl,escapeshellarg,escapeshellcmd,exec,link,mail,openlog,passthru,pcntl_alarm,pcntl_exec,pcntl_fork,pcntl_get_last_error,pcntl_getpriority,pcntl_setpriority,pcntl_signal,pcntl_signal_dispatch,pcntl_sigprocmask,pcntl_sigtimedwait,pcntl_sigwaitinfo,pcntl_strerror,pcntl_wait,pcntl_waitpid,pcntl_wexitstatus,pcntl_wifexited,pcntl_wifsignaled,pcntl_wifstopped,pcntl_wstopsig,pcntl_wtermsig,php_check_syntax,php_strip_whitespace,popen,proc_close,proc_open,shell_exec,symlink,system
Upload Files
File: //opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/functions/find_template.rb
# Finds an existing template from a module and returns its path.
#
# This function accepts an argument that is a String as a `<MODULE NAME>/<TEMPLATE>`
# reference, which searches for `<TEMPLATE>` relative to a module's `templates`
# directory on the primary server. (For example, the reference `mymod/secret.conf.epp`
# will search for the file `<MODULES DIRECTORY>/mymod/templates/secret.conf.epp`.)
#
# The primary use case is for agent-side template rendering with late-bound variables
# resolved, such as from secret stores inaccessible to the primary server, such as
#
# ```
# $variables = {
#   'password' => Deferred('vault_lookup::lookup',
#                   ['secret/mymod', 'https://vault.example.com:8200']),
# }
#
# # compile the template source into the catalog
# file { '/etc/secrets.conf':
#   ensure  => file,
#   content => Deferred('inline_epp',
#                [find_template('mymod/secret.conf.epp').file, $variables]),
# }
# ```
#
#
#
# This function can also accept:
#
# * An absolute String path, which checks for the existence of a template from anywhere on disk.
# * Multiple String arguments, which returns the path of the **first** template
#   found, skipping nonexistent files.
# * An array of string paths, which returns the path of the **first** template
#   found from the given paths in the array, skipping nonexistent files.
#
# The function returns `undef` if none of the given paths were found.
#
# @since 6.x
#
Puppet::Functions.create_function(:find_template, Puppet::Functions::InternalFunction) do
  dispatch :find_template do
    scope_param
    repeated_param 'String', :paths
  end

  dispatch :find_template_array do
    scope_param
    repeated_param 'Array[String]', :paths_array
  end

  def find_template_array(scope, array)
    find_template(scope, *array)
  end

  def find_template(scope, *args)
    args.each do |file|
      found = Puppet::Parser::Files.find_template(file, scope.compiler.environment)
      if found && Puppet::FileSystem.exist?(found)
        return found
      end
    end
    nil
  end
end