【问题标题】:how to use custom attribute in chef, so one can pass some value in default recipe?如何在厨师中使用自定义属性,以便可以在默认食谱中传递一些值?
【发布时间】:2015-03-21 04:33:43
【问题描述】:

我正在尝试传递两个值 input1 和 input2 到 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. 如何在属性列表中添加属性“路径”和“值”?
  2. 如何在不使用 json 的情况下填充它们

【问题讨论】:

    标签: attributes chef-infra


    【解决方案1】:

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

    食谱的属性文件

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

    环境、角色或节点对象

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

    【讨论】:

      猜你喜欢
      • 2017-08-21
      • 2021-04-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多