【问题标题】:How to write a wrapper cookooks in chef for the local cookbooks and not dependent on the chef community chef cookbooks?如何在厨师中为当地的烹饪书编写包装烹饪书,而不依赖于厨师社区的厨师烹饪书?
【发布时间】:2018-12-11 19:38:37
【问题描述】:

我有两本从头开始编写的基本厨师食谱,一本食谱依赖于另一本。这两本食谱都不依赖于社区食谱。所以,我被要求用 2 个基本的厨师食谱创建一个包装食谱

例如: 我有两本食谱“test-a”和“test-b”,它们都可以在本地托管的厨师服务器上使用,并且不依赖于社区食谱。

Ask 是用上面的食谱“test-a”和“test-b”创建一个包装食谱“test”。这样,他们就可以做一把刀 bootstrap/role/run_list。

提前致谢

【问题讨论】:

    标签: chef-infra wrapper devops knife


    【解决方案1】:

    role 对象中使用run_list。在你的情况下,它应该是这样的:

    $ cat roles/test.json
    {
      "run_list": [
        "recipe[test-a]",
        "recipe[test-b]"
      ]
    }
    

    另一种方法是创建另一个名为test 的食谱并使用include_recipe,它应该是这样的:

    $ cat test/recipes/default.rb
    include_recipe 'test-a'
    include_recipe 'test-b'
    
    $ cat test/metadata.rb
    depends 'test-a'
    depends 'test-b'
    

    如果您有想要覆盖的属性,请在test 包装食谱中进行。例如,如果 test-a 食谱有一个属性,如 node.default[:foo] = 'baz',那么您可以按如下方式覆盖它

    $ cat test/attributes/default.rb
    node.default[:foo] = 'spam'
    

    考虑阅读厨师博客上的Writing Wrapper CookbooksDoing Wrapper Cookbooks Right

    【讨论】:

    • 感谢您的信息。那么如何将覆盖属性传递给包装器说明书。
    • @Jeetu:根据你的问题,我更新了我的答案。我希望它能解决你的问题。如果有,请accept it
    猜你喜欢
    • 2011-07-03
    • 1970-01-01
    • 2017-07-10
    • 2010-11-04
    • 1970-01-01
    • 2011-09-24
    • 2011-09-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多