如何在厨师中使用自定义属性,以便可以在默认配方中传递一些值?

how to use custom attribute in chef, so one can pass some value in default recipe?

我想做的是传递两个值 输入 1 和输入 2 到 recipe/default.rb。

这些值来自 jason 文件。现在我使用这些输入来解析我的模板 xml.

template "/tmp/temp_chef_sample.xml" do
  source "temp_chef_sample.xml.erb"
  variables( :fsIP => node[:hostname], :fsname => node[:ipaddress], :path=>    node[:input1], :value=> node[:input2] )
end

我有两个问题。

  1. 如何在属性列表中添加属性 "path" 和 "value"?
  2. 如何在不使用 json
  3. 的情况下填充它们

很多地方都可以设置节点属性

说明书的属性文件

# cookbook/attributes/filename.rb
...
node.default[:input1] = 'somevalue'
...

环境、角色或节点对象

....
"default_attributes": {
  "input1": "somevalue"
}
....