Chef: How to increase the CommandTimout for Mixlib::ShellOut in a ruby block

chefruby

I'm trying to perform a database data load in a chef recipe on an Ubuntu 14.04 system with a Chef 11.10.4 based client. I'm doing the data load in a ruby block and here are the relevant portions of the error in the log:

Mixlib::ShellOut::CommandTimeout

Command timed out after 600s:

Command exceeded allowed execution time, killed by TERM signal.

[2015-10-06T01:24:00+00:00] ERROR: ruby_block[Load Dataset] (chef-virtuoso::load line 178) had an error:
Mixlib::ShellOut::CommandTimeout: Command timed out after 600s:

Anyone know how to increase the default CommandTimeout to 3600 for a shell_out! in a ruby block?

Here is the ruby block from the recipe that is failing:

::Chef::Recipe.send(:include, Chef::Mixin::ShellOut)

ruby_block "Load Dataset" do
  block do
    shell_out!(DATA_LOAD_COMMAND)
  end
end

Best Answer

shell_out! takes an optional second parameter hash which may specify a timeout :

shell_out!(DATA_LOAD_COMMAND, timeout: 7200)

That being said, based on your example it really doesn't look like you need to use a ruby_block resource and would likely benefit more from either a script or execute resource instead.

Both of those support a timeout resource property which would do the same thing. You'll find additional documentation on the execute resource in the official docs : https://docs.chef.io/resource_execute.html