[英]How can a chef LW resource attribute default value refer to another attribute?
[英]chef attributes value not getting parsed in another attribute
我在default.rb中設置屬性為
default[:my_app] = {
:vol => "data02",
:commitlog => "/foo/bar/node[:vol]/commitlog",
}
但是:vol
值未在commitlog屬性中解析,並且出現以下錯誤。
mError executing action `create` on resource 'directory[/foo/bar/node[:vol]/comitlog]'[0m
您缺少字符串插值語法,例如y = "The value of X is #{X}."
您可能想要:
default[:my_app] = {
:vol => "data02",
:commitlog => "/foo/bar/#{node[:vol]}/commitlog",
}
另外,請記住,如果使一個屬性依賴於另一個屬性的值,則稍后可能會覆蓋node[:my_app][:vol]
並期望node[:my_app][:commitlog]
的值隨之變化,可能不會。 這些屬性將一起解析,可能在您的覆蓋影響第一個屬性之前。
即使在我使用插值語法之后,以及在配方中使用node [:my_app] [:commitlog]時,它也會顯示/ foo / bar // commitlog
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.