質問

I'm using Chef 11.8.2, with open source chef server I have the following statements in my role and cookbook file:

roles/webserver.rb

name "webserver"
description "Web Servers"
run_list %w{recipe[my_cookbook]}
default_attributes({
     "company" => "OPSCODE"
})

cookbooks/my_cookbook/recipes/default.rb

puts node.default.inspect

It only prints "{}". And I checked that the node is correctly assigned to role webserver:

C:\chef\chef-repo>knife node show chef-client-1
Node Name:   chef-client-1
Environment: dev
FQDN:        chef-client-1.puncha.com
IP:          192.168.1.31
Run List:    role[webserver]
Roles:       webserver
Recipes:     my_cookbook
Platform:    ubuntu 12.10
Tags:
役に立ちましたか?

解決

You want to inspect the "compiled" attributes, not the default ones:

puts node.inspect
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top