Reputation: 3945
I am experiencing a recurring, yet random, error. Sometimes this works but more often than not I get a timeout on a very simple powershell_script
resource. Chef doesn't seem to wait the default timeout (3600 seconds) but immediately throws this exception. Is there something I'm missing here? How can I debug the
Mixlib::ShellOut::CommandTimeout
?
================================================================================
Error executing action `run` on resource 'powershell_script[uninstall]'
================================================================================
Mixlib::ShellOut::CommandTimeout
--------------------------------
command timed out:
---- Begin output of "C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -InputFormat None -File "C:/Users/vagrant/AppData/Local/Temp/chef-script20180924-2936-1r1bagl.ps1" ----
STDOUT:
STDERR:
---- End output of "C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -InputFormat None -File "C:/Users/vagrant/AppData/Local/Temp/chef-script20180924-2936-1r1bagl.ps1" ----
ProcessId: 1664
app_name: C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe
command_line: "C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -InputFormat None -File "C:/Users/vagrant/AppData/Local/Temp/chef-script20180924-2936-1r1bagl.ps1"
timeout: 3600
Resource Declaration:
---------------------
# In C:/Users/vagrant/AppData/Local/Temp/kitchen/cache/cookbooks/documents/recipes/service.rb
7: powershell_script "uninstall" do
8: only_if { ::File.exist?('C:\Documents\scripts\Uninstall.ps1') }
9: code <<-SCRIPT
10: "Trying to uninstall...."
11: . C:\\Documents\\scripts\\Uninstall.ps1 > C:\\Documents\\Uninstall.log
12: SCRIPT
13: end
14:
Upvotes: 0
Views: 611
Reputation: 1576
What Chef version are you using specificly?
Though, if you would like to debug, I guess trying to pass your command directly into Mixlib::ShellOut.new(cmd, :timeout => 3600)
is a good starting point.
However, after I google it a bit I have just found out that powershell resource used to have some issues like https://github.com/chef/mixlib-shellout/issues/86, https://github.com/chef/chef/issues/2348, so not sure if they have been fixed in newer version etc.
Therefore, an alternate solution to consider is using dsc
script with Chef
( that is, https://docs.chef.io/resource_dsc_script.html with https://learn.microsoft.com/en-us/powershell/dsc/scriptresource ) which I think might be more reliable.
Upvotes: 1