4
說我有以下廚師角色:廚師的角色和環境default_attributes無法訪問
name "test"
description "role for test"
run_list %w(recipe[cookbook_name])
default_attributes(
:cookbook_name => {
:a => 1
}
)
和相應的環境:
name "test environment"
description "environment for test"
default_attributes(
:cookbook_name => {
:b => 2
}
)
然後在我的食譜的屬性我有這樣的:
parent = default[:cookbook_name]
parent[:c] = 3
attribute documentation會讓我相信這些將是一個在node[:cookbook_name][:a]
或node[:cookbook_name][:b]
的配方範圍內可用。但是,當我嘗試訪問我的實際烹飪書中的內容時,我得到了nil
。這是怎麼回事?我是否誤解了這些屬性的作用?我認爲值得注意的是,即使我在屬性文件中爲這些屬性設置了默認值,我也得到了相同的結果,導致我相信我正在訪問錯誤的屬性。
我在做什麼錯?
是的,但事實證明環境未能上傳。謝謝你的好回答! –