Chef: Why I cannot access the attributes defined in Role?

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:

Answers


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

puts node.inspect

Need Your Help

How to open URL in Microsoft Edge from the command line?

windows-10 microsoft-edge

I need to open URL in Microsoft Edge (on Windows 10). When I invoke