- From: Ash Berlin <
>
- To:
- Subject: [chef] Re: how to debug errors
- Date: Mon, 13 Sep 2010 11:25:01 +0100
On 13 Sep 2010, at 11:19, Ran Tavory wrote:
>
I'm only learning chef now and find it hard to develop and debug my recipe
>
errors.
>
All I can see are verbose stack traces but it's usually quite hard to dig
>
the real error from the traces. The example below does not, as far as I can
>
tell hint any specific error in my code (and there are obviously errors...)
>
so I'm left with g-old trial and error.
>
I was wondering what's the best approach to advance faster while leaning
>
developing. I've made myself familiar with chef's basics and ran a few
>
tutorials but when writing my own first recipe I'm having hard time
>
bootstrapping.
>
>
The error below indicates some sort of bash error in a recipe although I'm
>
not sure exactly what. I suppose the following code uses the wrong syntax
>
but the real question isn't about the syntax it's about finding an
>
effective way to write-compile-test.
>
>
17 bash "install_app" do
>
18 user "root"
>
19 code <<-EOH
>
20 mkdir -p #{node[:wars]}
>
21 cp #{node[:war_src]} #{node[:war_dest]}
>
22 EOH
>
23 end
>
Run with chef debug logging enable to see the full command output/error:
chef-solo -l debug ....
Also using bash to make a directory and the copy a file isn't what I'd
consider the 'chef' way of doing things.
directory node[:wars] do
recursive true
mode '0755'
end
etc.
-ash
>
>
>
imageserver]# chef-solo -c ~/solo.rb -j ~/node.json
>
[Mon, 13 Sep 2010 11:52:06 +0200] INFO: Setting the run_list to
>
["recipe[imageserver]"] from JSON
>
[Mon, 13 Sep 2010 11:52:06 +0200] INFO: Starting Chef Run (Version 0.9.8)
>
[Mon, 13 Sep 2010 11:52:06 +0200] ERROR: bash[install_app]
>
(/tmp/chef-solo/cookbooks/imageserver/recipes/default.rb:17:in `from_file')
>
had an error:
>
"bash" "/tmp/chef-script.17504.0" returned 1, expected 0
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/mixin/command.rb:184:in
>
`handle_command_failures'
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/mixin/command.rb:131:in
>
`run_command'
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/provider/execute.rb:49:in
>
`action_run'
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/provider/script.rb:33:in
>
`action_run'
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/runner.rb:51:in
>
`send'
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/runner.rb:51:in
>
`run_action'
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/runner.rb:109:in
>
`converge'
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/runner.rb:108:in
>
`each'
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/runner.rb:108:in
>
`converge'
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/resource_collection.rb:94:in
>
`execute_each_resource'
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/resource_collection/stepable_iterator.rb:116:in
>
`call'
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/resource_collection/stepable_iterator.rb:116:in
>
`call_iterator_block'
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/resource_collection/stepable_iterator.rb:85:in
>
`step'
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/resource_collection/stepable_iterator.rb:104:in
>
`iterate'
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/resource_collection/stepable_iterator.rb:55:in
>
`each_with_index'
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/resource_collection.rb:92:in
>
`execute_each_resource'
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/runner.rb:82:in
>
`converge'
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/client.rb:304:in
>
`converge'
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/client.rb:87:in `run'
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/application/solo.rb:191:in
>
`run_application'
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/application/solo.rb:181:in
>
`loop'
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/application/solo.rb:181:in
>
`run_application'
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/application.rb:62:in
>
`run'
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/chef-solo:25
>
/usr/bin/chef-solo:19:in `load'
>
/usr/bin/chef-solo:19
>
[Mon, 13 Sep 2010 11:52:06 +0200] ERROR: Running exception handlers
>
[Mon, 13 Sep 2010 11:52:06 +0200] ERROR: Exception handlers complete
>
[Mon, 13 Sep 2010 11:52:06 +0200] ERROR: Re-raising exception:
>
Chef::Exceptions::Exec - "bash" "/tmp/chef-script.17504.0" returned 1,
>
expected 0
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/mixin/command.rb:184:in
>
`handle_command_failures'
>
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/mixin/command.rb:131:in
>
`run_command'
>
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/provider/execute.rb:49:in
>
`action_run'
>
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/provider/script.rb:33:in
>
`action_run'
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/runner.rb:51:in
>
`send'
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/runner.rb:51:in
>
`run_action'
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/runner.rb:109:in
>
`converge'
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/runner.rb:108:in
>
`each'
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/runner.rb:108:in
>
`converge'
>
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/resource_collection.rb:94:in
>
`execute_each_resource'
>
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/resource_collection/stepable_iterator.rb:116:in
>
`call'
>
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/resource_collection/stepable_iterator.rb:116:in
>
`call_iterator_block'
>
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/resource_collection/stepable_iterator.rb:85:in
>
`step'
>
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/resource_collection/stepable_iterator.rb:104:in
>
`iterate'
>
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/resource_collection/stepable_iterator.rb:55:in
>
`each_with_index'
>
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/resource_collection.rb:92:in
>
`execute_each_resource'
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/runner.rb:82:in
>
`converge'
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/client.rb:304:in
>
`converge'
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/client.rb:87:in
>
`run'
>
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/application/solo.rb:191:in
>
`run_application'
>
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/application/solo.rb:181:in
>
`loop'
>
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/application/solo.rb:181:in
>
`run_application'
>
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/application.rb:62:in
>
`run'
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/chef-solo:25
>
/usr/bin/chef-solo:19:in `load'
>
/usr/bin/chef-solo:19
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/mixin/command.rb:184:in
>
`handle_command_failures': "bash" "/tmp/chef-script.17504.0" returned 1,
>
expected 0 (Chef::Exceptions::Exec)
>
from
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/mixin/command.rb:131:in
>
`run_command'
>
from
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/provider/execute.rb:49:in
>
`action_run'
>
from
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/provider/script.rb:33:in
>
`action_run'
>
from
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/runner.rb:51:in
>
`send'
>
from
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/runner.rb:51:in
>
`run_action'
>
from
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/runner.rb:109:in
>
`converge'
>
from
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/runner.rb:108:in
>
`each'
>
from
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/runner.rb:108:in
>
`converge'
>
... 13 levels...
>
from
>
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/application.rb:62:in
>
`run'
>
from /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/chef-solo:25
>
from /usr/bin/chef-solo:19:in `load'
>
from /usr/bin/chef-solo:19
>
>
>
thanks
Archive powered by MHonArc 2.6.16.