diff options
-rw-r--r-- | lib/puppet/indirector/exec.rb | 6 | ||||
-rwxr-xr-x | spec/unit/indirector/exec.rb | 7 |
2 files changed, 7 insertions, 6 deletions
diff --git a/lib/puppet/indirector/exec.rb b/lib/puppet/indirector/exec.rb index 2462e31da..5b51142c3 100644 --- a/lib/puppet/indirector/exec.rb +++ b/lib/puppet/indirector/exec.rb @@ -39,11 +39,7 @@ class Puppet::Indirector::Exec < Puppet::Indirector::Terminus begin output = execute(external_command) rescue Puppet::ExecutionFailure => detail - if $?.exitstatus == 1 - return nil - else - Puppet.err "Could not retrieve external node information for %s: %s" % [name, detail] - end + Puppet.err "Failed to find %s via exec: %s" % [name, detail] return nil end diff --git a/spec/unit/indirector/exec.rb b/spec/unit/indirector/exec.rb index e474de8b9..4a7e2b50e 100755 --- a/spec/unit/indirector/exec.rb +++ b/spec/unit/indirector/exec.rb @@ -47,5 +47,10 @@ describe Puppet::Indirector::Exec do @searcher.find(@request).should be_nil end - it "should be able to execute commands with multiple arguments" + it "should return nil and log an error if there's an execution failure" do + @searcher.expects(:execute).with(%w{/echo foo}).raises(Puppet::ExecutionFailure.new("message")) + + Puppet.expects(:err) + @searcher.find(@request).should be_nil + end end |