HEX
Server: Apache
System: Linux vpshost0650.publiccloud.com.br 4.4.79-grsec-1.lc.x86_64 #1 SMP Wed Aug 2 14:18:21 -03 2017 x86_64
User: bandeirantesbomb3 (10068)
PHP: 8.0.7
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: //proc/thread-self/root/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/face/catalog/select.rb
# Select and show a list of resources of a given type.
Puppet::Face.define(:catalog, '0.0.1') do
  action :select do
    summary _("Retrieve a catalog and filter it for resources of a given type.")
    arguments _("<host> <resource_type>")
    returns _(<<-'EOT')
      A list of resource references ("Type[title]"). When used from the API,
      returns an array of Puppet::Resource objects excised from a catalog.
    EOT
    description <<-'EOT'
      Retrieves a catalog for the specified host, then searches it for all
      resources of the requested type.
    EOT
    notes <<-'NOTES'
      By default, this action will retrieve a catalog from Puppet's compiler
      subsystem; you must call the action with `--terminus rest` if you wish
      to retrieve a catalog from the puppet master.

      FORMATTING ISSUES: This action cannot currently render useful yaml;
      instead, it returns an entire catalog. Use json instead.
    NOTES
    examples <<-'EOT'
      Ask the puppet master for a list of managed file resources for a node:

      $ puppet catalog select --terminus rest somenode.magpie.lan file
    EOT
    when_invoked do |host, type, options|
      # REVISIT: Eventually, type should have a default value that triggers
      # the non-specific behaviour.  For now, though, this will do.
      # --daniel 2011-05-03
      catalog = Puppet::Resource::Catalog.indirection.find(host)

      if type == '*'
        catalog.resources
      else
        type = type.downcase
        catalog.resources.reject { |res| res.type.downcase != type }
      end
    end

    when_rendering :console do |value|
      if value.nil? then
        _("no matching resources found")
      else
        value.map {|x| x.to_s }.join("\n")
      end
    end
  end
end