Sha256: 779c43fa8b7e5d0065fce4f41eee4089aa96ac6bb9176eff1cba897f914f1330

Contents?: true

Size: 1.19 KB

Versions: 266

Compression:

Stored size: 1.19 KB

Contents

require 'puppet/indirector/terminus'
require 'puppet/util'

class Puppet::Indirector::Exec < Puppet::Indirector::Terminus
  # Look for external node definitions.
  def find(request)
    name = request.key
    external_command = command

    # Make sure it's an array
    raise Puppet::DevError, _("Exec commands must be an array") unless external_command.is_a?(Array)

    # Make sure it's fully qualified.
    raise ArgumentError, _("You must set the exec parameter to a fully qualified command") unless Puppet::Util.absolute_path?(external_command[0])

    # Add our name to it.
    external_command << name
    begin
      output = execute(external_command, :failonfail => true, :combine => false)
    rescue Puppet::ExecutionFailure => detail
      raise Puppet::Error, _("Failed to find %{name} via exec: %{detail}") % { name: name, detail: detail }, detail.backtrace
    end

    if output =~ /\A\s*\Z/ # all whitespace
      Puppet.debug "Empty response for #{name} from #{self.name} terminus"
      return nil
    else
      return output
    end
  end

  private

  # Proxy the execution, so it's easier to test.
  def execute(command, arguments)
    Puppet::Util::Execution.execute(command,arguments)
  end
end

Version data entries

266 entries across 266 versions & 2 rubygems

Version Path
puppet-5.5.22 lib/puppet/indirector/exec.rb
puppet-5.5.22-x86-mingw32 lib/puppet/indirector/exec.rb
puppet-5.5.22-x64-mingw32 lib/puppet/indirector/exec.rb
puppet-5.5.22-universal-darwin lib/puppet/indirector/exec.rb
puppet-6.17.0 lib/puppet/indirector/exec.rb
puppet-6.17.0-x86-mingw32 lib/puppet/indirector/exec.rb
puppet-6.17.0-x64-mingw32 lib/puppet/indirector/exec.rb
puppet-6.17.0-universal-darwin lib/puppet/indirector/exec.rb
puppet-5.5.21 lib/puppet/indirector/exec.rb
puppet-5.5.21-x86-mingw32 lib/puppet/indirector/exec.rb
puppet-5.5.21-x64-mingw32 lib/puppet/indirector/exec.rb
puppet-5.5.21-universal-darwin lib/puppet/indirector/exec.rb
puppet-6.16.0 lib/puppet/indirector/exec.rb
puppet-6.16.0-x86-mingw32 lib/puppet/indirector/exec.rb
puppet-6.16.0-x64-mingw32 lib/puppet/indirector/exec.rb
puppet-6.16.0-universal-darwin lib/puppet/indirector/exec.rb
puppet-6.15.0 lib/puppet/indirector/exec.rb
puppet-6.15.0-x86-mingw32 lib/puppet/indirector/exec.rb
puppet-6.15.0-x64-mingw32 lib/puppet/indirector/exec.rb
puppet-6.15.0-universal-darwin lib/puppet/indirector/exec.rb