Regarding #1. Next I include the backtrace. Just to point out that "chef-client version" in the node shows "Starting Chef Run (Version 0.9.18)". However Chef server is 0.10.4
[Wed, 11 Apr 2012 10:05:26 +0200] DEBUG: Loading Recipe application::java_webapp via include_recipe
[Wed, 11 Apr 2012 10:05:26 +0200] DEBUG: Found recipe java_webapp in cookbook application
[Wed, 11 Apr 2012 10:05:26 +0200] ERROR: Running exception handlers
[Wed, 11 Apr 2012 10:05:26 +0200] ERROR: Exception handlers complete
[Wed, 11 Apr 2012 10:05:26 +0200] DEBUG: Re-raising exception: ArgumentError - Attribute chef_environment is not defined!
/usr/lib/ruby/1.8/chef/node/attribute.rb:428:in `method_missing'
/usr/lib/ruby/1.8/chef/node.rb:319:in `send'
/usr/lib/ruby/1.8/chef/node.rb:319:in `method_missing'
/var/cache/chef/cookbooks/application/recipes/java_webapp.rb:28:in `from_file'
/usr/lib/ruby/1.8/chef/cookbook_version.rb:473:in `load_recipe'
/usr/lib/ruby/1.8/chef/mixin/language_include_recipe.rb:40:in `include_recipe'
/usr/lib/ruby/1.8/chef/mixin/language_include_recipe.rb:27:in `each'
/usr/lib/ruby/1.8/chef/mixin/language_include_recipe.rb:27:in `include_recipe'
/var/cache/chef/cookbooks/application/recipes/default.rb:31:in `from_file'
/var/cache/chef/cookbooks/application/recipes/default.rb:28:in `each'
/var/cache/chef/cookbooks/application/recipes/default.rb:28:in `from_file'
/var/cache/chef/cookbooks/application/recipes/default.rb:25:in `each'
/var/cache/chef/cookbooks/application/recipes/default.rb:25:in `from_file'
/usr/lib/ruby/1.8/chef/search/query.rb:39:in `call'
/usr/lib/ruby/1.8/chef/search/query.rb:39:in `search'
/usr/lib/ruby/1.8/chef/search/query.rb:39:in `each'
/usr/lib/ruby/1.8/chef/search/query.rb:39:in `search'
/usr/lib/ruby/1.8/chef/mixin/language.rb:135:in `search'
/var/cache/chef/cookbooks/application/recipes/default.rb:21:in `from_file'
/usr/lib/ruby/1.8/chef/cookbook_version.rb:473:in `load_recipe'
/usr/lib/ruby/1.8/chef/mixin/language_include_recipe.rb:40:in `include_recipe'
/usr/lib/ruby/1.8/chef/mixin/language_include_recipe.rb:27:in `each'
/usr/lib/ruby/1.8/chef/mixin/language_include_recipe.rb:27:in `include_recipe'
/usr/lib/ruby/1.8/chef/run_context.rb:94:in `load'
/usr/lib/ruby/1.8/chef/run_context.rb:91:in `each'
/usr/lib/ruby/1.8/chef/run_context.rb:91:in `load'
/usr/lib/ruby/1.8/chef/run_context.rb:55:in `initialize'
/usr/lib/ruby/1.8/chef/client.rb:166:in `new'
/usr/lib/ruby/1.8/chef/client.rb:166:in `run'
/usr/lib/ruby/1.8/chef/application/client.rb:222:in `run_application'
/usr/lib/ruby/1.8/chef/application/client.rb:212:in `loop'
/usr/lib/ruby/1.8/chef/application/client.rb:212:in `run_application'
/usr/lib/ruby/1.8/chef/application.rb:62:in `run'
/usr/bin/chef-client:26
/usr/lib/ruby/1.8/chef/node/attribute.rb:428:in `method_missing': Attribute chef_environment is not defined! (ArgumentError)
from /usr/lib/ruby/1.8/chef/node.rb:319:in `send'
from /usr/lib/ruby/1.8/chef/node.rb:319:in `method_missing'
from /var/cache/chef/cookbooks/application/recipes/java_webapp.rb:28:in `from_file'
from /usr/lib/ruby/1.8/chef/cookbook_version.rb:473:in `load_recipe'
from /usr/lib/ruby/1.8/chef/mixin/language_include_recipe.rb:40:in `include_recipe'
from /usr/lib/ruby/1.8/chef/mixin/language_include_recipe.rb:27:in `each'
from /usr/lib/ruby/1.8/chef/mixin/language_include_recipe.rb:27:in `include_recipe'
from /var/cache/chef/cookbooks/application/recipes/default.rb:31:in `from_file'
from /var/cache/chef/cookbooks/application/recipes/default.rb:28:in `each'
from /var/cache/chef/cookbooks/application/recipes/default.rb:28:in `from_file'
from /var/cache/chef/cookbooks/application/recipes/default.rb:25:in `each'
from /var/cache/chef/cookbooks/application/recipes/default.rb:25:in `from_file'
from /usr/lib/ruby/1.8/chef/search/query.rb:39:in `call'
from /usr/lib/ruby/1.8/chef/search/query.rb:39:in `search'
from /usr/lib/ruby/1.8/chef/search/query.rb:39:in `each'
from /usr/lib/ruby/1.8/chef/search/query.rb:39:in `search'
from /usr/lib/ruby/1.8/chef/mixin/language.rb:135:in `search'
from /var/cache/chef/cookbooks/application/recipes/default.rb:21:in `from_file'
from /usr/lib/ruby/1.8/chef/cookbook_version.rb:473:in `load_recipe'
from /usr/lib/ruby/1.8/chef/mixin/language_include_recipe.rb:40:in `include_recipe'
from /usr/lib/ruby/1.8/chef/mixin/language_include_recipe.rb:27:in `each'
from /usr/lib/ruby/1.8/chef/mixin/language_include_recipe.rb:27:in `include_recipe'
from /usr/lib/ruby/1.8/chef/run_context.rb:94:in `load'
from /usr/lib/ruby/1.8/chef/run_context.rb:91:in `each'
from /usr/lib/ruby/1.8/chef/run_context.rb:91:in `load'
from /usr/lib/ruby/1.8/chef/run_context.rb:55:in `initialize'
from /usr/lib/ruby/1.8/chef/client.rb:166:in `new'
from /usr/lib/ruby/1.8/chef/client.rb:166:in `run'
from /usr/lib/ruby/1.8/chef/application/client.rb:222:in `run_application'
from /usr/lib/ruby/1.8/chef/application/client.rb:212:in `loop'
from /usr/lib/ruby/1.8/chef/application/client.rb:212:in `run_application'
from /usr/lib/ruby/1.8/chef/application.rb:62:in `run'
from /usr/bin/chef-client:26
On Wed, Apr 11, 2012 at 9:50 AM, Andrea Campi
<
">
> wrote:
On Wed, Apr 11, 2012 at 9:20 AM, <
">
> wrote:
> Hi all,
>
> I have installed chef 0.10.4 and I am testing the application cookbook.
>
> The thing is that executing this cookbookit fails when the recipe
> application::java_webapp.rb tries to get the value of the method
> chef_environment of the Node Object (node.chef_environment). This is the error:
>
> Re-raising exception: ArgumentError - Attribute chef_environment is not
> defined!
First of all, be aware that I'm currently on refactoring the
application cookbook, I will have a replacement ready in the next few
weeks.
Having said that, the current one shouldn't fail like this.
Can you show me where it fails? A backtrace would be most useful.
> I have checked the node with knife node edit command and I have seen that the
> attribute chef_environment is set to "_default"
>
> *****
> "chef_environment": "_default",
> "run_list": [
> "recipe[application]",
> "role[my_app]"
> ]
> *****
>
> So, I guess the value of the node.chef_environment should be "_default", what
> is the problem?
>
> On the other hand, I have tried to modify the environment of this node via
> knife by changing the value to "prooduction" (after creating this environment
> in the chef server as it is said in the Usage section of this cookbook ) and It
> happens two things:
> 1)The recipe still fails (same error)
> 2)The chef_environment in the node is changed back to "_default" after excution
> of the recipe
Regarding #2, that can happen if you edit the node while a chef-client
run is happening on the client.
I assume you tried again, but try again :)
This is the sequence of the commands that I execute:
1)knife node edit <node_name>
2)I go to the "chef_environment" attribute and I write "production" instaead of "_default"
3)I save the changes (!wq with vi EDITOR)
4)I wait a minute and type again knife node edit <node_name> to check the value is still "production" (it is)
5) I ecxecute "chef-client" in the node whose run_list includes the cookbook application
6)The cookbook fails (the problem stated above)
7)I type again knife node edit <node_name> and the values is back to "_default"
Andrea