diff options
author | Jay Mundrawala <jdmundrawala@gmail.com> | 2015-03-02 09:12:00 -0800 |
---|---|---|
committer | Jay Mundrawala <jdmundrawala@gmail.com> | 2015-03-02 09:12:00 -0800 |
commit | 22ad70b28136a2f99362ec13af50f32c99756cac (patch) | |
tree | 53846d3c257ccadc45d6a457e9700d52120ae289 | |
parent | 91eff901bdad40f91dc5592d76fba7c927f2c03c (diff) | |
download | chef-jdm/yum-fix.tar.gz |
Use shell_out instead of output_of_command for yum package providerjdm/yum-fix
The yum package provider was broken by #2924 because
Chef::Mixin::Command was removed from the base Package provider.
Without this patch, I was getting:
```
NoMethodError
-------------
undefined method `output_of_command' for #<Chef::Provider::Package::Yum:0x00000003a5f278>
```
when trying to execute
```ruby
package "gdb" do
action :install
end
```
on Centos 6.5
Chef was breaking in weird ways and it didn't produce a stacktrace.out,
which was a little concerning, however that's a different bug
-rw-r--r-- | lib/chef/provider/package/yum.rb | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/chef/provider/package/yum.rb b/lib/chef/provider/package/yum.rb index 405e4177ab..4f90b5eb2e 100644 --- a/lib/chef/provider/package/yum.rb +++ b/lib/chef/provider/package/yum.rb @@ -984,7 +984,7 @@ class Chef end def yum_command(command) - status, stdout, stderr = output_of_command(command, {:timeout => Chef::Config[:yum_timeout]}) + status = shell_out(command, {:timeout => Chef::Config[:yum_timeout]}) # This is fun: rpm can encounter errors in the %post/%postun scripts which aren't # considered fatal - meaning the rpm is still successfully installed. These issue @@ -996,21 +996,19 @@ class Chef # A cleaner solution would have to be done in python and better hook into # yum/rpm to handle exceptions as we see fit. if status.exitstatus == 1 - stdout.each_line do |l| + status.stdout.each_line do |l| # rpm-4.4.2.3 lib/psm.c line 2182 if l =~ %r{^error: %(post|postun)\(.*\) scriptlet failed, exit status \d+$} Chef::Log.warn("#{@new_resource} caught non-fatal scriptlet issue: \"#{l}\". Can't trust yum exit status " + "so running install again to verify.") - status, stdout, stderr = output_of_command(command, {:timeout => Chef::Config[:yum_timeout]}) + status = shell_out(command, {:timeout => Chef::Config[:yum_timeout]}) break end end end if status.exitstatus > 0 - command_output = "STDOUT: #{stdout}" - command_output << "STDERR: #{stderr}" - Chef::Mixin::Command.handle_command_failures(status, command_output, {}) + status.error! end end |