5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | # File 'lib/puppet/trusted_external.rb', line 5 def retrieve(certname) command = Puppet[:trusted_external_command] return nil unless command Puppet.debug { _("Retrieving trusted external data from %{command}") % { command: command } } setting_type = Puppet.settings.setting(:trusted_external_command).type if setting_type == :file return fetch_data(command, certname) end data = {} Puppet::FileSystem.children(command).each do |file| abs_path = Puppet::FileSystem.expand_path(file) executable_file = Puppet::FileSystem.file?(abs_path) && Puppet::FileSystem.executable?(abs_path) unless executable_file Puppet.debug { _("Skipping non-executable file %{file}") % { file: abs_path } } next end basename = file.basename(file.extname).to_s unless data[basename].nil? raise Puppet::Error, _("There is more than one '%{basename}' script in %{dir}") % { basename: basename, dir: command } end data[basename] = fetch_data(abs_path, certname) end data end |