diff options
author | Tim Smith <tsmith84@gmail.com> | 2016-02-17 16:07:42 -0800 |
---|---|---|
committer | mcquin <claire@chef.io> | 2016-04-01 10:05:43 -0700 |
commit | 51f96b21e2fccf52fb0d717971bc6efd39611483 (patch) | |
tree | 6e23834ef52ee05b1e873e5c190c18f0411cacb9 | |
parent | e577c90e03951f109cad6b9cb8908281a8088748 (diff) | |
download | ohai-51f96b21e2fccf52fb0d717971bc6efd39611483.tar.gz |
Allow passing any of the mixlib-shellout options to the shell_out method
-rw-r--r-- | lib/ohai/mixin/command.rb | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/ohai/mixin/command.rb b/lib/ohai/mixin/command.rb index 6be29a7d..a27dff21 100644 --- a/lib/ohai/mixin/command.rb +++ b/lib/ohai/mixin/command.rb @@ -28,11 +28,15 @@ require "mixlib/shellout" module Ohai module Mixin module Command - def shell_out(cmd) - m = Mixlib::ShellOut.new(cmd, :timeout => 30) + # accept a command and any of the mixlib-shellout options + def shell_out(cmd, **options) + # unless specified by the caller timeout after 30 seconds + options[:timeout] = 30 unless options[:timeout] + m = Mixlib::ShellOut.new(cmd, options) begin m.run_command + # we should really fail here on non-0, but historically we haven't so we can't now if m.exitstatus == 0 Ohai::Log.debug("Plugin #{self.name} successfully ran command #{cmd}") else @@ -44,7 +48,7 @@ module Ohai Ohai::Log.debug("Plugin #{self.name} failed to run command #{cmd}") raise Ohai::Exceptions::Exec, e rescue Mixlib::ShellOut::CommandTimeout => e - Ohai::Log.debug("Plugin #{self.name} timeout after 30s running command #{cmd}") + Ohai::Log.debug("Plugin #{self.name} timed out after #{options[:timeout]}s running command #{cmd}") raise Ohai::Exceptions::Exec, e end end |